Social Interactive TV and Data Integration with XML

cakeexoticInternet και Εφαρμογές Web

13 Δεκ 2013 (πριν από 3 χρόνια και 7 μήνες)

227 εμφανίσεις

Social Interactive TV and Data
Integration with XML
Johan Norberg
June 18,2012
Master's Thesis in Computing Science,30 ECTS credits
Supervisor at CS-UmU:Thomas Johansson
Supervisor at Dohi Sweden:Linus Mahler Lundgren
Examiner:Fredrik Georgsson
Ume

a University
Department of Computing Science
SE-901 87 UME

A
SWEDEN
Abstract
During recent years Smart TVs have been growing in popularity and is said to be the
next big thing following the huge success of smartphones and tablets.Important aspects
of Smart TVs are the interactive and especially the social aspects that can be incorporated
into television broadcasting.This thesis explores the possibilities of creating social and
interactive applications based on events that occur during live events.This is done by rst
creating a framework that incorporates modules for aggregating events from various data
providers,social networking components and nally it contains a back-end for storing users'
interactions.The thesis contains a study focusing on various XML techniques and dierent
approaches to data integration to be able to choose the correct techniques needed for the
aggregator.Finally a prototype is developed to act as a proof-of-concept for the developed
framework,incorporating the social and interactive functionality found in the framework.
ii
Contents
1 Introduction 1
1.1 Background.....................................2
1.2 Goals........................................2
1.3 Purpose.......................................3
1.4 Related work....................................4
1.5 Thesis outline....................................4
2 Method 5
2.1 Outline.......................................5
2.2 Development method................................5
2.3 Tracking.......................................6
2.4 Orientation of Smart TV platforms........................6
3 Smart TVs 7
3.1 Background.....................................7
3.2 Orientation.....................................8
3.2.1 Set-top boxes................................8
3.2.2 Smart TV Platforms............................10
3.2.3 Conclusion.................................13
3.3 Google TV Streaming...............................13
4 Data transformation and integration with XML 17
4.1 Properties......................................17
4.2 XML Technologies.................................18
4.3 Heterogeneity....................................23
4.3.1 Problem description............................24
4.3.2 Approaches.................................24
4.3.3 Conclusion.................................26
4.3.4 Transformation with XML.........................26
4.4 Parser........................................29
4.4.1 Conclusion.................................29
iii
iv CONTENTS
4.5 Summary and discussion..............................30
5 Framework 31
5.1 Goals........................................31
5.2 Design........................................32
5.2.1 Communication...............................32
5.2.2 Back-end and web service.........................32
5.3 Social Networks...................................33
5.4 Aggregator.....................................34
5.4.1 Solution...................................35
5.5 Discussion......................................36
6 Prototype 39
6.1 Goals........................................39
6.2 Implementation...................................40
6.3 Results........................................40
7 Discussion 43
7.1 Restrictions.....................................43
7.2 Future work.....................................43
8 Acknowledgements 45
References 47
List of Figures
1.1 A high level overview of the system........................3
3.1 An overview of the HTTP live streaming playlist structure...........16
4.1 An overview of the ETL process..........................25
4.2 An overview of the virtulized integration paradigm................25
5.1 Overview of the aggregation system........................36
5.2 An overview of the framework...........................37
v
vi LIST OF FIGURES
Listings
3.1 XML message sent from Google TV.......................11
3.2 JSON message sent from Samsung TV......................13
4.1 XML tag examples.................................18
4.2 XML attribtute examples.............................19
4.3 XML example....................................20
4.4 XSLT transformation example...........................21
4.5 XML result after transformation.........................21
4.6 xQuery transformation example..........................22
4.7 XSD example....................................23
vii
viii LISTINGS
Chapter 1
Introduction
The purpose of Social TV is to bring people together and keep people connected even
though they are separate,creating what could be called an online living room.This is done
by having social interaction and communication,either in the context of watching television
or content related to the TV content.By the use of,for instance,text and voice chat,
context awareness,recommendations,rating of movies and TV shows or video conference a
social television system can be achieved either directly on the TV or on a secondary device.
TV used to be something very social where people would gather with friends and family
to watch a movie,a show or an event.The various achievements in technology has however
had an adverse eect on this.For instance,TVs have become much cheaper than they used
to be which has led to that most households have multiple TVs,therefore people often watch
TV separately in separate rooms.The rise of on-demand content has also put a dent in the
social aspect of TV since consumers can now watch their content at their own time.
This is where Social TV comes in.When watching something on TV,even if it is by
yourself,people are now always connected through the use of social networking services.
In America social networks and blogs reach 80% of the total Internet usage[2].During an
average day 300 million public social comments are made,about 200 million of these are
made on Twitter where about 10 million are related to television[3].
The fact that these social networks have so many users also enables one to nd like-
minded people.This also means that you are no longer limited to watch TV with people
based on proximity.
During recent years the number of broadcast TVviewers has declined,but recently shows
like the grammys,the oscars,the super bowl and so on have attracted much more viewers
and buzz.This is at least somewhat because of people sharing their opinions and views
on the programming through social networks such as Twitter[1].It is basically creating a
real-time water cooler
1
online.For instance,the latest Grammy show broke the record for
social comments in regards to a broadcast show,generating 13 million comments according
to Bluen Labs[4],which is a company that analyse publicly available social comments
related to TV.All this data that is being generated can for instance be used by networks to
research the demographic of a show or what show is most popular.It can also be used to
recommend shows to consumers.A survey conducted in the UK in 2010 showed that 45%
were using social networks to discuss the programming while it was being aired,using for
instance a laptop,desktop computer or a smartphone[9].
1
The water cooler eect is a phenomenon that occurs when employees of an oces gather around the
water cooler and chat.The topics discussed are said to have a water cooler eect.
1
2 Chapter 1.Introduction
1.1 Background
Dohi Sweden is a holding company for high-potential brands and services in the audiovisual
industry.They have a long background in development for mobile platforms and advanced
web.The company has an interest in Smart TVs and especially social products as they
believe it will become a lucrative market in the future and have therefore put eorts into
exploring this new technology.It is a very interesting area since there is little concrete
information and no good summary of available technologies because the technology is new
and changing very fast.
1.2 Goals
The rst goal of this thesis is to write an orientation about the currently available Smart
TV platforms.The orientation will consist of both vendor specic and platforms available
to multiple devices.The purpose of which is to become familiar with the current market
and the platforms capabilities.After that,a framework for Smart TVs will be developed
consisting of loosely coupled modules to ease the process of making social and interactive
applications.Lastly,a prototype for a Smart TV will be developed demonstrating the use of
the aforementioned framework.The target platform for the prototype will be chosen based
on the ndings in the overview of the Smart TV platforms.
The goals of this thesis projects are to:
{ Write an orientation of available Smart TV platforms and their capabilities.
{ Create a framework that enables and simplies the process of creating social and
interactive applications for Smart TVs.
{ Create a prototype for a Smart TV that overlays live video content and demonstrates
the use of the framework,by using the dierent modules which are described in the
following subsection.
Each of these goals can be viewed as separate tasks.As each of the goals are completely
dependant upon the previous one they also have to be nished in this order.
Framework
The functionality that were requested by the stakeholders (Dohi Sweden) to be incorporate
into the framework are described here.
{ Social components to easily enable developers to incorporate popular social networks,
such as Facebook and Twitter.
{ A module for aggregating events published in XML format which should be able to
handle XML documents of dierent structures.These events should be persisted as
they could be needed for keeping track of the events occurred.Events refer to events
that occur during live events,such as a penalty shot during a football game.The in-
depth study carried out in Chapter 4 explores dierent approaches and technologies
available when dealing heterogeneity and data integration for XML.
{ A back-end for storing user interactions that are created when responding to events
aggregated by the previous module and displayed on the television.
1.3.Purpose 3
Figure 1.1:A high level overview of the system.
Figure 1.1:A high level representation of the nished system with a remote control (used
by a potential user),the prototype and part of the framework functionality,the aggregator,
as represented by entities A,B and C,respectively.
An remote control is noted by A,which is interacting with the TV where the prototype,
labeled B,will run.This is as previously described the third goal of the thesis project.The
nal entity labeled C,is the aggregation module which is part of the second goal of creating
a framework.The aggregator is aggregating live events which a potential user,using the
remote control,is interacting with.
1.3 Purpose
This is an emerging technology that has not yet become as widespread as anticipated.
However,recent studies show that during 2012 there might be an increase in purchases[8].
That means it is very important to be on the forefront of oering expertise in these areas
if one wants to be able to become established.Considering that all goals are met this
thesis project and the developed framework can then be used as a foundation when creating
new applications for Smart TVs while the prototype will act as-proof-of concept for the
framework.
4 Chapter 1.Introduction
1.4 Related work
An additional project is also being carried out by another student from Umea University at
Dohi Sweden that is also directed at Smart TVs.That project,focuses on interactive ads
and facial recognition.However,some information sharing and discussions were possible to
achieve on some higher level topics.
1.5 Thesis outline
This section describes the outline of this thesis report.Chapter 2 explains the method used
for carrying out the thesis project.More detailed sections include the tools and methods
used throughout the project.Chapter 3 presents an overview of dierent platforms for
Smart TVs.The term"Smart TV"will be used to refer to the dierent Smart TVs even
though Samsung's Smart TV is named"Samsung Smart TV".Chapter 3 concludes with an
overview of dierent streaming protocols supported for the Google TV platform.Chapter
4 is an in-depth study exploring dierent approaches and technologies available to handle
heterogeneity and data integration for XML.This is essential to be able to understand
and use the correct approach and technology for creating the XML integration module
brie y described in Section 1.2.Chapter 5 goes on to describe the framework,its dierent
modules and the technologies used for each of them to achieve the goals dened for the
framework.Chapter 6 brie y presents the prototype as created to display the functionality
of the framework.Chapter 7 contains a discussion of the thesis project as a whole.
Chapter 2
Method
This chapter describes the methodology and development process used throughout the
project.Section 2.1 describes the work needed to complete the entire project.Section
2.2 describes the development method called Scrum which was used during the entirety of
this project and Section 2.3 describes the tool used for tracking progress of the project.
Continuing,Section 2.4 describes the approach to the orientation of Smart TV platforms in
Section 3.2.
2.1 Outline
The following describes a general and rough outline of the work that needed to be nished
to complete the thesis project.
1.Write an orientation of dierent available Smart TVplatforms,to get oriented with the
market and to help with the decision of choosing the target platformfor the framework
and prototype.
2.Gather requirements for the modules that will be incorporated into the framework.
3.Carry out an in-depth study related to XML data integration to be able to choose the
technologies suited when creating the XML aggregator as brie y described in Section
1.2.
4.Create a framework based on the requirements that were previously identied.
5.Develop a prototype that displays the functionality of the framework.
6.Document the results of the project.
2.2 Development method
The development method used at Dohi Sweden is the agile development method Scrum.
In Scrum the work of a project is divided into development units called sprints.A sprint
consist of a clear goal and have a restricted duration,which is one month or less.The reason
for having short sprints is to quickly build prototypes which can be tested,while also being
very adapt to responding to new requirements from stakeholders.
5
6 Chapter 2.Method
It is quite common for companies to adapt the method to better suit their specic needs.
Therefore,based on previous experience at the company and the fact that this is a project
thesis with limited time,some parts of the Scrum method have been removed.
Following is the list of activities that were carried out both weekly and daily with the
external supervisor at Dohi Sweden.
{ Daily Scrum - discussing:
 What was done yesterday
 Problems that had been encountered
 What had to be done until he next day
{ Sprint review (Every week):
 Go over completed weekly tasks
 Discuss encountered problems
 Go over tasks that had to be postponed or modied
 Show the project/prototype progress in a demo session
Every sprint begins with a sprint planning session which decides tasks which will be
included in the sprint.This held true for the entirety of the project.The tasks were to be
a maximum of eight hours.This means that each sprint will consist of at least ve tasks,
assuming that one work week consisted of ve days a week eight hours a day.The goal was
to divide each task so that they were at most four hours long since keeping tasks at a very
low level ensures that they are conceptually easy.This would result in ten tasks per week
and sprint,this was however not always possible.
If there were tasks from previous week that carried over to the next,these tasks could
either be re-prioritised,discarded or delayed.
2.3 Tracking
To help plan and track progress of the project a tool called Pivotal Tracker[5] was used,which
is a software as service.It is very well suited for the Scrum development process which,
as previously stated,was used during this project.Stories (tasks in Scrum terminology)
are created and assigned to a team member.They are placed in a backlog and ordered
by priority,after which these stories gets started,nished and nally accepted.Releases
(sprints) can also be created which are placed at the end of the backlog.When all stories are
completed and the release is completed a velocity based on the estimated time for the nished
tasks are calculated which can be used as a measurement of how the project progressed for
that sprint.
2.4 Orientation of Smart TV platforms
An orientation of platforms for Smart TVs will be written with focus on the more popular
platforms in Section 3.2.For each platform emphasis will be put on writing about the parts
of the platforms that were deemed most interesting considering the aspects of this thesis,
which is interactive and Social TV.Those aspects were mainly how interactivity can be
achieved and the possibilities of creating interactive applications
Chapter 3
Smart TVs
This chapter contains information that was needed to be gathered prior to beginning the
work on the implementation to get oriented in the area of the thesis.The goal of this chapter
is to gather information about dierent Smart TV platforms available on the market.The
study mainly focuses on two points which are how development is carried out and the
possibilities of creating interactive applications for each platform (i.e.controlling the TV
with a secondary device).A brief background of each platform is also provided.This means
that the study is mainly supposed to give a general overview of what the platforms are
capable of and how development is carried out from a developer's stand point.With the
help of this information the target for the prototype,that will be developed at the end of
the project,will be chosen.The study was carried out by scouring the net for information,
reading SDKs,press releases and at times trusted blogs.
Section 3.1 contains a brief background and description of Smart TVs in general.Pro-
ceeding,Section 3.2 contains a study regarding some of the more popular dierent Smart TV
platforms currently available on the market.Some focus is put on features in the dierent
SDKs for the various platforms that enable developers to make interactive applications.
Finally,Section 3.3 describes the dierent streaming possibilities for the Google TV,
which was chosen,as described in Section 3.2.3,to be the target for the prototype.
This is needed because as described later in the chapter it is not possible to create an
overlay on standard broadcasting for the Google TV platform.Therefore a video stream is
needed to create an overlay upon since one of the requirements for the prototype was that
it should overlay upon video content as described in Section 1.2.Playing a local le is not
sucient because the prototype is based on live content.
3.1 Background
A Smart TVs,which also is known as a Hybrid TV or a Connected TV,is a television or
set-top box that has Web 2.0 features incorporated into it.They often have a focus on
Internet TV,on-demand streaming and less focus on regular television broadcasting.This
technology is not limited to Smart TVs and set-top boxes but it is often found in game
consoles and Blu-ray players for instance.They often run a mobile or a complete operating
system which often allows end-users to install additional applications.On-demand video is
now often viewed on a computer or streamed to a TV from a computer,but with Smart
TVs it will be more convenient for the end-user to access such services.Smart TVs can also
7
8 Chapter 3.Smart TVs
often deliver content from a computer or a NAS
1
.
Smart TVs have been around for a while but have not taken over the market as thought as
the number of people owning a Smart TV is still low.However,according to The Guardian
the ownership of Smart TVs will take o during 2012[8].A study shows that by 2014
over 120 million Connected TVs will have been sold throughout the world[7].By 2014 the
households with a Connected TV will have increased from about 4 million in 2009 to about
47 million.Households with a Connected Blu-ray player will have increased from about 5
million in 2010 to about 66 million in 2014[9].
3.2 Orientation
This section contain a brief description of dierent platforms either found on televisions or
set-top boxes,or sometimes on both.There are both vendor specic platforms and those
that are available to third parties.
3.2.1 Set-top boxes
A set-top box,also known as a buddy box or companion box,is a small box that you connect
to a TV,meaning that it is without the actual screen,therefore an external TV is needed.
Not all set-top boxes are Smart TVs but some have that functionality.Some of the more
popular platforms that are found in the set-top box category are described below.
Apple TV
The rst Apple TV began shipping in march of 2007[10],with a platform based on OS X
Tiger.This did not succeed as intended because users had to streammedia froma computer.
This led in turn to\Take two"which was an update to the rst generation.Steve Jobs
said in a keynote in 2008 in relation to the release of the update[6]:
"Apple TV was designed to be an accessory for iTunes and your computer.It
was not what people wanted.We learned what people wanted was movies,movies,
movies."
The new update meant people were able to stream directly from the iTunes store.
The second generation was released in September 1,2010.The second generation uses
a platform based upon iOS
2
.The Apple TV platform is only available on the Apple TV
devices.The device can streammedia fromvarious providers and also via AirPlay
3
.A third
generation was released on March 12,2012.This is the rst of the Apple TVs that is able to
output video in 1080p.Apple TV does not have an application store,all applications avail-
able are the ones that are included when shipped.It also does it contain some applications
that have become common to include,such as a browser or social networking applications,
e.g.Facebook and Twitter.
Development It is not possible to create applications for the device.What is possible
however is to create an application that pushes content through AirPlay to the television.
This can create interesting applications such as games with dierent content being displayed
at the dierent screens.For instance in a racing game being run on an iPad one could control
1
Network-attached storagehttp://en.wikipedia.org/wiki/Network-attached_storage
2
iOS is the operating systemused in other Apple products,such as the iPod Touch,iPhone and the iPad.
3
AirPlay http://www.apple.com/airplay/
3.2.Orientation 9
the car with the accelerometer on the tablet,see through the windscreen of the car on the
TV and when looking at the tablet it could for instance display the rear-view mirror.In
terms of creating Social TV applications it does not display any real opportunities.
Boxee
The rst Boxee powered device was the Boxee Box by D-Link which was launched in Novem-
ber of 2010.The Boxee platform is based on the popular XBMC Media Center
4
.Boxee
can not show live TV without an additional USB-module called"Boxee Live TV".That
does however only provide selected channels and is currently only available in the US and
Canada[14].The Boxee platform is currently available on devices created by D-Link and
Iomega.
Development The development of applications for the Boxee platformis made with XML
for GUI markup and Python for scripting.Applications can also use HTML5 and JavaScript
combined with a specic avour of JavaScript that manages the Control Context
5
.The
JavaScript that is run in the control context does not have access to the DOM,instead it
has access to specic Boxee functionality.
Applications can be submitted through Boxee's website free of charge.After submission
they are reviewed and if approved they get added to the Boxee Application Directory.
Remote Boxee also provide an interface for communicating with a Boxee box,which
is based on JSON RPC
6
.First the Boxee must be discovered by the secondary device.
After the devices have been paired,the API can be accessed,which provide a variety of
functionality,such as changing the volume or play and pause video[16].
Roku
Roku was founded in 2002 by the inventor of the DVR (Digital Video Recorder),Anthony
Wood.Roku provides their own devices that run the Roku platform.The rst Net ix
Streaming Player was launched in 2008 called the Roku DVP[12].Roku is a streaming
media player,meaning it relies on various streaming services,such as NetFlix,HBO GO
and Pandora for providing content,i.e.movies,TV shows and music.There are currently
over 400 channels (the name of an application on the Roku platform) available on the
Channel Store[11].
Development Roku provide their own scripting language called BrightScript which is
similar to VisualBasic,that is used when developing applications for the Roku platform.
To make use of the features like the GPU,OpenGL and the Roku Game Remote,applications
need to be developed using the NDK (Native Development Kit).The NDK is however not
currently available to the public.
It is free to publish a Channel on the Channel Store.Before they are published Roku reviews
and ensures a level of quality of the applications[13].
4
XBMC Media Center http://en.wikipedia.org/wiki/XBMC
5
Control Script Context http://developer.boxee.tv/Control_Script_Context
6
JSON-RPC http://en.wikipedia.org/wiki/JSON-RPC
10 Chapter 3.Smart TVs
3.2.2 Smart TV Platforms
A Smart TV is a television that has the capability of being connected to the Internet,
but also the integration of sophisticated operating systems comparable to those found on
smartphones.Smart TVs often come with a few applications pre-installed,often including
a browser,social networking applications and streaming services.Some of the more popular
platforms that are available on Smart TVs are described in this section.
Google TV
Google TV is a platform built on the Chrome and Android platforms.The current version
of Android that is available on the TVs is Honeycomb 3.2.It is delivered with some basic
applications and a full browser,which is capable of most of the newest web technologies,such
as HTML5,CSS3,JavaScript and Flash.The rst Google TVs were launched in October
2010 in devices from both Sony and Logitech[18].
This initial launch were perhaps not as successful as intended as Logitech reported a
loss of over 100 million in operating prots,and cancelled the partnership[20].During 2012,
Samsung will also begin shipping Google TVs[19].
Eric Schmidt,Executive Chariman of Google,has high hopes for Google TV which was
made clear during LeWeb 2011,where he stated
"By the summer of 2012,...,the majority of the televisions that you see in the
television stores here,will have Google TV embedded in them."[21]
After the update to Honycomb 3.1 the Google TVs got access to the Android Market
7
,
where it is possible to purchase and download applications.This is the same market that
other Android powered devices have access to,the dierence is that only applications that
have support to be run on a Google TV is shown when accessing the store from a TV.
Development The same Android SDK can be used to develop for Google TV as the
one used when developing applications for smartphones,which means that most application
already work on the television.The only dierence being that TVs do not have access
to some functionality such as GEO location services and accelerometer,instead it can for
example list the channels available on the TV[17].An application can easily be published
to the market if one wants to distribute it.
An emulator is available through an add-on.It does however require Linux with a kernel-
based virtual machine.Meaning it does not support Windows or Macintosh platforms[17].
Overlay The creation of an overlay on top of regular broadcast TV is not something
intended in the Google TV platform,as it is not possible for a third party application to
hook into the live TV stream[22].However,if a streamof a video is used,creating an overlay
on top of that is very simple using one of Androids built in layouts.
Remote Google provides a protocol called the Anymote Protocol.This protocol is
used to easily enable interaction between a mobile device,e.g.smartphone,and a Google
TV.The TV will act as a server to which the other devices connect.After the pairing is
made,simple messages are sent to the TV which can also respond to the clients[17].
Listing 3.1 shows a message that indicates that the user has interacted with a key.
7
Now called Google Play
3.2.Orientation 11
Listing 3.1:XML message sent from Google TV
//Sends a key event to the server
message KeyEvent f
//Key code
required Code keycode = 1;
//Action (Up/Down)
required Action action = 2;
g
Yahoo!Connected TV
The Yahoo!Connected TV platform was released March 30,2009.An application store,
which was launched in late 2011,is also included in the platform called Yahoo!Connected
TV Store[23].In June 2011 Yahoo!reached 8 million sold devices,that is powered by their
platform[24].The Yahoo!Connected TV platform is available on a variety of devices from
manufacturers such as Sony,Samsung,Vizio and Toshiba[25].
Development Yahoo!provide a SDK for developing applications for their platformcalled
Widget Developer Kit (WDK).Although the name says widget the applications are able
to run in full screen as any other application is able to.The SDK is based on the use of
Javascript,XML and CSS.Yahoo also provides a simulator for testing applications[27].
Apps can be submitted to Yahoo!for approval and if they are approved they get pub-
lished on the TV Store.
Overlay An app is launched from a launcher called the Widget Dock,that,when
activated,is shown at the bottomof the screen on top of the programming[27].Applications
in Yahoo!Connected TV platform can be shown in three dierent views.The rst is called
a snippet which is shown in the launcher,it can be a static image or it can include dynamic
data.The second view is the sidebar,and the third is full screen.The fullscreen view is
also in two forms,the rst being is overlay is put upon the TV content and the second is
where the TV content is replaced with other content,such as a game or streaming video
content[28].
Remote The SDK also provides a model called device communication which enables
Internet connected devices to easily communicate with your application on the TV.This is
done by using a two-way message passing protocol over a local network.Discovery between
the TV and the secondary devices is made by Multicast DNS
8
and DNS Discovery Service
9
.
Once connected the device needs to be authenticated and authorised.When this nal step
is made communication can begin between the widget and the device[26].
Other In 2011 Yahoo!acquired IntoNow,which is a check-in service available on mo-
bile devices and tablets.At the core of IntoNow is SoundPrint,a ngerprinting service used
for identifying what show you are watching down to the exact episode.SoundPrint is now in-
corporated into Connected TV platforms which gives context of the content being watched.
This gives many opportunities,for instance more relevant adds[29].This information is
however currently not available to 3rd-party developers.
8
http://en.wikipedia.org/wiki/Multicast_DNS
9
http://www.dns-sd.org/
12 Chapter 3.Smart TVs
Samsung Smart TV
The Samsung Smart TV platform is called internet@tv,which is only available on Samsung
televisions.In 2010 they launched their application store called\Samsung Apps"where
both ocial and third-party applications are available.This was,according to Samsung,
the rst ever HDTV-based application store.At rst it was only open for free applications
but a few months later it also opened for premium apps[30],and as of January 2012 it
contains over 1400 applications[33].
Development Samsung provides their own SDK for developing applications for the inter-
net@tv platform called Samsung Smart TV SDK.They also provide an IDE which contains
an emulator,this is however only available for Windows.A Samsung Smart TV application
is basically a web page that is displayed in a browser,whilst also having access to TV spe-
cic functionality,i.e.make the volume higher and lower or accessing the le system.An
application consists of JavaScript,CSS,HTML and optionally Flash les[31].
Overlay An application can be displayed in three ways on a Samsung Smart TV[31].
These are:
{ Full-screen application.The application lls the entire screen.
{ Single-wide application.The application is only shown on part of the screen.
{ Ticker.Keeps the application on screen while other things are done on the TV.
A strange restriction is that applications that are launched in Europe must be in the
fullscreen view[31].
Remote The SDK provides two types of APIs for communicating with the TV.One
is called Interactive Remote,which relies on the Samsung Remote App (an application
available for tablets and smartphones running iOS or Android).The TV sends an XML
based layout to the app which is responsible for displaying it correctly.Other types of
messages can also be exchanged between the devices[32].
The second API is called Convergence.This is based on a REST-interface which means
that any device on the network can communicate with the TVusing UPnP discovery
10
.First
the client must discover the TV using SSDP (Simple Service Discovery Protocol) after which
the devices are paired together.After the connection is made messages can be exchanged.
Messages can be either in XML or JSON format and can also contain attachments such as
images or audio.
Listing 3.2 shows a predened system message in JSON which should be sent when the
TV needs to notify the client that the application has terminated[31].
10
http://en.wikipedia.org/wiki/Universal_Plug_and_Play
3.3.Google TV Streaming 13
Listing 3.2:JSON message sent from Samsung TV
f"widgetInfo":
f
"ID":"sampleApp",
"Version":"0.930",
"Status":"TERMINATED",
"widgetname":"sampleApp"
g
g
Future During 2012 Samsung's new TVs will be released featuring their new"Smart
Interaction"technology.This consists of motion control,voice control and face recognition.
This can be used to more easily navigate through the menus with the wave of a hand,search
by dictation,using one of the 20 to 30 languages that are supported and much more.It will
also feature a technology called"Smart Evolution"which will allow users to simply install
kits to keep their television up-to-date,without having to buy a completely new television
set.The TVs will have a slot in the back where the kits will be inserted and through this
the TVs will be,as Samsung call it,"future proof"[33].
Other platforms
There are many platforms that were not described in this study.Some of those include the
platforms provided by LG,Philips,Vizio and Panasonic.Devices such as the Xbox 360 and
Playstation 3 can also be considered as Smart TVs.There are also upcoming platforms such
as Ubuntu TV,which was presented during CES 2012.It has a very similar look and feel
as other unity 2d platforms.There are also a lot of rumours that Apple will be releasing a
Smart TV during 2012[34].If Apple were to release a complete Smart TV it could increase
the uptake of Smart TVs[35].
3.2.3 Conclusion
For this thesis the target for the prototype will be the Google TV platform.This choice
was made because it is possible to create and publish applications,the vast documentation
available for Android programming and the huge developer community.And because it is
simple to create multi-screen applications (which could be interesting in the future) and
because of the possibility to test application in the oces of Dohi Sweden since they have
a Google TV.Since Google TV cannot overlay software upon broadcast TV at this time,
overlaying upon a video stream was instead chosen as the approach to achieve an overlay
upon video content which was a requirement for the prototype.
3.3 Google TV Streaming
The previous section ended with a conclusion that the prototype would be developed tar-
geting the Google TV platform,but as stated previously in Section 3.2.2 it is not possible
to create an overlay on on top of broadcast television for the Google TV.Therefore a video
stream must be obtained to create an overlay upon,since overlaying the prototype upon
video content was a requirement,as described in 1.2.This was because having video below
the overlay is necessary to give an image of what the prototype would be like in a real
14 Chapter 3.Smart TVs
environment.This section is an orientation of the streaming protocols supported by the
Android SDK.
Real Time Streaming Protocol
Real Time Streaming Protocol,or RTSP,is used to establish and manage media sessions
betweens end points.It is used to deliver media streams,such as audio and video.The source
of the media can both be stored and live data.RTSP streaming only delivers the frame
that the user is currently viewing,which means that no unnecessary data is downloaded.
However,at the same time this means that one can not wait for a video to buer to ensure
smooth playback.RTSP is also capable of switching stream mid-playback,meaning it is
adaptive to changes in the environment.Such as a change to fullscreen playback or the
switch to a 3G network from a WiFi network.
RTSP is similar to HTTP in some aspects,but contrary to HTTP,which is stateless,
RTSP has a state.This state is managed by storing a session identier for the sessions.
This means that RTSP is not tied to a transport-level connection,and is capable of opening
and closing multiple transport connections to issue requests to the server during a RTSP
session.Since the requests are issued with a session id the requests will still eect the same
session.
Transport of data is not made by the RTSP protocol,and it is not dependant upon the
transport mechanism.RTP is used in combination with RTCP on most RTSP servers for
delivering the stream.RTP manages the transportation of the media streams while RTCP
helps synchronise and manage QoS
11
.
Commands which are useful to media playback are issued between the client and the
server.These commands are issued using TCP to ensure reliability.Most commands are
issued by the client but there are also commands that go in the other direction (i.e.from
the server to the client),such as REDIRECT [36].
Example of some of these commands are:
{ SETUP.A setup request is issued by the client to the server to specify how the
media shall be transported.The request includes the URI of the media stream,it
also species the transport mechanism that should be used for the stream,it is also
possible to send a request to the server to change transport mechanism for a stream
that is already playing,this is not however something that the servers must support.
Upon receiving a setup request the server generates a session identier for the session
and responds with the parameters that has been chosen.A setup request must have
been issued by the client before a play request can be issued.
{ PLAY.This will cause the stream to be played.A range can be specied if only part
if the stream is required.If no range is specied it will begin at the beginning.Or
if the stream is paused it will start at that point.It also possible to queue PLAY
requests on the server.Meaning the second requests will not be executed until the
rst request has been completed.
{ PAUSE.This will pause the stream.If the range parameter is not specied it will
pause immediately and indenitely.Otherwise the range parameter,which must only
11
Quality of Service
3.3.Google TV Streaming 15
contain a single value and not a range,instructs the server when to pause.No resources
on the server will be freed when the stream has been paused.
{ TEARDOWN.This will stop delivering the streamto the client that requested it.It
will will also free all resources associated with it on the server,including removing the
session identier.This means that if the clients wishes to play the stream a SETUP
has to be issued again.
HTTP Progressive Streaming/Download
While HTTP Progressive Download is not true streaming it does emulate the feel of stream-
ing.The entire le,that the user wants to consume,is located on a web server.The client
starts downloading the le which,in most cases,gets stored locally on the hard drive.It
creates a local buer from which it can start playing before the entire le has downloaded.
This way it gives feel that the le is being streamed.If the bit rate of the media exceeds
the download bit rate it cannot be consumed in real time.At the same time the media can
be encoded at higher rates then the bandwidth is capable of and still give smooth playback,
since it has been stored locally.That does however mean that one must buer the stream
a while before playback can be started.Otherwise playback will catch up to the buering
and playback will stop.
Since the download is progressive it will could potentially waste bandwidth.For instance
if a video is 10 minutes,and one stops watching the video after 2 minutes it could be the
case that the entire video has already been downloaded.The fact that the le is being
stored locally on the hard drive does also make it more exposed for illegal copying.
Adaptive bitrate streaming
There are various implementations of the adaptive streaming protocol created by Apple,
Microsoft,Adobe and Octoshape.The one described here is HTTP Live Streaming which
is implemented by Apple.
HTTPLive Streaming,henceforth known as HLS,was created by Apple to enable stream-
ing to the iPhone.If you develop an application for the iPhone App Store and the app
delivers video over cellular networks and the video either exceeds 10 minutes of duration or
exceeds 5MB of data in 5 minutes,you are required to use HLS[37].
It is built up by breaking down the overall source into a sequence of smaller media
segments,often of a length of a few seconds each.Each of these segments must either be
of MPEG-2 Transport Stream or an MPEG-2 audio elementary stream.The les are then
available as simple HTTP downloads which are referenced by URIs in a playlist,which must
be an extended m3u.The server can also provide the stream in various encodings and rate
of the same source.This is done by having a variant playlist that references the variant
streams.This makes HLS very dynamic and easy to optimise because dierent deceives can
select dierent streams depending on dierent conditions,such as its own or the network's
capabilities.Keeping in mind the explanation given of playlist referencing,a simple playlist
structure example can be reviewed in Figure 3.1.
This means that when the stream rst is requested the m3u le is downloaded and the
correct substream is selected.If it is a variant playlist the correct variant stream is rst
selected and then the substream.If the playlist does not contain the EXT-X-ENDLIST it is a
sliding window playlist which means that the playlist is part of an ongoing broadcast.The
client will then continuously reload the playlist to be able to locate the additional segments.
This enables the protocol to handle both bounded and unbounded streams[38].
16 Chapter 3.Smart TVs
Figure 3.1:An overview of the HTTP live streaming playlist structure.
Conclusion
Adaptive bitrate streaming combine the strong points of both RTSP and Progressive stream-
ing as it is bandwidth ecient.It handles quality switching and it works on standard web
servers over HTTP[39].The downside is that there are multiple implementations.However,
HLS is supported by quite a few clients such as Android iOS,Roku and WebOS.HLS could
therefore be a suitable solution for creating a stream that is both adaptive and accessible
by various platforms in dierent conditions.
Chapter 4
Data transformation and
integration with XML
This chapter presents the in-depth study that was carried out in order to to be able to
create the XML integration module that was brie y described in Section 1.2.It was crucial
to perform the study to be able to choose the best suited approached and technologies to
solve the problem.The rst section describes the properties against which the dierent
approaches and technologies were evaluated against.Section 4.2 introduces various XML
technologies and what they are used for.If the reader has a good understanding of these
technologies it might be possible to skip this section.Continuing,Section 4.3 describes the
general problem domain when dealing with data integration and dierent approaches to the
problem.It also concludes with comparing technologies used to transform XML.Section
4.4 discusses and compares dierent approaches used to parse XML.The chapter concludes
with Section 4.5 where a summary of the ndings of this study is presented.
4.1 Properties
This section describes the properties that the approaches and technologies that are re-
searched are evaluated against.They are all applicable to the data integration part of the
problemwhile only the rst two are related to the problemof eciently parsing XML.All are
however,as a collective,properties that are needed to create the desired XML aggregator.
{ Memory ecient.The module needs to be memory ecient.This is mostly a
problemwhen parsing XML as the XML les can have an arbitrary size and containing
many les in-memory can be very resource consuming.
{ Fast.The response from a program to the integrated data system needs to be fast
so that new data quickly can be presented.This pertains both to parsing,as the new
data needs to be quickly parsed,and the integration since it needs to be able to quickly
return a reply form the integrated data from the time the query was issued.
{ Dynamic.The module needs be able to integrate XML feeds of an arbitrary structure
and integrate them into one single view.
{ Minimise queries to publishers.As some publishers of XML data limit the number
of queries allowed during an interval it is important to keep the number of queries to
17
18 Chapter 4.Data transformation and integration with XML
the publishers as low as possible as to not exceed those limits.
4.2 XML Technologies
This section contain an overview of various XML technologies.It begins by describing XML
and goes on to introduce other XML technologies.
XML
XML,which stands for eXtensible Markup Language,is,as the name implies,a markup
language,readable by both humans and machines.
XML is a very exible and simple text format and was introduced in mid-1990,as
a less complex subset of SGML (Standard Generalized Markup Language:ISO 8879).It
immediately gained foot hold as a data interchange format and emerged as the de facto
standard for the sharing of data[60].
It became a recommendation of the World Wide Web Consortium (W3C)
1
in 1998.It
was originally designed for large-scale electronic publishing but it also plays an important
role of data exchange on the web and elsewhere.XML is completely platform-independent,
very simple and there is a large set of available tools for working with it.XML documents
are built up with a hierarchical and ordered tree structure.The structure is built up using
arbitrary tags.The logical structure of an XML document describes the manner in which
it is built up,not the contained data.XML is self-descriptive and does not contain any
predened tags,instead the author of the document creates them.
Logical Structure
{ Tag.A tag begins with"<"and ends with">".There are three types of tags.The
rst being the start tag,followed by the end tag and nally the empty-element tag,
all of which can be seen in Listing 4.1.
{ Element.An element begins with a start-tag and ends with a end-tag,or it is only an
empty-element tag.Examples can be seen in both Listing 4.1 and 4.2.The characters
between the start and end-tags,if any,are the element's content.The content may
contain markup,including other elements,which are called child elements,attributes,
text or a combination of them all.
{ Attribute.An attribute is a name-value pair that are associated with elements.
Attributes must appear inside a start tag or an empty-element tag.Examples of
attributes can be seen in Listing 4.2.
Listing 4.1:XML tag examples
<item> <! Start tag >
</item> <! End tag >
<br/> <! Emptyelement tag >
1
http://www.w3.org/Consortium/
4.2.XML Technologies 19
Listing 4.2:XML attribtute examples
<person sex="male"> <! Element with attribute >
<rstname>foo</rstname>
<lastname>bar</lastname>
</person>
<name rst="foo"last="bar"/> <! Emptyelement with attributes >
Namespaces Namespaces are used to distinguish elements and attributes between dif-
ferent XML vocabularies.This is done by providing unique names through the use of
namespaces to the dierent vocabularies.Namespaces are specied by an URI,the URI
however,is simply treated as a string.This means that it is just a simple name,there does
not have to be any information located at the URI.Namespaces are declared in an element
by the xmlns attribtue.
Well-formed A textual object is only a XML document if it is well-formed.According
to the W3C XML specication the processing of an XML document should be stopped if it
is not well-formed[41].An XML document must full certain conditions to be considered a
well-formed document[40].
Some of those conditions are listed below.
{ There is a single root element.This is the element a the top-level,parent of all other
elements,which must not appear in the content of any of the other elements.
{ The elements must be correctly nested.
{ The tag names are case-sensitive and must therefore match exactly.
{ All non empty tags must be delimited by an end tag.
{ The value of attribute needs to be quoted.
xPath
xPath has been a recommendation of W3C since Novemver 1999,xPath 2.0 became a
recommendation in January of 2007.It is a major element in XSLT and xQuery,both of
which are built upon xPath.Both XSLT and xQuery are described in the coming sections.
xPath started as a subset of XSL (eXtensible Stylesheet Language) but it soon became
an independent language.It is currently under the joint management of the xQuery and
XSL working groups.The purpose when the development for xPath started was to pro-
vide common syntax and semantics between XSLT and xPointer.xPath is used primarily
to address parts in an XML document,where it operates on the logical structure of an
XML document (i.e.the data model) rather than the surface syntax[48].It also contains
functionality for manipulating strings,numbers,boolean values and date and time compar-
ison to name a few,an example being creating a substring.It contains over 100 built-in
functions[49].
xPath models an entire XML document as a tree built up of nodes.There are seven types
of nodes,including element nodes,attribute nodes and text nodes.xPath can compute a
string-value for each type of node.The name of the node is simply the local part,but since
xPath fully supports namespaces,the nodes name can become a pair of the local part and
20 Chapter 4.Data transformation and integration with XML
the namespace URI.It then uses a path notation to navigate the tree structure of an XML
document.It can then select a set of nodes based on location with a path expression and
it can also lter those node sets based on predicates.An xPath expression could look like
/library/novel[position()<=2],which would return the rst two novel elements from
the document,as described in Listing 4.3.
Listing 4.3:XML example
<?xml version="1.0"?>
<library>
<novel username="1">
<title>1984</title>
<author>Orwell</author>
</novel>
<novel username="2">
<title>1Q84</title>
<author>Murakami</author>
</novel>
<comic username="3">
<title>Year One</title>
<author>Miller</author>
</comic>
</library>
XSLT
XSL Transformations (XSLT) is a transformation language and it became a W3C recom-
mendation in 1999.XSLT 2.0 became a recommendation in 2007.It can transforms XML
into a dierent output formats,e.g.Plain Text,HTML,SVG or other XML documents[51].
XSLT is also written in XML and is a well-formatted document.It is also often used by the
data integration community[53].
To navigate the XML document,XSLT uses xPath which was described in a previous
section.With XSLT it is possible to lter out,rename,add,remove,rearrange elements or
attributes and much more.
This can be achieved by declaring template rules,in the XSLT.A pattern is specied
in the template which corresponds to a node or nodes in the source document,as an xPath
expression.Those patterns are matched to nodes in the document upon which the trans-
formation is being performed,and the template is applied generating nodes in a result tree.
The template is capable of handling many useful elements,such as,for-each,if,sort,value-of
and more.
The following is an example of how,using an XSLT template,an input XML document
can be transformed.Listing 4.3 contains a XML document containing two books and one
graphic novel.The XSLT in Listing 4.4 is applied recursively on the nodes of the input
document,transforming novel elements into book elements.As the XSLT does not specify
a template rule for the comic element they are not included in the result document.It is
the same for the author element.The result of the transformation can be seen in Listing
4.5.
4.2.XML Technologies 21
Listing 4.4:XSLT transformation example
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="1.0">
<xsl:output method="xml"indent="yes"/>
<xsl:template match="/library">
<books>
<xsl:applytemplates select="novel"/>
</books>
</xsl:template>
<xsl:template match="novel">
<book id="f@usernameg">
<xsl:valueof select="title"/>
</book>
</xsl:template>
</xsl:stylesheet>
Listing 4.5:XML result after transformation
<?xml version="1.0"?>
<books>
<book id="1">1984</book>
<book id="2">1Q84</book>
</books>
xQuery
xQuery is,as previously stated,based on xPath and it became a W3C recommendation
in January of 2007.It is a language for querying,constructing and manipulating XML
documents.It is to XML what SQL is to databases[64],because it allows one to query the
logical structure of an XML document in an SQL-like manner[50].
xQuery is derived from a previous XML language called Quilt,which in turn also bor-
rowed futures from several other languages including,but not limited to,xPath 1.0,XQL
and SQL.
xQuery is an extension of xPath 2.0.By adding functionality such as FLWOR expres-
sion (FOR-LET-WHERE-ORDER BY-RETURN),element constructors,variables,func-
tions and updating capabilities it enriches the xPath functionality[53].Therefore any ex-
pression that is valid in both xPath 2.0 and xQuery will return the same results.xQuery
operates on the same logical structure of the document as xPath 2.0 does.
The xQuery expression in Listing 4.6 shows how the XML described in Listing 4.3 can
be transformed.The result of this expression will be the same as in the previous example,
meaning Listing 4.5.
22 Chapter 4.Data transformation and integration with XML
Listing 4.6:xQuery transformation example
<books>
f
for $n in doc("library.xml")//novel
return
<book id="f$n/@usernameg">
f $n/title/text() g
</book>
g
</books>
DTD
DTD,Document Type Denition,denes the document structure of a particular type of
XML document.A DTD itself is not an XML document.DTD is used to validate XML
documents.An XML document is said to be valid if it conforms to a specic DTD and an
XML document that is valid according to a specic DTD is said to be an instance of that
schema.
A DTD can be written directly in the XML or included as a reference.It is a formal
denition of a specic XML document.It can include declarations for attributes,elements,
entities and notations.It can for instance specify an elements name,content,the cardinality
2
of sub-elements.It can further specify the attributes for an element,its name,type and
optionally a default value.
XSD
XSD (XML Schema Denition) is recommended by W3C,and has been so since May 2001.
Similar to DTD it is used to dene the structure of an XML document and often used for
XML validation.Contrary to DTD however,XSD is a well-structured XML document.An
XML document that conforms to a specic schema is called an"instance document".This
is not to say that instances or schemas have to exist as separate documents,they can just
as well be records in a database or a stream of bytes in an application.
XSDs are said to be the successors of DTDs,and will soon replace DTDs in most web
applications.This is because they are extensible to future additions,they are richer and
more powerful than DTDs,they are written in XML,they support data types and they
support namespaces[46].
An XSD denes the legal structure of an XML,using the XML Schema Language.
Every XML Schema begins with the <schema> element,meaning it is the root of the doc-
ument.A schema can consist of various subelements,most notably element,complexType
and simpleType.The dierences between a complexType and a simpleType is that a
complexType contains additional elements and attributes whereas simpleType cannot con-
tain neither additional elements nor attributes.Both can however contain text.
A simpleType is a simple type that is derived from the built in simple types of the XML
Schema.This is used in particular to put restrictions on the simple types,which is done
with the restriction element to indicate the derived type and thereafter"facets"can be
applied that restrict the values.For instance,a simpleType that derives the string can
among other things,restrict its length and pattern with regular expressions.
2
In mathematics,the cardinality of a set is a measure of the"number of elements of the set".(http:
//en.wikipedia.org/wiki/Cardinality)
4.3.Heterogeneity 23
Elements and attributes must dene a name and a type.The name is simply the name
of the element or attribute and the type species the type,which for an attribute the type
must be a simple type.For both elements and attributes occurrence constraints can be
enforced.For attributes,the attribute that species this is called use.It allows 3 dierent
values,required,optional or prohibited,all of which are self-explanatory.The default
value of use is optional.To specify occurrences for elements one uses the maxOccurs and/or
minOccurs.The values can be set to an arbitrary positive integer,or for maxOccurs it can
also be set to unbounded to indicate that there is no upper bound.The default values for
both is 1[47].
The example in Listing 4.7 shows what an XSDcould look using some of these denitions.
Listing 4.7:XSD example
<?xml version="1.0"encoding="ISO88591"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="stringtype">
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType name="orderidtype">
<xs:restriction base="xs:string">
<xs:pattern value="[09]f6g"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="shiptotype">
<xs:sequence>
<xs:element name="name"type="stringtype"/>
<xs:element name="address"type="stringtype"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="shipordertype">
<xs:sequence>
<xs:element name="orderperson"type="stringtype"/>
<xs:element name="shipto"type="shiptotype"/>
</xs:sequence>
<xs:attribute name="orderid"type="orderidtype"use="required"/>
</xs:complexType>
<xs:element name="shiporder"type="shipordertype"/>
</xs:schema>
4.3 Heterogeneity
This section describes the problems and solutions available for dealing with heterogeneity
and data integration.It also concludes with comparison of approaches to solving these
problems in terms of XML data integration.
24 Chapter 4.Data transformation and integration with XML
4.3.1 Problem description
In a standard scenario where remote data is needed by an application the data is contained
at a single source,e.g.a database.And in those cases querying only requires one request
and the data is returned.In other cases,however,the necessary data is located over multiple
sources.There are times when it is necessary to provide a single view over such a set of
dierent data sources.Otherwise the user would perhaps have to consider all available
sources,query each of them,or maybe select the ones that need to queried.This would be a
long,tedious,complicated and error prone process.To achieve a single view data integration
is needed to combine the data from the dierent sources.
Problems arise when one needs to integrate a number of heterogeneous data sources
into one homogeneous view.In terms of dealing with only XML sources heterogeneity
is also a large problem,because XML sources are highly heterogeneous in many aspects,
most often these aspects are classied as two dierent types of heterogeneity[55].First tag
heterogeneity which means there may be vocabulary discrepancies used in the element tags.
Meaning that two elements containing the same information may be labeled with dierent
names (e.g.book and novel).The next heterogeneity is structural heterogeneity which
explains the heterogeneity that occur when documents which contain the same information
are of dierent structures.
4.3.2 Approaches
Based on the description of the problem in the previous section it is clear that at times
providing some software means for unied access to that data in such a manner as if they
had a single logical and physical representation is needed.There are generally two basic
approaches used[52] when dealing with heterogeneous data sources and data integration,
they are materialized integration and virtual integration[53].
Data integration systems are usually characterised by an architecture based on a global
schema,which provides an integrated view of the underlying sources.
Materialized Integration
Materialized integration essentially means storing data in a database and then querying it.
A well-known example of materialized integration is data warehousing.In this approach
the data that needs to be integrated is transformed into the target model and persisted
in the warehouse database periodically by a program.One advantage provided by this
approach is the performance of processing a query[60].It often utilize the ETL process (i.e.,
extraction,transformation,and loading).This involves extracting data from the various
sources,transforming it and nally loading it into the target,e.g.a data warehouse.An
overview of this process can be seen in Figure 4.1
Virtual Integration
In the virtual integration paradigm the data from various sources is not persisted into a
single model.Instead users query a mediate schema which is only used for querying data.
When a query is issued to the system,it translates the query into sub-queries at runtime
to the separate underlying data sources and the results of which are combined by the data
integration system.Wrappers possibly have to be created,in case of the sources result in
dierent formats,to transform the result into a format the integration system can process.
4.3.Heterogeneity 25
Figure 4.1:An overview of the ETL process.
These wrappers are programs created for this purpose.An overview of this process can be
seen in Figure 4.2
Figure 4.2:An overview of the virtulized integration paradigm.
There are two approaches often used in terms of virtual integration to describe the
mappings between the global schema and the sources.They are Global-as-view (GAV) and
Local-as-view (LAV).
GAV consists of the mediate schema which is dened as a set of views over the underlying
sources.When sources are added or a source changes its structure the view needs to be
adapted to handle the new mappings[58],which means that it is not very exible.On
the other hand it is simple to reform the queries to the underlying sources[58][59].Simply
speaking,the global view maps to the local views.
In local-as-view,the approach is the opposite,sources are dened as views over the medi-
ate schema.This requires that for each source a viewover the global schema is associated[63].
26 Chapter 4.Data transformation and integration with XML
When there is a change in an underlying sources or a new source is added,only local
views that describes the sources in terms of the global schema needs to be adjusted or,in
the case of a new source,a local view needs to be provided[58].This means that it is also
easy for a source to leave the system.
This means that the sources are independent from the mediated schema which could
invite additional sources provided that they provide a description of their local relations
in terms of the global relation,in the case where there is an open system for sources to
join[62].It is however dicult to map the query,applied to the mediate schema,to the
dierent sources[53],which is often a NP-complete problem[61].
4.3.3 Conclusion
Materialized integration is suited for situations when fast evaluation of complex queries is
required[53].But it is not always convenient or possible to replicate and persist all data
from a set of sources.In some cases materialization is impossible,for instance because of
the size of the data.Because of that,as virtual integration has matured,it has become
increasingly popular over the years[53].In virtual integration a large performance penalty
is paid because each source has to be contacted for every query that is issued to the system
query[60].
The need of keeping the queries to publishers low,as stated in Section 4.1,the best
solution would be to persist the data from the publishers into a database.Therefore,based
on a scenario where there is high load integration system,virtual integration is not preferred,
as it queries a collection of dierent publishers (XML sources) for every query it is issued.As
the data also needs to be persisted for future viewing,as stated in Section 1.2,materialization
is also the preferred choice.That combined with the need for fast replies,as specied in the
goals section,makes materialized integration the more suitable choice compared to virtual
integration,as virtual integration needs to query multiple sources while materialized only
needs to query one source which results in faster response time for materialized integration.
If,however,all remote sources are available on the LAN of the virtual integration,the
dierence in performance will be less[57][56].
4.3.4 Transformation with XML
The problem discussed in this study is a more primitive real world problem than those often
discussed in the academic world,as it is only concerned with data in the form of XML
sources with an already known target schema (which data from the sources that are needed
is already known).The previous section ended with motivating the reason why materialized
integration is the preferred approach for the problem discussed here.Two solutions that
can be used for materialized integration when dening wrappers or mappings for XML
sources[53],which are discussed in this section,are xQuery and XSLT.Both xQuery and
XSLT are described in Section 4.2.
They will be compared against each other based on the ease of use and performance.
The ease of use is important since wrappers need to be created for each additional source
that needs to be integrated.
Comparison of xQuery and XSLT
As previously stated in the overview,xQuery and XSLT were designed with dierent pur-
poses in mind.The former was designed with the purpose of being a query language for
large collections of data,while XSLT was designed for the purpose of transforming XML
4.3.Heterogeneity 27
into other documents.In spite of that,some of their capabilities overlap,for instance is
xQuery also capable of transforming XML documents.
xQuery 1.0 and XSLT 2.0 have been developed by two working groups (the XSL and
xQuery working groups) in close collaboration and their similarities are many;they are
both declarative languages,they are both based on xPath 2.0 and more[65].They can both
take input and generate output in XML format,they handle documents with no schema
and those that have been validated against schemas.As they both share the xPath subset,
expressions can be written in the same way in both languages.They also share the same
library of built in functions.Since they are so similar this means that once one have mas-
tered one of the language it is easy to transition to the other[65].
There are,however times,when one technology is a better choice than the other[65][66],
as,for instance,some people argue that the other language is easier to learn than the other.
Therefore it is important to know when to choose which.,which will be explored in this
section.The two language have more similarities than dierences which is why this choice is
hard to make.At the same time when the similarities are this strong the choice one makes
will make less of a dierence[65].
The biggest dierence between the two could be that XSLT is an XML document while
xQuery is not.Since XSLT is XML all XML technologies can be used when writing a
stylesheet.
xQuery has the FLWOR (FOR-LET-WHERE-SORT BY-RETURN) expression func-
tionality which is not available in XSLT.However,almost all FLWOR expressions can be
rewritten into XSLT constructs[65].
XSLT on the other hand have the template rules for which there are no corresponding
functionality of in xQuery[65].The benet of using template rules is that it makes it more
independent from the structure of the input documents,as it only describes what should be
done with a specic element,not where the element is found.Template rules are dicult
to optimise for an optimiser because of the exibility of the rules since it is dicult for an
optimiser to know the circumstances under which the rules will be activated.When dealing
with large documents optimisation is very important,therefore when working with large
volumes of data xQuery is preferred[64][65].XSLT also includes functionality to format
numbers,dates and times.This shows that XSLT is well suited when the generated data
needs to be consumed by a human reader,where xQuery has no corresponding functionality.
This means that when the data needs to be read by a human,XSLT could be the better
choice[65].
There are also many more dierences between XSLT and xQuery that are outside of
the scope of this comparison,mostly they refer to extra functionality available in the XSLT
language compared to the functionality in xQuery.
User experience XSLT is verbose because of the fact that it uses XML syntax.This
seems to be one factor to which why some users might be hesitant of using XSLT[65][64].
xQuery is more compact,not as verbose as XSLT,and could therefore be argued to be easier
to grasp in that aspect.At the same time XSLT advocates claim that XSLT contain many
convenient features that are not available in xQuery[64].
Users'experience have a large in uence on how dicult it is to use either language.
Studies have shown that xQuery is easier to learn than XSLT for people with experience
using SQL[64][65].While learning XSLTis said to be easier for users with a background using
non-functional programming languages[64].The more overall experience of programming
28 Chapter 4.Data transformation and integration with XML
the user has tends to simplify the learning of both XSLT and xQuery[64].In this case
of people without any experience,xQuery still tend to be easier to learn.This can be
attributed to fact that xQuery is a language with fewer concepts than XSLT[65].
People also nd that writing transformations in a declarative manner in XSLT,which is
a non-procedural language,is more dicult than writing them in the form of a procedural
algorithm.Some people also nd it dicult to use the rule-based programming that is used
in XSLT[65][64].Some developers might also have diculty grasping the recursive nature
of XSLT[67].XSLT has worked to address these problems,because now complex logic is
more easy to describe in XSLT 2.0 than in XSLT 1.0,through added functionality to XSLT
2.0[65][66].
A study carried out by J.P.M.Graaumans in [64] show that the more verbose the
language is,the longer the queries tend to be which can lead to that more complex queries
are much more dicult to solve in a verbose language[64].While on small queries they
present the same level of diculty[64].In the same study,with a dierent test group,this
hypothesis was also dis-proven.This can be attributed to the fact that there were two
test groups that had dierent backgrounds and level of experience and therefore dierent
problems were created for the dierent test groups.In the same report it was shown that it
were easier for subjects solving the tasks of the experiment using xQuery than with XSLT,
while also showing that tasks were also performed in less time using xQuery.Users were
also more satised using xQuery than with XSLT,based on the test subjects'answers in
a questionnaire.It went on to show that more programming experience is needed to work
with XSLT,meaning that it is harder to learn and use.The more characters needed to write
the query result in the query taking longer time to create.Since XSLT is more verbose this
can be one reason why solving tasks with XSLT took more time[64].
Discussion
It is not possible to compare the XSLT and xQuery technologies using performance bench-
marks as they are dependant upon the specic implementation of the (XSLT or xQuery)
processor,and are therefore not included.The performance dierence between XSLT and
xQuery would most likely not end in a clear win for either.It would more likely depend
upon the products rather than the languages[65].
The argument as to which of these two languages is the better one have lead to erce
debates in user communities.Arguing,for instance,over aspects of the syntaxes of the
languages.Research regarding the in uence of the dierent syntaxes are however almost
non-existing[64].The one case where xQuery probably would win is when working with
large XML databases where optimisations are absolutely essential[65].
A common argument in these discussions is that XSLT is dicult to use because of
the verboseness of the language.And that XQuery is argued to be more suitable for users
with a database background because of the compact syntax that is partly based on popular
database query languages.However the claim that XSLT stylesheets are always longer than
the equivalent in xQuery is not always true[65].
In cases where memory consumption truly matters,transforming XML in a streaming
manner could be advantageous in certain conditions.A streaming transformation program
is however more dicult to construct[54].However,work on XSLT 3.0 includes streaming
capabilities.XST does not however have access to the entire document structure when
transforming,which could be very disadvantageous when doing transformations.
The choice is often done on a less objective criteria and instead on personal preference
based on how much one likes the syntax of the language and one's previous experience[65]
4.4.Parser 29
with similar languages[66].It also depends on the quality of the available tools[53],because
in most cases both language can be used to achieve the same result[66].However,XSLT is
currently the primary choice for transforming data while xQuery is becoming the standard
for querying and updating XML databases[53].
4.4 Parser
There is a variety of XML parsers available,all of which have their strengths and weaknesses
and are suited for dierent problems.In this section the more common parsers are presented,
the section ends with a conclusion and summary of the results found.The main purpose is
to nd a parsing technique that does not require high memory consumption as the sizes of
the XML documents are of arbitrary size which means they can be very large and it also
needs to be fast since otherwise the parsing can easily become a bottleneck for the module.
DOM
DOMstands for Document Object Model and is a tree-based parser.It parses an entire XML
document and loads it into memory,modelling it as a tree object,with nodes containing
element name,attributes parent-child-sibling relationship and so on,for easy node traversal.
DOMparsers are slow and consume a lot memory if it loads an XML document that contains
large amounts of data.Using DOM does on the other hand give one very easy access to
manipulating the document because it is in memory.It is possible to read and navigate to
any node in the tree and also perform CRUD operations.
SAX
SAX (Simple API for XML) parsers work dierently from a DOM parser.It does not load
the XML document into memory nor does it create an object representation of the XML
document.Instead,the SAX parser uses events and pushes information of the XML to the
event handlers.This is known as a push architecture.As it does not load the document
into memory it is very memory ecient.
STaX
STaX,the Streaming API for XML,is based on a pull architecture which means that,
instead of as in SAX where events are generated when new tags are encountered,one must
pull the next tag manually.STaX is also a memory ecient approach when dealing with
large documents as the entire document does not have to be held in memory.
4.4.1 Conclusion
As far as speed is concerned,SAX and STaX are the preferred approaches because of the
improved speed performance[68][72].This is because both SAX and STaX can immediately
access data as soon as the parsing has begun,while DOM on the other hand has to build
the entire tree structure before data can be accessed.The memory consumption is much
lower[68] compared to a DOM parser which could run out of memory[69][70] as it loads
the entire document into memory,which makes SAX and STaX the better choices when
there is a need to keep the memory consumption low.When there is a need for easy and
random access to the documents structure and content and back-and-forth traversal,DOM
is preferred[68][70],as neither SAX or StAX can navigate the document nor do they have
30 Chapter 4.Data transformation and integration with XML
randomaccess to the document[70].If there is a need to alter the XML structure DOMis the
correct approach as,again,neither SAX nor StAX can modify the document in place[70][71].
That is however only parsing technologies.There are also various dierent implementa-
tions of parsers which,obviously,also aect the performance.They should also be bench-
marked to nd the best performing one.That is left as future work.
4.5 Summary and discussion
This study found that based on the properties described in Section 4.1.The best use for
data integration would be materialized integration.This is because that will most likely
decrease the number of queries to the data publishers if there is a large number of users
querying the data.It would also be faster performing than using virtual integration because
it only needs to query one source,compared to virtual integration which needs to query all
underlying sources.
The choice for the XML transformation technology does not seem to matter to a high
degree,as xQuery and XSLT are very similar.It might however be harder to learn and
utilize XSLT.Therefore,the best solution would be to enable the system to handle both
xQuery and XSLT as wrappers,and allowing the developer of the wrapper to make his or
hers preferred choice.
Internally,XML should be parsed using SAX or StAX to keep the memory usage as low
as possible,as there is no need for the systemto have randomaccess to the entire document.
As future work,benchmarks should be explored to correctly choose the best xQuery
and XSLT processors.And also benchmarks should be investigated for comparing SAX and
StAX for nding the best performing one.
Chapter 5
Framework
This chapter goes over the developed framework and the dierent solutions for the modules
as described in Section 1.2.The main focus being on social networking and a module for
aggregating data (which are events,i.e.events that occur during live events,such as a
penalty shot during a football game) from various data providers.A user should be able
to respond to these events,guessing the outcome of the event.This data should be stored
in a back-end.Section 5.1 species additional goals for the framework,while the following
sections describe the dierent modules.The chapter concludes with a discussion of the
developed framework.
5.1 Goals
Aside from the goals described for the framework in Section 1.2,additional goals needed to
be achieved for the framework which are described below.
{ The framework should not include any dependencies that disable the user (a developer)
of the framework to publish the application for commercial use.This means that if
third party libraries are used within the framework they must be under permissive
licenses such as,for instance,the BSD license.
{ The framework should be available to as many platforms as possible.As described in
Section 3.2 the dierent Smart TV platforms utilise dierent languages for creating
applications.Therefore it is important to try and make the framework cross-platform,
so that it could be used when developing for all dierent platforms.This is not
completely possible but some parts can be broken out and instead create a web service
for them.That way it is completely independent upon implementation language of
the application,and can it instead be accessed through network calls.
{ When using the framework no new code should have to be written in the framework.
(For example when adding a new XML source to the aggregator.)
{ The aggregator should be able to integrate multiple XML sources into a single view.
This will enable a developer to query the aggregetor as though it is one source,when
it is in fact an arbitrary number.
{ It should be easy to add additional event publishers to the aggregator.This should
be done without having to change or write any additional code to the aggregator.
31
32 Chapter 5.Framework
{ It should be easy to change the underlying database of the back-end as it is not certain
on which database is will be deployed.
5.2 Design
Even though the prototype will only run on the Google TV the goal is,as previously stated,
to have a framework that is platform independent.As the televisions need to be online
to be able to communicate the interactions given by the end-user one can assume that the
end-user is online when using the framework.Therefore the use of a web service will enable
all devices that have an Internet connection to communicate with the back-end that will
store user interactions and events.The framework will then consist of specic modules
for communication with the web service,social networking modules,a separate aggregator
service that will aggregate events,and nally a back-end for storing user interactions and
the events.Even though it will contain a separate service,a web service and a back-end
aside from the other framework modules,the term framework will be continued to be used.
5.2.1 Communication
The web service will use the REST (Representational state transfer) architecture.REST is
a set of methods that enable one to create,read,update and delete (CRUD) data on the
web service.All of these methods are accessed over HTTP.
To transfer data to and from the web service JSON (JavaScript Object Notation) will
be used.JSON is a lightweight,easy to read to read for humans,text based language often
used to serialise and transmit data between a web service and application.
5.2.2 Back-end and web service
To achieve the goal of having a back-end implementation independent from the underlying
database vendor,there are many approaches.The solution for this project was to use Ruby
on Rails (RoR).Using Ruby on Rails a web service was also created for communicating
with the underlying back-end.Ruby on Rails utilises the model-view-controller pattern and
it includes scaolding tools to easily generate models,views and controllers.Since it can
also generate views for the models it can give an interface for manipulating and viewing
the data in the database.These views could later be extended further,allowing users to
log in and compare their results,view high-scores based on users'results and perhaps add
achievements.The models are very easy to persist to the database.This all enables one to
very easily create a fully functional web service that can easily persist data.
Modications of the underlying database is done with"migrations"which are written
in a database independent way.RoR then translates this code to code the specic database
in use understands.The models one create are mapped to the underlying database.RoR
handle all of the O/Rmapping (object-relational mapping) and in doing so one does not have
to write queries to access that data.That said,through the use of migrations and mappings
RoR keeps the developer separated fromthe underlying database and if the database vendor
needs to be changed that can be easily done without almost any code changes.
5.3.Social Networks 33
5.3 Social Networks
This section describes the social networks that have been incorporated into the framework.
Both in terms of how they were added as modules in the framework as well as what services
they provide to enable third-party developers to include their service in an application.The
selected social networks to include in the framework were Facebook and Twitter,mainly
because of their popularity.
Twitter
To access the Twitter API it requires you to register your application with Twitter through
their website with a Twitter Developer account,which can be created by anybody.Twitter