markup language for books (xml and semantic web approach)

46
Markup Language for Books (XML and Semantic Web Approach) Markup Languages By: Rakhi Gupta August 03, 2009

Upload: jaxon

Post on 11-Jan-2016

59 views

Category:

Documents


0 download

DESCRIPTION

Markup Language for Books (XML and Semantic Web Approach). Markup Languages By: Rakhi Gupta August 03, 2009. 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) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Markup Language for Books (XML and Semantic Web Approach)

Markup Language for Books(XML and Semantic Web Approach)

Markup Languages

By: Rakhi Gupta

August 03, 2009

Page 2: Markup Language for Books (XML and Semantic Web Approach)

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

Page 3: Markup Language for Books (XML and Semantic Web Approach)

INTRODUCTION (cont’d)

XML

XML Schema

RDF

RDF Schema

Ontology

Logic and Proof

Trust

Page 4: Markup Language for Books (XML and Semantic Web Approach)

Markup Language for books

Page 5: Markup Language for Books (XML and Semantic Web Approach)

XML Schema

Page 6: Markup Language for Books (XML and Semantic Web Approach)

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.

Page 7: Markup Language for Books (XML and Semantic Web Approach)

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>

Page 8: Markup Language for Books (XML and Semantic Web Approach)

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>

Page 9: Markup Language for Books (XML and Semantic Web Approach)

XQuery

Query language Handles transformation, query and merge

problems Extends the capability of XPath Handles complex queries very well

Page 10: Markup Language for Books (XML and Semantic Web Approach)

Query multiple documents

<results>{

let $bookdoc := doc("catalog.xml")//booklet $pubdoc := doc("addresses.xml")/publishers/publisherfor $somebook in $bookdoc, $somepublisher in $pubdocwhere $somebook/bookcatalog/publisher = $somepublisher/@idreturn <result>{<book>{$somebook/title}</book>,

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

</results>

Page 11: Markup Language for Books (XML and Semantic Web Approach)

FLWOR

General structure :FOR variable declarationsLET variable := expression, variable := expression, …WHERE conditionORDER BY variableRETURN document

Page 12: Markup Language for Books (XML and Semantic Web Approach)

Example - FLWOR

<bookcatalog>{

for $book at $index in doc("catalog.xml")/bookcatalog/section/booklet $price := $book/pricelet $genre := $book/genrewhere $genre = “ScFiction"order by $price descendingreturn

<book index = "{$index}">{$book/@*}$book/*}</book>

}</bookcatalog>

Page 13: Markup Language for Books (XML and Semantic Web Approach)

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

Page 14: Markup Language for Books (XML and Semantic Web Approach)

XForms

Instance data

used inuser

interaction

XForms model

XForms user interface

Serialized data sent to server

user

XML Events

Page 15: Markup Language for Books (XML and Semantic Web Approach)

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>

Page 16: Markup Language for Books (XML and Semantic Web Approach)
Page 17: Markup Language for Books (XML and Semantic Web Approach)

Why XForms?

Multiple Environments Internationalization Input ValidationAvoid round trips

Page 18: Markup Language for Books (XML and Semantic Web Approach)

XML SemanticsExample1:

<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>

Page 19: Markup Language for Books (XML and Semantic Web Approach)

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

Page 20: Markup Language for Books (XML and Semantic Web Approach)

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

Page 21: Markup Language for Books (XML and Semantic Web Approach)

Represent data as a set of relations

Semantic Web

2009

Wrox

Chicago

http://bml.net/isbn0002659X

http://neilgaiman.comNeil Gaiman

a:title

a:year

a: publisher

a:city

a:author

a:name a: homepage

Page 22: Markup Language for Books (XML and Semantic Web Approach)

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

Page 23: Markup Language for Books (XML and Semantic Web Approach)

Represent data from book store

http://bml.net/isbn0002659X

http://bml.net/isbn0203040

Web Sémantique

Terry Pratchett

Neil Gaiman

f:auteur

f:nomf:nom

f:original f:titre

f:traducteur

Page 24: Markup Language for Books (XML and Semantic Web Approach)

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:yeara: publisher

a:city

a:name

a:pubname

a:homepage

a:author

f:auteurf:titre

f:traducteur

f:nomf:nom

Same URI’s = Same resources

foaf:personr:type

r:type

foaf:name foaf:name

f:original

foaf:homepage

foaf:name

Page 25: Markup Language for Books (XML and Semantic Web Approach)

Semantic Web Approach

Data Integration map various data onto an abstract data

representation merge resulting representations makes queries on whole

Page 26: Markup Language for Books (XML and Semantic Web Approach)

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

Page 27: Markup Language for Books (XML and Semantic Web Approach)

RDF Characteristics

Independence Interchange Scalability Properties are resources Values can be resources Statements can be resources

Page 28: Markup Language for Books (XML and Semantic Web Approach)

Resource Property Statement RDF-Triples

Subject

Basic elements of RDF

ObjectPredicate

Page 29: Markup Language for Books (XML and Semantic Web Approach)

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>

Page 30: Markup Language for Books (XML and Semantic Web Approach)

Validation Result

Page 31: Markup Language for Books (XML and Semantic Web Approach)

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

Page 32: Markup Language for Books (XML and Semantic Web Approach)

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>

Page 33: Markup Language for Books (XML and Semantic Web Approach)

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

Page 34: Markup Language for Books (XML and Semantic Web Approach)

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

Page 35: Markup Language for Books (XML and Semantic Web Approach)

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#nonNegativeInteger">1</owl:minCardinality></owl:Restriction>

Page 36: Markup Language for Books (XML and Semantic Web Approach)

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.

Page 37: Markup Language for Books (XML and Semantic Web Approach)

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

Page 38: Markup Language for Books (XML and Semantic Web Approach)

Google Services

Google Marketplace Search Google Personal Agent Google Verification Manager Google MarketPlace Manager

Page 39: Markup Language for Books (XML and Semantic Web Approach)

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

Page 40: Markup Language for Books (XML and Semantic Web Approach)

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

Page 41: Markup Language for Books (XML and Semantic Web 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

Page 42: Markup Language for Books (XML and Semantic Web Approach)

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

Page 43: Markup Language for Books (XML and Semantic Web Approach)

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.

Page 44: Markup Language for Books (XML and Semantic Web Approach)

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

Page 45: Markup Language for Books (XML and Semantic Web Approach)

Questions??

Page 46: Markup Language for Books (XML and Semantic Web Approach)

Thank You!!