1 / 46

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

jaxon
Download Presentation

Markup Language for Books (XML and Semantic Web Approach)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. INTRODUCTION (cont’d) Trust Logic and Proof Ontology RDF Schema RDF XML Schema XML

  4. Markup Language for books

  5. XML Schema

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

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

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

  9. XQuery • Query language • Handles transformation, query and merge problems • Extends the capability of XPath • Handles complex queries very well

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

  11. FLWOR • General structure : FOR variable declarations LET variable := expression, variable := expression, … WHERE condition ORDER BY variable RETURN document

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

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

  14. XForms XForms model Instance data used in user interaction Serialized data sent to server XML Events XForms user interface user

  15. <?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> Examples

  16. Why XForms? • Multiple Environments • Internationalization • Input Validation • Avoid round trips

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

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

  19. Simplified Book Store(based on Markup Language for books ) • Books • Authors • Publishers

  20. Represent data as a set of relations http://bml.net/isbn0002659X Semantic Web a:title a:year 2009 a:author a: publisher Wrox a:city Chicago a:name a: homepage http://neilgaiman.com Neil Gaiman

  21. Another book store’s data

  22. Represent data from book store Web Sémantique http://bml.net/isbn0002659X f:original f:titre f:auteur http://bml.net/isbn0203040 f:traducteur f:nom f:nom Neil Gaiman Terry Pratchett

  23. Merge internal resources Same URI’s = Same resources http://bml.net/isbn00026539X a:title Semantic Web a: publisher a:year f:original Web Sémantique 2009 f:auteur f:titre a:pubname a:author http://bml.net/isbn0203040 Wrox f:traducteur a:city r:type Chicago foaf:person a:name foaf:name r:type f:nom f:nom a:homepage foaf:name foaf:name Neil Gaiman foaf:homepage Neil Gaiman Terry Pratchett http://neilgaiman.com

  24. Semantic Web Approach • Data Integration • map various data onto an abstract data representation • merge resulting representations • makes queries on whole

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

  26. RDF Characteristics • Independence • Interchange • Scalability • Properties are resources • Values can be resources • Statements can be resources

  27. Basic elements of RDF • Resource • Property • Statement • RDF-Triples Subject Predicate Object

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

  29. Validation Result

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

  31. <?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> RDF Schema Example

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

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

  34. <?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> Example

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

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

  37. Google Services • Google Marketplace Search • Google Personal Agent • Google Verification Manager • Google MarketPlace Manager

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

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

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

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

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

  43. 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/sparqlhttp://www.slideshare.net/LeeFeigenbaum/semantic-web-landscape-2009?type=powerpoint • http://www.ibm.com/developerworks/library/x-xformswhy.html

  44. Questions??

  45. Thank You!!

More Related