Markup Language for Books

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

22 Οκτ 2013 (πριν από 3 χρόνια και 9 μήνες)

115 εμφανίσεις




Markup Language for Books

(XML and Semantic Web Approach)


Markup Languages

By: Rakhi Gupta

August 03, 2009


INTRODUCTION



Develop a markup language for books



Develop document structure or information model


DTD/Schema for markup language



Use XSLT and XQuery



XForms



Semantic Web (RDF, RDFS, OWL, FOAF)



Applications and Conclusions










INTRODUCTION (cont’d)




XML

XML Schema

RDF

RDF Schema

Ontology

Logic and Proof

Trust


Markup Language for books
















XML Schema




XSLT


Transformation problems


Querying


Uses XPath for navigation through the
hierarchical nodes in the XML tree


Can result output in XML, HTML or text
format.






Example1

<?xml version="1.0" encoding="UTF
-
8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">



<xsl:template match="bookcatalog">


<xsl:copy>


<xsl:for
-
each select="//book[author]">


<xsl:copy>


<xsl:copy
-
of select="title"/>







<xsl:copy
-
of select="author[position() &lt;= 2]"/>





<xsl:if test="author[3]">




<et
-
al/>


</xsl:if>


</xsl:copy>


</xsl:for
-
each>


</xsl:copy>


</xsl:template>

</xsl:stylesheet>




Example2

<?xml version="1.0" encoding="UTF
-
8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output method="html"/>

<xsl:template match="bookcatalog/book">


<html>


<head/>


<body>


<h3>


<ul><li>


<xsl:text>Publish Date from</xsl:text>


<xsl:value
-
of select="child::*[1]/publish_date"/>


<xsl:text>until</xsl:text>


<xsl:value
-
of select="child::*[last()]/publish_date"/>


<xsl:text></xsl:text>


</li></ul>


</h3>


<xsl:apply
-
templates select="price"/>


<!
--

Price Information
--
>


<h3>


<xsl:text>Prices from</xsl:text>


<xsl:value
-
of select="child::*[1]/publish_date"/>


<xsl:text>until</xsl:text>


<xsl:value
-
of select="child::*[last()]/publish_date"/>


<xsl:text>highest to lowest</xsl:text>


</h3>


<xsl:apply
-
templates select="book">


<xsl:sort data
-
type="number" order="descending"


select="price"/>


</xsl:apply
-
templates>


</body>


</html>


</xsl:template>

</xsl:stylesheet>






XQuery


Query language


Handles transformation, query and merge
problems


Extends the capability of XPath


Handles complex queries very well



Query multiple documents

<results>

{


let $bookdoc := doc("catalog.xml")//book


let $pubdoc := doc("addresses.xml")/publishers/publisher


for $somebook in $bookdoc,



$somepublisher in $pubdoc


where $somebook/bookcatalog/publisher = $somepublisher/@id


return


<result>


{<book>{$somebook/title}</book>,



$somepublisher/address
[@type = "shipping"]
}


</result>


}

</results>







FLWOR


General structure :

FOR
variable declarations

LET variable := expression,


variable := expression, …

WHERE
condition

ORDER BY

variable

RETURN
document




Example
-

FLWOR

<bookcatalog>

{


for

$book at $index in doc("catalog.xml")/bookcatalog/section/book


let
$price := $book/price


let $genre := $book/genre


where

$genre = “ScFiction"


order
by $price descending


return



<book index = "{$index}">



{$book/@*}



$book/*}



</book>

}

</bookcatalog>





XQuery versus




XSLT and SQL


Why XQuery?


XSLT


better oriented towards transformation
problems


XQuery


great at expressing joins and sorts;
manipulate values and nodes


SQL


focus on unordered sets of “flat” rows
while XQuery focusses on ordered sequences




XForms


Instance

data

used in

user

interaction

XForms model

XForms

user interface

Serialized data

sent to server

user

XML Events




Examples

<?xml version="1.0" encoding="UTF
-
8"?>

<xhtml xmlns="http://www.w3.org/1999/xhtml"


xmlns:ev="http://www.w3.org/2001/xml
-
events"


xmlns:xf="http://www.w3.org/2002/xforms">


<head>




<style type="text/css">


h1 {font
-
size: 12pt }


xf|input.itemClass { width:100px }


xf|input.custNumClass { width:100px }


xf|input.dateClass { width:80px }


</style>


<title>Enter Review(s)</title>




<xf:model id="model1">




<xf:instance>


<books xmlns="">


<review>


<title/>


<author/>


<custreview/>


</review>


</books>


</xf:instance>




<xf:submission id="s01" method="put"


action="ex2order.xml" />


</xf:model>


</head>



<body>



<h1>Give Reviews here!</h1>


<p>Enter details.</p>


<xf:repeat id="i1" nodeset="/books/review">


<xf:input ref="title">


<xf:label>Title </xf:label>


</xf:input>




<xf:input ref="author">


<xf:label>Author</xf:label>


</xf:input>


<xf:input ref="custreview">


<xf:label>Reviews</xf:label>


</xf:input>


<br />


</xf:repeat>




<
xf:trigger

id="addAnotherBookReview">


<xf:label>Add Reviews</xf:label>


<xf:action ev:event="DOMActivate">


<xf:insert nodeset="review" at="last()"


position="after"


ev:event="xforms
-
activate"/>


</xf:action>


</xf:trigger
>


<xf:submit submission="s01">


<xf:label>Save</xf:label>


<xf:hint>Click here to save.</xf:hint>


</xf:submit>


<p>Click "Save" to store entered reviews.</p>


</body>

</xhtml>




Why XForms?


Multiple Environments


Internationalization


Input Validation


Avoid round trips



XML Semantics

Example1:

<item>

<subitem1 property1=”Terry Pratchett” property2=”Feet of Clay”





property3=”12345”/>

<subitem2 property1=”Neil Gaiman” property2=”Nancy Drew”

property3=”Feet of Clay” property4=”
www.terrypratchett.com
”/>

</item>


Example2:


<bibliography>

<book author=”Terry Pratchett” title=”Feet of Clay” ISBN=”12345”/>

<webpage author=”Neil Gaiman” author=”Terry Pratchett”


title=”Feet of Clay” URL=”
www.terrypratchett.com
”/>

</bibliography>



Semantic Web


Extension of current Web


Provides common framework


Agrees on common terms and relationship



Web information in machine readable fashion


Metadata



Dublin Core metadata


Ontologies


OWL, FOAF


WWW : WebPages :: Semantic Web : Data



Simplified Book Store







(based on Markup Language for books )


Books




Authors




Publishers


ID

Author

Title

Publisher

Year

0
-
002659X

a_xyz

Semantic Web

p_abc

2009

ID

Name

Homepage

a_xyz

Neil Gaiman

http://neilgaiman.com

ID

Publisher Name

City

p_abc

Wrox

Chicago

Represent data as a set of relations

Semantic Web

2009

Wrox

Chicago


http://bml.net/isbn0002659X


http://neilgaiman.com

Neil Gaiman

a:title

a:year

a: publisher

a:city

a:author

a:name

a: homepage


Another book store’s data

A

B

C

D

1

ID

Titre

Traducteur

Original

2

ISBN0
-
203040

Semantic Web

A7

ISBN
-

0
-
002659X

3

ID

Auteur

4

ISBN
-

0
-
002659X


A6

5

Nom

6

Neil Gaiman

7

Terry Pratchett

Represent data from book store

http://bml.net/isbn0002659X

http://bml.net/isbn0203040

Web Sémantique

Terry Pratchett

Neil Gaiman

f:auteur

f:nom

f:nom

f:original

f:titre

f:traducteur


Merge internal resources

http://bml.net/isbn00026539X

Semantic Web

2009

Wrox

Chicago

Neil Gaiman

http://neilgaiman.com

Web Sémantique

Terry Pratchett

http://bml.net/isbn0203040

Neil Gaiman

a:title

a:year

a: publisher

a:city

a:name

a:pubname

a:homepage

a:author

f:auteur

f:titre

f:traducteur

f:nom

f:nom

Same URI’s = Same resources

foaf:person

r:type

r:type

foaf:name

foaf:name

f:original

foaf:homepage

foaf:name


Semantic Web Approach


Data Integration


map various data onto an abstract data
representation


merge resulting representations


makes queries on whole


Resource Description Language




(RDF)


Framework to describe resources.



Coding, exchanging and reusing structured
metadata.



RDF is openly extensible i.e. it is machine
-
understandable.



RDF works in decentralized fashion








RDF Characteristics


Independence


Interchange


Scalability


Properties are resources


Values can be resources


Statements can be resources






Resource


Property


Statement


RDF
-
Triples


Subject



Basic elements of RDF

Object

Predicate


RDF Example

<?xml version="1.0" encoding="UTF
-
8"?>

<!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]>


<
rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22
-
rdf
-
syntax
-
ns#
"


xmlns="http://wwww.bml.net/books/Catalog#"


xmlns:uom="http://www.standards.org/measurements#"


xmlns:newp="http://
www.myfriend.net/
books/Catalog#"


xmlns:dc="http://www.purl.org/metadata/dublin
-
core#">




<rdf:Description rdf:about="http://wwww.bml.net/books/rdf/SemanticWeb.rdf #Semantic
-
Web">


<rdf:type rdf:resource="http://www.bml.net/books/Books#Catalog"/>


<title>Let's Learn Semantic Web in Summers</title>


<price>


<rdf:Description>


<
rdf:value

rdf:datatype="&xsd;decimal">25.25</rdf:value>


<uom:units rdf:resource="http://www.something.org/units#dollars"/>


</rdf:Description>


</price>



<newp:retailPrice rdf:datatype="&xsd;integer">23</newp:retailPrice>


<newp:salePrice rdf:datatype="&xsd;integer">15</newp:salePrice>


<dc:creator>Rakhi Gupta</dc:creator>


<dc:date>2009
-
07
-
25</dc:date>


</rdf:Description>

</rdf:RDF>





Validation Result



RDF Schema


RDF Vocabulary description language


Defines classes and the relationships between them


Defines properties and associate them with classes


Adds semantics to RDF predicates and resources


Core classes:

rdfs:Resource, rdfs:Property,rdfs:Class, rdfs:datatype


Core properties:

rdfs:subClassOf, rdfs:subPropertyOf


Core constraints:

rdfs:range,rdfs:domain



RDF Schema Example

<?xml version="1.0" encoding="UTF
-
8"?>

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22
-
rdf

-
syntax
-
ns#"

xmlns:base="http://www.bml.net/books/Computers.rdf"

xmlns:rdfs=“
http://www.w3.org/2000/01/rdf
-
schema#


xmlns:uom="http://www.standards.org/measurements#">


<
rdfs:Class

rdf:ID="Catalog"> </rdfs:Class>


<rdfs:Class rdf:ID="Publisher"></rdfs:Class>



<rdfs:Class rdf:ID="Books">


<rdfs:subClassOf rdf:resource="#Catalog"/>


</rdfs:Class>


<rdfs:Class rdf:ID="Magazines">


<rdfs:subClassOf rdf:resource="#Catalog"/>


</rdfs:Class>


<rdfs:Class rdf:ID="Beginner">


<rdfs:subClassOf rdf:resource="#Books"/>


</rdfs:Class>


<rdfs:Class rdf:ID="Advanced">


<rdfs:subClassOf rdf:resource="#Books"/>


</rdfs:Class>



<rdfs:Class rdf:ID="Wrox">


<rdfs:subClassOf rdf:resource="#Publisher"/>


</rdfs:Class>


<rdfs:Class rdf:ID="Specifications"></rdfs:Class>


<rdf:Property rdf:ID="has_spec">


<rdfs:domain rdf:resource="#Books"/>


<rdfs:range rdf:resource="#Specifications"/>


</rdf:Property>


<rdf:Property rdf:ID="owned_by">


<rdfs:domain rdf:resource="#Books"/>


<rdfs:range rdf:resource="#Publisher"/>


<rdfs:range rdf:resource="#Author"/>


</rdf:Property>

</rdf:RDF>






Ontologies


What are ontologies?


Can DTD be described as an Ontology?


DTD


restricted to “parent
-
of”, “child
-
of” and “attribute
-
of”


Complete ontology

”is
-
akind
-
of”, “if
-
then” or “is
-
afraid
-
of”,
“published
-
by”


Described using RDF




OWL Ontology


Web Ontology Language


OWL=RDF Schema + new constructs for
expressiveness


Defines group of terms and relationships


Provides a way to reuse domain
knowledge




Example


<?xml version="1.0"?>

<rdf:RDF


xmlns:rdf="http://www.w3.org/1999/02/22
-
rdf
-
syntax
-
ns#"


xmlns:xsd="http://www.w3.org/2001/XMLSchema#"


xmlns:rdfs="http://www.w3.org/2000/01/rdf
-
schema#"


xmlns:owl="http://www.w3.org/2002/07/owl#"


xmlns:base="http://www.bml.net/Books.owl">


<owl:Ontology
rdf:about="http://www.bml.net/books/Books.owl"/>


<owl:Class rdf:ID="Books"/><owl:Class rdf:ID="Person"/>



<owl:Class rdf:ID="SemanticWeb">

<rdfs:subClassOf rdf:resource="#Books"/>

<owl:equivalentClass

rdf:resource="http://www.yetAnother.com#SemanticWeb">

</owl:Class>


<owl:Class rdf:ID="Author">


<rdfs:subClassOf rdf:resource="#Person"/> </owl:Class>

<owl:Class rdf:ID="Specifications"></owl:Class>

<owl:Class rdf:ID="Advanced">

<rdfs:subClassOf rdf:resource="#SemanticWeb"/>

<
owl:disjointWith
rdf:resource="#Beginner"/></owl:Class>

<owl:Class rdf:ID="Advanced">

<rdfs:subClassOf rdf:resource="#Books"/><rdfs:subClassOf>
<
owl:Restriction
>


<owl:onProperty rdf:resource
="#owned_by
"/>


<
owl:allValuesFrom

rdf:resource="#GraduateStudents"/>


</owl:Restriction
>


</rdfs:subClassOf>


</owl:Class>

<
owl:DatatypeProperty

rdf:ID="expensiveOrNot">

<rdfs:domain rdf:resource="#Advanced"/>

<rdfs:range
rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>

</owl:DatatypeProperty>


<rdfs:datatype
rdf:about="http://www.w3.org/2001/XMLSchema#string"/>

<owl:DatatypeProperty rdf:ID="hasISBN">


<rdfs:domain rdf:resource="#Books" />


<rdfs:range rdf:resource="&xsd;string" />

<rdfs:label xml:lang="en">has ISBN</rdfs:label>

<rdfs:comment xml:lang="en">The International Standard
Book Number.</rdfs:comment>

</owl:DatatypeProperty>



<owl:Class rdf:ID="Wrox">


<rdfs:subClassOf rdf:resource="#Publisher"/>

</owl:Class>

<owl:Class rdf:ID="Specifications"></owl:Class>


<owl:ObjectProperty

rdf:ID="has_spec">


<rdfs:domain rdf:resource="#Books"/>


<rdfs:range rdf:resource="#Specifications"/>


</owl:ObjectProperty>

</rdf:RDF>


<rdfs:subClassOf> <owl:Restriction>

<owl:onProperty rdf:resource="#hasAuthor" />

<owl:minCardinality

rdf:datatype="&xsd;nonNegativeInteger">1

</owl:minCardinality>

</owl:Restriction> </rdfs:subClassOf>


<owl:Restriction>


<owl:onProperty rdf:resource="#owned_by"/>


<owl:minCardinality
rdf:datatype=“http://www.w3.org/2001/XMLSchema#nonNegat
iveInteger">1</owl:minCardinality>

</owl:Restriction>




Advantages of using Semantic Web



In large
-
scale systems architectures there are
often many component systems.


A huge amount of effort is spent in making
systems 'talk to one another'.


We can use meta
-
data ontologies to help use
'glue' diverse systems' data models together.





Applications


SWOOGLE


Knowledge management


Ontologies and P2P


Web Services


Use the Internet to access remote applications


Compose complex applications from simple one as around
the world


Standards should exist for:


Message exchange for accessing a service: SOAP


Description of services: could be WSDL



Directory of available services: could be UDDI




Google Services


Google Marketplace Search


Google Personal Agent


Google Verification Manager


Google MarketPlace Manager



Microsoft and XML


"XML
-
documents will be around for hundreds of
years",

Bill Gates


Browser support for XML and XSL


Development support: Parsers, XSL processor


Developments for e
-
commere, web services


.NET: everything is .NET as along as it is not
Java




IBM Developments


Basic technology: Parsers, XSL
processors, XML editor, XSL Editor and
more


Technoly included in e
-
commerce
software like Websphere


Fits in new IBM Grid services and e
-
everything approach




SUN and XML


Java is much used for XML processing


Java Servlets for Web servers


Interfaces, h for DOM, SAX, JDOM, Trax,
etc


Web services in Java and XML





Web Trends


Web is evolving from a provider of documents and images
(information retrieval)




To a provider of services



Web service discovery
-


Find me a book service that offers books on discounts



Web service execution
-


Buy me “Harry Potter and the Sorcerer’s Stone” at
www.amazon.com



Web service selection, composition and interoperation
-


Make my travel arrangements for my Internet World conference trip




Both retrieval and services lend themselves to agent
technologies





Conclusions





RDF, and the 'ontologies' family has the potential to be
an extremely powerful technology.


Markup languages will revolutionize the web
applications.


Software modules can be human proxies enabling new
applications and modes of interaction.


Given more time, I would extend the markup langauge
using Semantic Web and Web services into a web
application.


I would like to publish the semantics and its ontology on
the server so that anyone could access and reuse it.








References


http://www.w3.org/XML/

-

XML resources at W3C


http://www.w3.org/TR/xquery/

-

XQuery


http://www.w3.org/TR/xslt

-

XSLT


http://www.w3.org/2001/sw/

-

Semantic Web


http://semanticweb.org/wiki/Main_Page



http://www.w3.org/RDF/

-

RDF resources at W3C


http://dbpedia.org/sparql

http://www.slideshare.net/LeeFeigenbaum/semantic
-
web
-
landscape
-
2009?type=powerpoint



http://www.ibm.com/developerworks/library/x
-
xformswhy.html




Questions??

Thank You!!