CHAPTER

9

The Future of Web Applications

Chapter Objectives

• Discuss technologies that may replace Ajax, like XForms

• Discuss the future of the web and web applications: Semantic Web, Web 3.0.

• Discuss web structuring

9.1 Overview

 

People like to use terms Web 1.0, Web 2.0, and Web 3.0 as milestones in web technology evolution. More precisely, it is just an evolutionary path for the Web in the following phases (http://en.wikipedia.org/wiki/Web_3):

Web 1.0: Web Browser driven “Interactive Web of Hypertext” pages where presentation, logic, and data are indistinguishable

Web 2.0: Web Services based API driven “Web of Services” that separate “Application Logic” from the intermingled presentation, logic, and data pages of Web 1.0. Examples of Web 2.0 application profiles include: blogs, wikis, the use of Ajax to improve web application interaction richness, and mashups. Web 2.0 does not explicitly expose Data Models.

Web 3.0: The final step in the decomposition of monolithic Web Pages into discrete components that include the Presentation (HTML and (X)HTML), Logic (Web Services APIs), and Data (Data Models) trinity, it transitions Web containment from Web Pages to Web Data. Its emergence simplifies the development and deployment of Data Model driven composite applications that provide easy, transparent and organized access to “the world's data, information, and knowledge.”

Looking back at the evolution of web technology from HTTP Form to XForms, from syntactic web to semantic web, we see that how to model, structure, and organize web data has always been a key issue.

Web 3.0 links and merges all information on the Web as a global database. In Web 3.0, the Web will be organized into a well-linked database, making content accessible by nonbrowser computer applications instead of browsers only, adding artificial intelligence to Semantic Web. In previous chapters we discussed the XmlHttpRequest and Ajax in detail. In this chapter we will introduce Semantic Web. The future of the Web is semantic. Before we discuss the Semantic Web, you should know about XML Forms Language (XForms), which offers a new way to look at a form where content, structure, and presentation are completely decoupled.

9.2 XForms

 

XForms is the next generation of web HTML forms (XHTML 2.0) recommended by the W3C in 2003. XForms is an improvement and enhancement of HTML. XForms uses XML to create input forms on the Web. Traditional XHTML forms consists of three parts—XForms model, instance data, and user interface—like a model-view-controller model that separates presentation from data and business logic. XForms make XForms device independent such that many mobile devices can be used as XForms’ user interface for presentation. Data is stored in XML documents. Adding XForms elements to any other XML application is easy. Separation of presentation and data also increases form reusability. XForms itself has the functionality of form validations. XForms has significantly reduced the need for scripting event handlers. In summary, XForms provides a powerful, fast, more secure, and device-independent way of handling web input. For example, strongly typed submitted data in XForms can be checked on site without round trips to the server for validation. XForms will be adopted by all major browsers. XForms can now be integrated into many other languages in addition to XHTML.

9.2.1 XForms Example

Now let us design a simple instance of XForms and see how it works.

The layout of this page is given next. With this form, a student can submit an information request based on the major and degree program level.

images

It is clear that the form is collecting a value that represents a student. You can see the student instance data in the following model element.

images

images

xf: is a namespace of http://www.w3.org/2002/xforms, which provides all elements of the XForms specification. The xf: namespace can be used as a prefix for all XForms in the preceding XForms. Instead of xf: you can select any prefix name you want.

9.2.1.1 XForms Data Model

The data model in the <xf:model> element declared in the HTML <head/> section collects information of degree types and major. The XForm user interface in the user interface section binds to the model section by using the ref attribute. The XForm model uses an instance element to define the XML template for data to be collected by the user interface. The <MyData> element is the root for the XML data in the <instance> tag. The XForms model element is completely independent from its presentation (user interface).

In this example, XForms collects the data in XML format from input like the following:

images

The submission element of the data model describes how the XForm submits the data. In the preceding example, the id=“form1” attribute identifies the form, the action=“myXForm.jsp” attribute defines the URL where the form is processed, and the method=“get” attribute defines the method type so that server knows how to respond to it.

9.2.1.2 XForms User Interface

The XForms user interface displays the data input collected by the model element of XForms. It focuses on the look and feel of the form. The user interface elements in XForms are called input controls. They are defined in the same way as ordinary HTML controls except that they refer to data items defined in the model element.

The <select1 ref=“/MyData/MyLevel” > tag associates the select1 control with collected MyLevel data, and <input ref=“/MyData/MyMojor”> associates the text input box with the collected MyMajor data in the model element. The <submit> element has a submission=“form1” attribute that points to the <submission> element in the XForms model.

An XForms processor built into the browser will be responsible for submitting the XForms data to a target. The data can be submitted as an XML document:

images

Or it can be submitted as text as follows:

images

XForms’ XML data definition, XHTML data display, and separation of the data from its presentation allow it to adapt to all devices. The mobile phones and handheld devices such as iPhones, iPods, and cell phones all have different interface requirements, but you can use the same data model to fit all these requirements. Reuse of the same data model for all devices is one of the important advantages of XForms over HTML forms. Also, XForms enables multiple submit buttons to act on the same data model with different purposes versus just one submit button in HTML forms.

XForms has many other advanced features over HTML. For example, new data can be requested and used to update on the fly just like XmlHttpRequest/Ajax.

In summary, the advanced features of XForms are the following:

• Enhanced application accessibility because of its generic user interface. XForms works equally well with accessible technologies.

• Usability of XML-based submission. It can load XML and submit XML data. XForms is integrated with XML technologies. It can reuse existing XML schema.

• Device adaptability of supporting multiple devices because of the separation of model and interface. The same form without change can fit a traditional browser, a PDA, a mobile phone, or any other device. A form needs to be written only once for many clients.

• Writing forms is easy because of the declarative markup declaration of properties of values and relationships between values. Using available XML parsing and handling packages is also easy.

XForms is the next generation of web form applications. Almost all web applications have web forms, so it will have a huge effect for future web deployment.

9.3 Semantic Web

 

9.3.1 Overview

Semantic Web is the next generation of the web as recommended by the W3C consortium in 2001. The Semantic Web is a web of computer-proces-sible data that is an extension of the current World Wide Web. The data in the current Web is structured in a way for browsers to access or for search engines to find rather than being organized in predesigned semantic formats so that application programs can understand, retrieve, and process the data automatically and effectively. Tim Berners-Lee, a pioneer of Semantic Web, pointed out that the Semantic Web is the solution to information overload and the personalization of the Web by adding logic to the Web and turning it into a global database. Because of the lack of semantic connection between data on the Web, we often need to search many websites to get an answer and you may face a high fault hit rate. For example, some Georgia Tech (GaTech) students want to take some transient classes at Southern Polytechnic State University (SPSU) in the summer so that they can transfer these credits back to GaTech. (GaTech does not offer these courses in the summer.) These students must access the GaTech website first to find the eligible transferable course at SPSU and then go to the SPSU website to find the course description and schedule information and then go back to the GaTech website to make the request again online. The process is time consuming and would be made even worse if the students could not get the information that they needed because of a huge number of search results with a high fault hit rate. All these problems are caused by a lack of semantics on the Web, which focuses only on the interchange of documents. Semantic Web also provides ontology metadata that shows body-of-knowledge concepts. With Semantic Web, you may build up a domain-specific semantic web. Each domain-specific Semantic Web has its metadata associated with a URI and its ontology (i.e., metadata of relationships between data, taxonomies, or mapping relationship) so that it becomes a part of the global database on the Web. You can effectively use a smart domain-specific search engine to find only useful information instead of so much irrelevant data returned by a regular search engine on the original Web. A Semantic Web search engine is much smarter than current search engines because it can use ontology knowledge and rules to deduce the conclusion on the basis of Semantic Web principles.

Software for Semantic We b will be able to find, understand, and use all relevant data in context in a smart way. A good example of Semantic Web is Wikipedia, the world's largest online collaboratively edited resource of encyclopedic knowledge. The goals of Semantic Web are

1. To provide and support common unified formats for integration and combination of data from diverse sources in various locations and various formats on the Web.

2. To record the relationship between different sets of data and describe how they relate to real-world objects.

It allows machines to search the data starting off at one website and then follows semantic ontology relationship connections to traverse all necessary links to reach all data in a semantic query. Semantic ontology is like bridges spanning over many web-related websites. For example, one can make a “semantic link” between a database or home page with a “mammal” identifier, and the other identifier could be“carnivore” with its properties. The relationship between carnivore and mammal is an “is a” relationship, also called a subclass relationship: carnivore is a subclass of mammal and it encompasses all properties that a mammal has. This approach allows machines to follow links to integrate data from many various sources automatically.

Semantic Web moves from a human-oriented, document-based web to a machine-oriented, information-linked web; it moves from a data-oriented web to a semantic-oriented web with meaningful metadata built on top of the original Web. This Semantic Web provides not only documents but also a common framework that allows data to be shared, reused, and processed by application agents automatically. It also provides a global integrated ontology-oriented database that merges all related databases together on the Web.

9.3.2 Structure of Semantic Web

Semantic Web maps various resources on the Web onto a syntax representation so that the underlying web data is independent from its representation. As shown in the following hierarchical layered structure, Figure 9.3.1, all data resources at the bottom level have their unique identification with a URI. W3C recommendations in 2004 for following foundation specifications include Resource Description Framework (RDF), RDF Schema (RDFS), Web Ontology Language (OWL), Query (SPARQL), and Semantic Web Rule Language (SWRL).

images

Figure 9.3.1

Semantic Web Hierarchies

The basic syntax representation is in a subject, predicate, object (SPO) sentence statement that is noted by Resource Description Language (RDF)/ XML. Many additional constraints and properties of statements are described by RDFS, which is an extension of RDF. RDFS describes groups of resources, attributes of the resources, and relationships between resources. XML-based RDF and RDFS together provide shareable and reusable syntactic interoperability for upper-level semantic parsing and analysis. An ontology-common vocabulary for a specific domain can be built up by the OWL framework, which provides semantic interoperability for Semantic Web applications. It describes domain data model by class, subclass, property, class operation, etc.

OWL makes logical reasoning and deduction on this web semantic ontology possible by means of SWRL and SPARQL.

9.3.3 RDF

Recommended by the W3C, RDF is an XML-based framework for modeling, representing, and integrating data resources on the Web. Each resource is described in terms of pairs of properties and its values in triple RDF statement formats. A URI identifies each triple element. The purpose of a URI is to uniquely identify a concept in the form of subject, predicate, or object by linking to the origin where the concept is defined. RDF provides an infrastructure for linking distributed metadata.

A Uniform Resource Locator (URL) is a typical URI that describes the resource access mechanism including the protocol type (http:, ftp:, mail:,…) and access address. Every web page has its globally unique URL. An email address is also a URL. A Uniform Resource Name (URN) is also a URI that specifies a unique resource in a certain domain space. For example, an automobile vehicle identification number, a book ISBN, and a student ID number within the school domain namespace are all examples of URIs. Any data item including subject item, predicate item, object item, class, and property needs to have a URI (but an object item in a triple SPO statement may have its literal value).

images

Figure 5.3.2

Single Triple Statement Graph

images

Figure 9.3.3

Simple Triple Pattern Graph

Figure 9.3.2 shows the SPO description statement graph notation where the predicate is presented as an arrow link from the subject to the object in the sentence.

Nodes with identical URIs are considered identical, so it is easy to merge the nodes in the RDF graph where the node represents a resource and the edge represents the property of the resource. RDF encodes information in sets of triples, each triple being rather like the subject, verb, and object of a simple sentence.

A URI is used to identify not only the subject of the original statement but also the predicate and object. An object in RDF statements may be either a URI or literal values such as character strings to represent certain kinds of property values. Literals may not be used as subjects or predicates in RDF statements.

In RDF, the English statement “Carnivore eats meat” is a description statement. In this statement the subject is #carnivore; the predicate is #eats; and the object is the phrase “meat.” Prefix # is a reference that points to its URI.

"Carnivore is a mammal” is another description statement describing the relationship between the carnivore class and the mammal class. The subject is #carnivore; the predicate is the “is_a” relationship defined as subClassOf; and the object is #mammal. Figure 9.3.3 shows the RDF triple statements in the graph.

A Semantic Web is a web whose resource nodes are linked by many related triples. The subject of one triple statement can be the object of another triple and the subject of many other triple statements. The arrow link in the diagram represents a predicate or property, which can also point to other resource nodes in this RDF graph. An object of a triple can be a resource (oval) or a terminal literal string (rectangle). Semantic Web is a web of all related resources where each resource represents an abstract concept, a web page, a message, an image, or any related information.

images

Figure 9.3.4

RDF Triple-Linked Semantic Web

Next, let us look at the commonly used RDF attributes for the description of a resource.

Attribute Description
rdf:RDF The root of an RDF document
rdf:about Defines the resource being described
rdf:description Container for the description of a resource
rdf:resource Defines a resource to identify a property
rdf:datatype Defines the data type of an element
rdf:ID Defines the ID of an element

For example, the following RDF document could describe the resource http://www.spsu.edu/Ajax-book, where “Ajax-book” is a resource or subject that has a property of “author” with its value of Kai Qian and second property “homepage” with a value of http://www.jbpub.com.

images

Namespaces are omitted in this simplified RDF document.

The namespace in RDF is the same as in XML and .NET and packages in Java that specifies the domain scope of an entity. It is widely used in RDF. For example, the RDF namespace (xmlns:rdf) is http://www.w3.org/1999/ 02/22-rdf-syntax-ns#; the RDFS namespace (xmlns:rdfs) is http://www.w3.org/2000/01/rdf-schema#. You can use the rdf and rdfs prefixes to refer to these two namespaces, respectively.

Here is an RDF document about a Java book with namespace added:

images

The first line declares that this RDF document is XML based. The root element of RDF documents is <rdf:RDF>.The xmlns:rdf namespace declares that elements with the rdf prefix are from the namespace http://www.w3.org/1999/02/22-rdf-syntax-ns#. The xmlns:book namespace declares that elements with the book prefix are from the namespace http://www.virtual.com/book#. The <rdf:Description> element contains the description of the resource identified by the rdf:about attribute. The elements <book:author>, <book:price>, and <book:year> are properties of the resource; they are defined in the http://www.fake.virtual/book# namespace. This namespace is outside RDF (and not a part of RDF built-in namespaces). All the preceding properties are considered attributes. Some property may have its resource; for example, detailed author information is described in <book:author rdf:resource=“http://www.anotherfake.com/kq” />. You can also replace <book:author>Kai Qian</book:author> with

images

to show that there is a list of coauthors with RDF container element <rdf:Bag>.

RDF is a general model for defining triples with machine-readable formats (RDF/XML, Turtle, N3). In RDF triples, names of subject, predicate, and object are all represented by URIs, but the object may be a literal. The predicate connects or relates the subject and object as follows, and all RDF statements are linked to make a meaningful domain (sometimes called vocabulary).

RDF makes web information understandable by RDF's parsers rather than only for web information display purposes. RDF/XML uses a URI to link related information across the Web. Some URIs are real and can refer to retrievable web info on the Web, whereas other URIs are virtual and can refer only to an entity or a concept object. So RDF/XML describes not only web pages but also all kinds of objects and entities. RDF properties also have URIs to identify the relationships between the linked items. In short, RDF is designed to provide a simple way to make statements about web resources, e.g., web pages.

Here is a simple example of RDF/XML for the carnivore statement.

images

Line 1: <?xml version=“1.0”?> is the XML declaration indicating that the following content is XML 1.0 compliant.

Line 2: the rdf:RDF element indicates that the following XML content (starting here and ending with </rdf:RDF> in line 10) is intended to represent RDF. Following the rdf:RDF on this same line is an XML namespace declaration, represented as an xmlns attribute of the rdf:RDF start tag. It specifies that all tags in this content prefixed with rdf: are part of the namespace identified by the RDF site.

Line 4 specifies another XML namespace declaration, this time for the prefix animal:.

Lines 1-4 are general “housekeeping” necessary to indicate that this is RDF/XML content and to identify the namespaces being used within the RDF/XML content.

Lines 5-9 provide the RDF/XML for the given statements.

The rdf:Description start tag in line 5 indicates the start of a description of a resource. The property element is nested within the containing rdf:Description element, indicating that this property applies to the resource specified in the rdf:about attribute of the rdf:Description element.

Line 6 specifies that the resource carnivore has its homepage at http://…/~carnivore. The property is hasHomePage and value is http://…/~carnivore.

In Line 7 the value of the eats property defined in the animal namespace (the object of the statement) is the plain literal “meat” (the value of the gives and eats property of the subject resource).

Line 8 is an RDFS property that specifies that carnivore is a subclass of the mammal class, which is defined in the animal namespace.

Now look at a simple RDF definition about this Ajax book.

images

Here the description, about, and resource are specified in the rdf namespace. The subject (resource) is an “Ajax-book”, which comes with its URI. Here are two properties associated with this subject: “authorName” is Kai and “AuthorCV” is available at http://cse.spsu.edu/kqian, or you can say that “Ajax-book authorname” is kai and “Ajax-book authorCV” is at http://cse.spsu.edu/kqian.

The recommended extension for RDF files is .rdf. However, the extension .xml is often used instead to provide compatibility with older XML parsers.

9.3.4 RDF Schema (RDFS) and Application Classes

RDF describes resources by using classes, properties, and values. Simply, RDF Schema (RDFS) extends RDF and provides additional useful elements: class and property. RDFS provides extra knowledge on RDF and it is used to define application-oriented classes and properties. Application-oriented classes and properties must be defined by extensions to RDF, that is, RDFS. RDFS provides the framework to describe application-specific classes and properties. For example, just as in object-oriented programming, classes in RDFS can be a subclass of another class by inheritance. RDF resources can be instances of classes or subclasses of other classes.

In RDFS, rdfs:Resource and rdfs:Class are nodes and rdf:type and rdfs:subClassOf are properties connecting the subject node (the owner of property) and object node (property value). Rdf:type defines the membership; i.e., an individual belongs to a specific class. The individual may be a literal or an instance. subClassOf describes the relationships between two classes, where one instance or individual in the subclass is also the instance or individual in the superclass. These new RDFS built-in elements extend the RDF framework.

In RDFS, a property itself is a class that may have its subproperty; a property may have rdfs:domain to restrict its domain of the subject (owners of this property) and rdfs:range to restrict the range of objects (or possible property values).

In (P rdfs:domain d) P is a property, d is a class instance, and the subject must be an individual in the class of d when property P is used.

In (P rdfs:range r) P is a property, r is a class instance, and the object must be an individual in the class of r whenever property P is used.

In the famous animal identification game ontology, you know that carnivore is a mammal and that a tiger is a carnivore.

There are many animals belonging to carnivore; tiger is one type of carnivore. The carnivore should be defined as a class in addition to a resource.

Same with tiger—there are many different type of tigers living in different regions of the world. The tiger is a collection of special tigers from various regions. The tiger is a special kind of carnivore that eats meat and gives milk but it has its own property of black stripes and tawny color.

In a file called animal-world.rdf, you declare that carnivore is a class by the class definition in RDFS standard:

images

On the basis of the mammal class specified in animal-world.rdf, you can declare that the tiger resource is a subclass of the mammal class:

images

From the preceding example, you know the resource “tiger” is also a subclass of the class “mammal”. You declare it as follows:

images

This RDF document defines a mammal class within http://www.animal-world.xyz/mammal# by rdfs:Class element namespace and declares a tiger class, which is a subclass of the mammal class, by rdfs:subclassOf element. You used three namespaces in this document: rdf, rdfs, and base.

RDFS also provides many other rdfs elements: rdfs:domain and rdf:range elements to specify the domain and range of a resource to specify the constraints on the RDF resources.

RDFS supports rdfs:Class, rdfs:Datatype (subclass of the class type), rdfs:Resource (subclass of class), rdfs:Container, and rdfs:Literal (subclass of the resource class).

images

From the preceding RDF graph, you can see that RDFS provides basic elements for the description of ontology. Two important components are in this graph: class and property.

All resources are classes used by other resources.

(#mammal rdf:type rdfs:Class) is a schema triple and (#tiger #eats meat) is a data triple.

(#carnivore rdfs:subClassOf #Animal) is a sample triple for a subclass relationship between two classes and (#tiger rdf:type #carnivore) is a sample triple for an individual membership relationship.

You also see the property constraint with properties of domain and range such as

images

9.3.5 Ontology and Web Ontology Language (OWL)

RDFS is useful. But it does not cover all possible requirements for more complex applications, such as how to validate the equivalence of two concepts defined in different domains, how to construct a new class from existing classes or how to derive a new class from an existing class, how to restrict a specific property, and how to distinguish individuals from classes.

There is a need to have an ontology language on top of RDFS for Semantic Web applications.

Semantic Web Ontology Language (OWL) describes web information resources and relationships between the resources. OWL is a language standard for Semantic Web ontology to meet this need. It became a W3C recommendation in 2004. OWL is designed for ontology constructing, integrating, parsing, processing, and querying linked web information.

The focus of OWL is to provide a common way to process the contents of web information instead of displaying. OWL covers all vocabulary and syntax of RDF and RDFS, and it is much more powerful than these two standards. OWL is written in XML so that OWL information will be compatible with any type of operating system and application language. OWL supports more formal concepts and relationships and provides constraints on properties, as well as a reasoning mechanism. It can also deduce and check logic based on rules such as if A is a kind of B and B is a kind of C, is A a kind of C?

OWL is a standard layer on top of RDFS that introduces its own Class (collection) and Thing (individual) to distinguish classes from individuals.

For example, you declare a “Mammal” class and define an individual in this class called “Tomcat”:

images

Class, individual, and property are the three major components in OWL ontology.

First, the OWL class is an important element in OWL. OWL classes are building blocks in the OWL ontology. OWL can define and create a named class. OWL supports intersection of classes, union of classes, complementary classes, enumerated classes, and restrictions on classes.

By using class intersection, class union, and class complement operations you can construct a new class from existing classes.

OWL class restrictions include class quantifier restrictions (there exists at least one existential restriction and a “for all of” universal restriction), cardinality restrictions (class participation of individuals in a given property), “has value” restrictions (specific individuals in the class), and enumeration classes (explicit list of individuals in the class).

Second, OWL provides two new properties: object property and datatype property.

Object properties connect individuals to individuals and datatype properties connect individuals to a datatype such as integer or string. Each property may have its domain and range. Property domains specify the domain of the subject of the predicate (property), and range restricts the object range for the given property in an RDF triple.

You can associate attributes with a property.

A functional attribute restricts only one value; the property will apply for any individual.

Symmetric attributes specify that the properties apply in both directions, from subject to object and from object to subject as well.

Transitive attributes specify that if a property is applied from X to Y, and from Y to Z, then this property can also apply from X to Z.

Here is a simple OWL ontology example for the animal world.

Three OWL Classes are Animal, Mammal, and Carnivore. It declares that Mammal is a subclass of Animal, Carnivore is a subclass of Mammal, and Carnivore disjoints with Herbivore, defined somewhere else.

images

The following OWL fragment declares that an individual “Tiger” is an individual member of the class “Carnivore,” which has a “Colors” property restriction with value of two, indicating that it has only two colors. The “Color” property is defined in the next section.

images

Next, let us look at the OWL property declarations.

images

You declare a “Colors” object property applied to the “Animal” class, and color value will be a literal word. You then apply owl:Restriction to this “Colors” property with an owl:maxCardinality of 10.

images

In summary, OWL is used by Semantic Web applications to process the contents of Semantic Web information rather than to display the information. You have briefly seen how to use OWL to build Semantic Web ontology in this section. You will see how to query information by using OWL ontology in the next section.

9.3.6 Query Semantic Web with SPARQL Query Language

The RDF Query Language (SPARQL) based on the SPARQL protocol is a query language that provides a tool for web applications to work on RDF ontology. SPARQL allows you to match patterns in an RDF graph by using triple patterns, which are like triples except that they may contain variable placeholders. The variables are used as wildcard characters to match (bind) RDF terms in the dataset. The Semantic Web provides ontology for any web application to retrieve global information or domain-oriented information that the regular search engine cannot because the current Web is not semantic and current search engines do not support the semantic reasoning mechanism.

The OWL SELECT query statement is used to extract data from an RDF graph, returning it as a table of results.

A triple pattern can include variables. Any or all of the subject, predicate, and object values in a triple pattern may be matched by a variable. Variables are used to indicate data items of interest that will be returned by a query.

The next SPARQL query shows a triple pattern with variable ?food in place of the object in a triple pattern if the subject and predicate are known:

images

Because a SPARQL variable can match any value, this pattern will match any RDF resource that has an eats property for the carnivore in the designated namespace. Each triple that matches the pattern will bind an actual value from the RDF dataset to each variable. For example, there is a binding of this pattern to our dataset where the object of “meat” in the stored triple statement is matched and bound to the food variable.

In SPARQL all possible bindings will be found. So if a resource has multiple instances of a given property, then multiple bindings will be found.

The following SPARQL query has multiple variables.

images

Or

images

This pattern matches all triples in an RDF dataset. The names of the variables make no difference.

A few triple patterns can also be combined with algebra operations such as union, optional (join), and filters for restricting values to construct more complex patterns. SPARQL also provides ORDER BY, LIMIT/OFFSET, DISTINCT, and REDUCED solution modifiers to modify the query results. Let us look at the basic structure of our first SPARQL query.

Assume that the RDF dataset about an animal world is as follows (prefix myns is the application namespace for animal ontology):

images

Here are some simple SPARQL query examples:

Q1: Who likes meat?

images

This query returns the results as follows:

images

Q2: Who eats meat?

images

will also return the same result as before.

Q3: What is a carnivore's behavior?

images

Query results:

images

Q4: Who has what?

images

Query results:

who                    what

---------------------------------

myns:carnivore    “claws”

myns: mammal      “hair”

Q5: How many different mammals are there?

images

Query results:

images

Q6: Inference query:

What category does tiger belong to?

images

Query results:

images

Q7: Query with filter:

Who has an average lifespan longer than 15 years?

images

where the “avgAge” is defined as follows:

images

Query results:

images

Sometimes you need to use reasoners to strengthen SPARQL's deduction capability.

For just RDFS or OWL inference you can use the prepackaged reasoners; for extending your own rules that you defined yourself, you can build a generic reasoner and include the standard rules.

You know from the dataset that mammal has “hair” and :mammal gives “milk”, but you cannot conclude that an animal is a mammal simply because an animal has hair and gives milk.

If you do have such a rule about mammal recognition, then an animal that has hair and gives milk is a mammal.

Rule 1:

images

Rule 2:

images

If you know a mammal has “hair”, eats “meat”, has “claws”, and has “stripes”, SPARQL can infer that the animal is a tiger. By the first two given conditions you can deduce that it is a mammal. With the last two conditions plus the deduced fact, you can conclude that it is a tiger.

As W3C summarized,

The Semantic Web is about two things. It is about common formats for integration and combination of data drawn from diverse sources, where the original web mainly concentrated on the interchange of documents. It is also about language for recording how the data relates to real world objects. That allows a person, or a machine, to start off in one database, and then move through an unending set of databases which are connected not by wires but by being about the same thing.

The Semantic Web is the third-generation web. The new generation Web will be smarter, more open and connected, and more intelligent. It will evolve the Web from an isolated application and data network to a more seamless and interoperable web with an integrated and distributed semantic database for semantic search. The WebOS (Web 4.0) will be the next phase in web evolution after Web 3.0.

9.4 References

Semantic Web, http://www.w3.org/2001/sw/, 2007.

SPARQL, http://www.w3.org/2002/ws/sawsdl/, 2007.

RDF Primer, W3C Recommendation, http://www.w3.org/TR/rdf-primer/, 2004.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset