• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Chapter 2 semantic web
 

Chapter 2 semantic web

on

  • 1,187 views

 

Statistics

Views

Total Views
1,187
Views on SlideShare
1,187
Embed Views
0

Actions

Likes
2
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Chapter 2 semantic web Chapter 2 semantic web Presentation Transcript

    • Chapter 2 XML & Its Impact
    • Introduction• Definition 2.1: XML is used to improve compatibility between the desperate systems of business partners by defining the meaning of data in business documents.• Definition 2.2: XML is a language allowing the exchange of structured data.Akerkar: Foundations of © Narosa Publishing House, 2009 2Semantic Web.
    • The design goals for XML – XML shall be straightforwardly usable over the Internet. – XML shall support a wide variety of applications. – XML shall be compatible with SGML. – It shall be easy to write programs which process XML documents. – The number of optional features in XML is to be kept to the absolute minimum, ideally zero. – XML documents should be human-legible and reasonably clear. – The XML design should be prepared quickly. – The design of XML shall be formal and concise. – XML documents shall be easy to create. – Terseness in XML markup is of minimal importance.Akerkar: Foundations of © Narosa Publishing House, 2009 3Semantic Web.
    • W3C Understanding XML• XML is for structuring data• XML looks a bit like HTML• XML is text, but isn’t meant to be read• XML is verbose by design• XML is a family of technologies• XML is new, but not that new• XML leads HTML to XHTML• XML is modular• XML is the basis for Resource Description Format (RDF) and the Semantic Web• XML is license-free, platform-independent and well- supportedAkerkar: Foundations of © Narosa Publishing House, 2009 4Semantic Web.
    • XML Processing• Example 2.1: gopal.xml is an XML document containing Gopals resume. The document contains educational background, earlier work experience, references, and contact information by markup tags: <resume> <contact-info> ... </contact-info> <education> ... </education> <experience> ... </experience> <references> ... </references> </resume>Akerkar: Foundations of © Narosa Publishing House, 2009 5Semantic Web.
    • XML Processing XML Processor gopal.xml gopal.htmlAkerkar: Foundations of © Narosa Publishing House, 2009 6Semantic Web.
    • HTML & XML <p> The lecture notes on: <br /> <i> Semantic Web. </i> Author of the notes <br /> <b> R. Akerkar. </b> <book_title> Semantic Web </book_title> <author> R. Akerkar </author> <publisher> Narosa Publishing House </publisher> <copydate> 2008 </copydate>Akerkar: Foundations of © Narosa Publishing House, 2009 7Semantic Web.
    • XML Prolog prolog ::= (declaration, misc*, dtd?, misc*) misc ::= (comment | pi)Here is a sample XML declaration: <?xml version = "1.0" encoding = "UTF-16" standalone = "yes"?>Akerkar: Foundations of © Narosa Publishing House, 2009 8Semantic Web.
    • XML Comment – An XML comment has the same form as an HTML comment: <!-- this is an XML comment --> – XML processors ignore XML comments. – A processing instruction (PI) provides processing directions in the form of attribute values to a target XML processor. For example, the following PI tells a style sheet processor which style sheet should be used to process this document: <?xml:stylesheet type = "text/xsl" href = "outline.xsl"?>Akerkar: Foundations of © Narosa Publishing House, 2009 9Semantic Web.
    • Elements element ::= (start-tag, content?, end-tag) | empty-elem-tag start-tag ::= <(name, attribute*)> end-tag ::= </name> empty-elem-tag ::= <(name, attribute+)/> content ::= (text | comment | pi | entity-ref | element)+ <memo> <from> Gopal <to> Gita </from> </to> Dinner tonight? </memo>Akerkar: Foundations of © Narosa Publishing House, 2009 10Semantic Web.
    • Document Declaration• An XML document consists of a declaration followed by a single element called the root: <?xml version = "1.0"?> <ROOT> CONTENT </ROOT>Akerkar: Foundations of © Narosa Publishing House, 2009 11Semantic Web.
    • XML Overview XML Concepts Elements & DTDs Namespaces AttributesAkerkar: Foundations of © Narosa Publishing House, 2009 12Semantic Web.
    • Public Languages• A registry of public languages is maintained by xml.org at: http://www.xml.org/xml/registry.jsp W3C recommendations also include a number of public languages including XHTML, MathML, and SVG.Akerkar: Foundations of © Narosa Publishing House, 2009 13Semantic Web.
    • Foreign Elements• A LabML report has the format: <experiment date = "..."> <introduction>...</introduction> <equipment-list>...</equipment-list> <procedure>...</procedure> <data>...</data> <analysis>...</analysis> <summary>...</summary> </experiment>Akerkar: Foundations of © Narosa Publishing House, 2009 14Semantic Web.
    • XML Design Patterns• Document-Oriented <html> ... </html> <report> ... </report> <invoice> ... </invoice> <chapter> ... </chapter>• Data Oriented <employee> ... </employee> <measurement> ... </measurement> <organization> ... </organization>• Command Oriented <deposit> ... </deposit> <transfer> ... </transfer> <invoke> ... </invoke> <render> ... </render>Akerkar: Foundations of © Narosa Publishing House, 2009 15Semantic Web.
    • Data Structures• Records • <record type = "student"> <field name = "name"> Gopal </field> <field name = "gpa"> 1.2 </field> <field name = "class"> B. Sc. Second Year </field> <!-- etc --> </record>• Or, less generically: • <student> <name> Gopal </name> <gpa> 1.2 </gpa> <class> B. Sc. Second Year </class> <!-- etc --> </student>Akerkar: Foundations of © Narosa Publishing House, 2009 16Semantic Web.
    • Data Structures• Lists can be implicitly ordered by their position in the document (document order): <items> <item> 100 </item> <item> 200 </item> <item> 300 </item> <item> 400 </item> <item> 500 </item> </items>• Or the order can be made explicit: <items> <item id = "id4"> <data> 400 </data> <prev ref = "id3"/> <next ref = "id5"/> </item> …. ….Akerkar: Foundations of © Narosa Publishing House, 2009 17Semantic Web.
    • • Example 2.2: Let us consider a document containing Rita Mathur’s address. This information can be represented as: <label> <name> Rita Mathur </name> <address> <street> 12 Jaiprakash nagar, Goregaon </street> <city> Mumbai </city> <state> Maharashtra </state> </address> </label>Akerkar: Foundations of © Narosa Publishing House, 2009 18Semantic Web.
    • • Example 2.3: Attributes are used to represent the information. <address Street = “12 Jaiprakash nagar, Goregaon” City = “Mumbai” State = “Maharashtra” />Akerkar: Foundations of © Narosa Publishing House, 2009 19Semantic Web.
    • Namespaces• Namespaces are a simple mechanism for creating globally unique names for the elements and attributes of your markup language xmlns : prefix=”location” <xsd:integer> A sample namespace declaration: <xsd:schema xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>Akerkar: Foundations of © Narosa Publishing House, 2009 20Semantic Web.
    • Namespaces• A default namespace is declared by eliminating the prefix from the declaration: <html xmlns=”http://www.w3.org/1999/xhtml”> <head> <title> Default namespace </title> </head> <body> Web Programming </body> </html>Akerkar: Foundations of © Narosa Publishing House, 2009 21Semantic Web.
    • Example 2.5<?xml version="1.0" standalone="yes"?> ?><DATARECORD><PERSON> <FIRSTNAME>Ram</FIRSTNAME> <MEDDLENAME>Manohar</MIDDLENAME> <LASTNAME>Patel</LASTNAME> <CITY>Pune</CITY> <SALARY>Rs. 35000</SALARY></PERSON><PERSON> <PERSON> <FIRSTNAME>Jagan</FIRSTNAME> <FIRSTNAME>Raja</FIRSTNAME> <MEDDLENAME>Jeevan</MIDDLENAME> <MEDDLENAME>Ram</MIDDLENAME> <LASTNAME>Rai</LASTNAME> <LASTNAME>Venugopal</LASTNAME> <CITY>Mumbai</CITY> <CITY>Mumbai</CITY> <SALARY>Rs. 50000</SALARY> <SALARY>Rs. 80000</SALARY></PERSON> </PERSON><PERSON> <PERSON> <FIRSTNAME>Reema</FIRSTNAME> <FIRSTNAME>Pankaj</FIRSTNAME> <MEDDLENAME>Ravi</MIDDLENAME> <MEDDLENAME>Kumar</MIDDLENAME> <LASTNAME>Verma</LASTNAME> <LASTNAME>Sen</LASTNAME> <CITY>Delhi</CITY> <CITY>Pune</CITY> <SALARY>Rs. 65000</SALARY> <SALARY>Rs. 50000</SALARY></PERSON> </PERSON> <DATARECORD>Akerkar: Foundations of © Narosa Publishing House, 2009 22Semantic Web.
    • Document Type Definitions <!DOCTYPE name external-id? [internal-decs]?>Examples 2.6: Suppose we want to represent our books, records, CDs and DVDs in a library element. The following declaration requires that all books are listed before all records: <!ELEMENT library (book*, record*, cd*, dvd*)> By contrast, the following declaration allows us to list books, records, CDs, and DVDs in any order: <!ELEMENT library (book | record | cd | dvd)*>Akerkar: Foundations of © Narosa Publishing House, 2009 23Semantic Web.
    • Attribute Types• There are three attribute types: attType ::= CDATA | token | enumerated – where CDATA is any quoted string.• There seven token types: token ::= ID | IDREF | IDREFS | ENTITY | ENTITIES | NMTOKEN | NMTOKENSAkerkar: Foundations of © Narosa Publishing House, 2009 24Semantic Web.
    • Entity DeclarationsExample 2.8: <?xml version = "1.0" standalone = "no"?> <!DOCTYPE course SYSTEM "course.dtd" [<!ENTITY mt1 "midterm1"> <!ENTITY mt2 "midterm2"> ]> <course> <title> Web Programming </title> <semester> Fall 2008 </semester> <exams> <exam exam-id = "&mt1;" date = "2008-09-12" total = "100"/> <exam exam-id = "&mt2;" date = "2008-10-15" total = "100"/> <exam exam-id = "final" date = "2008-11-20" total = "200"/> </exams> <students> <student name = "Gopal Sharma" student-id = "A123" grade =Akerkar: Foundations of © Narosa Publishing House, 2009 25Semantic Web.
    • Entity Declarations "A"> <score exam-ref = "&mt1;" total = "90"/> <score exam-ref = "&mt2;" total = "95"/> <score exam-ref = "final" total = "182"/> </student> <student name = "Rita Mathur" student-id = "A124" grade = "B"> <score exam-ref = "&mt1;" total = "90"/> <score exam-ref = "&mt2;" total = "78"/> <score exam-ref = "final" total = "155"/> </student> <student name = "Shila Soman" student-id = "A125" grade = "C"> <score exam-ref = "&mt1;" total = "70"/> <score exam-ref = "&mt2;" total = "70"/> <score exam-ref = "final" total = "140"/> </student> <!-- etc. --> </students> </course>Akerkar: Foundations of © Narosa Publishing House, 2009 26Semantic Web.
    • XML Schema <?xml version = "1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <!-- global declarations go here --> </xsd:schema> <xsd:element name = "tag1" type = "Tag1Type"/> <xsd:element name = "tag2" type = "Tag2Type"/> <xsd:element name = "tag3" type = "Tag3Type"/>Akerkar: Foundations of © Narosa Publishing House, 2009 27Semantic Web.
    • XML Schema xsd:string ::= <char>+ xsd:boolean ::= false | true xsd:decimal ::= (+ | -)?<digit>+(.<digit>*)? xsd:double ::= IEEE double precision float xsd:float ::= IEEE single precision float xsd:integer ::= (+|-)?<digit>+ xsd:duration ::= P<int>Y<int>M<int>DT<int>H<int>M<int>S xsd:time ::= <hours>:<mins>:<secs> <hours>, <mins> ::= <int>, <secs> ::= <decimal> xsd:date ::= <CCYY>-<MM>-<DD> xsd:anyURI ::= <URI> xsd:ID ::= <NCName> xsd:IDREF ::= <NCName> xsd:QName ::= <URI>:<NCName> xsd:Name ::= <XMLName>Akerkar: Foundations of © Narosa Publishing House, 2009 28Semantic Web.
    • XML Schema <xsd:complexType name = "Tag1Type"> <!-- tag1 elements and attributes declared here --> </xsd:complexType> <xsd:complexType name = "Tag2Type"> <!-- tag2 elements and attributes declared here --> </xsd:complexType> <xsd:complexType name = "Tag3Type"> <!-- tag3 elements and attributes declared here --> </xsd:complexType>Akerkar: Foundations of © Narosa Publishing House, 2009 29Semantic Web.
    • XML Schema• A default value (content) may also be specified: <xsd:element name = "tag" type = "TYPE" minOccurs = "N" maxOccurs = "M" default = "J"/> where: 0 <= N <= M <= "unbounded"Akerkar: Foundations of © Narosa Publishing House, 2009 30Semantic Web.
    • Example 2.9 <review id="100"><!-- movies.xml --> <movie-id>1</movie-id><?xml version="1.0"?> <stars>5</stars><!DOCTYPE movies SYSTEM "movies.dtd"> <comment>You cant call<movies> yourself a geek <movie id="1"> unless youve seen this <title>The Matrix</title> <b>amazing</b> </movie> movie.</comment> <movie id="2"> </review> <title>The Matrix: Reloaded</title> <review id="101"> </movie> <movie-id>1</movie-id></movies> <stars>3</stars><!-- movie-reviews.xml --> <comment><a href=<?xml version="1.0"?><!DOCTYPE reviews SYSTEM "reviews.dtd"> "http://www.keanunet.com">Kean<reviews> u</a> can act!</comment> </review> </reviews>Akerkar: Foundations of © Narosa Publishing House, 2009 31Semantic Web.
    • XPath Root Node Element Node Element Node Content Node Attribute Node Attribute Node Attribute Node Attribute NodeAkerkar: Foundations of © Narosa Publishing House, 2009 32Semantic Web.
    • Path ExpressionConsider the XML document library.xml: <library location =”Kolhapur”> <author name=”R. Akerkar”> <book title=”Artificial Intelligence”> <book title=”Building an Intelligent Web”> <book title=”Discrete Mathematics”> </author> <author name=”P. Winston”> <book title=”Artificial Intelligence”> </author> <author name=”V. Rajaraman”> <book title=”Information Technology”> <book title=”Supercomputing”>Akerkar: Foundations of © Narosa Publishing House, 2009 33Semantic Web.
    • Path Expression V. author @name Rajaraman Information book @title Technology book Supercomp @title uting author @name P. Winston Artificial book @title Intelligence root library @name R. Akerkar Discrete author book @title Mathematics Building an book @title Intelligent Web Artificial book @title Intelligence @location KolhapurAkerkar: Foundations of © Narosa Publishing House, 2009 34Semantic Web.
    • Tree RepresentationAkerkar: Foundations of © Narosa Publishing House, 2009 35Semantic Web.
    • Tree RepresentationAkerkar: Foundations of © Narosa Publishing House, 2009 36Semantic Web.
    • XQuery• Example 2.10: This example searches the books.xml document and returns every chapter nodes title child value. document("books.xml")//chapter/title• Example 2.11: Generates a new element <report> for each value for title. <report> {$b/title} </report>Akerkar: Foundations of © Narosa Publishing House, 2009 37Semantic Web.
    • Example 2.12• Perform a simple search that returns all books published by Narosa Publishers after 1998, inclusive of each book year and title. <bib> { for $b in doc("http://book.sample.org/bib.xml")/bib/book where $b/publisher = "Narosa Publishers" and $b/@year > 1998 return <book year="{$b/@year}"> {$b/title} </book> } </bib>Akerkar: Foundations of © Narosa Publishing House, 2009 38Semantic Web.
    • Example 2.12• The result follows: <bib> <book year="1999"> <title>Nonlinear Functional Analysis</title> </book> … … … <book year="2008"> <title>Foundations of Semantic Web</title> </book> </bib>Akerkar: Foundations of © Narosa Publishing House, 2009 39Semantic Web.
    • Example 2.13• Let us use the function min() to determine the minimum price for each book. – We generate the <minprice> element, with the book title as its attribute. <results> { let $doc := doc("prices.xml") for $t in distinct-values($doc//book/title) let $p := $doc//book[title = $t]/price return <minprice title="{$t}"> <price>{min($p)}</price> </minprice> } </results>Akerkar: Foundations of © Narosa Publishing House, 2009 40Semantic Web.
    • Suggested Readings 1. R. Akerkar and P. Lingras. Building an Intelligent Web: Theory & Practice. Johns & Bartlett, 2008. 2. P. V. Biron, A. Malhotra (eds.): XML Schema Part 2: Datatypes, W3C Working Draft 07 April 2000, http://www.w3.org/TR/2000/WD-xmlschema- 2-20000407/. 3. T. Bray, J. Paoli, and C.M. Sperberg-McQueen (eds.): Extensible Markup Language (XML) 1.0, W3C Recommendation 10-February-1998, http://www.w3.org/TR/REC-xml. 4. T. Bray, D. Hollander, and A. Layman (eds.): Namespaces in XML, World Wide Web Consortium Recommendation, 14-January-1999, http://www.w3.org/TR/REC-xml-names/. 5. J. Clark (ed): XSL Transformations (XSLT), W3C Recommandation 16 November 1999, http://www.w3.org/TR/xslt. 6. J. Davidson: Java API for XML Parsing, Version 1.0 Final Release, http://java.sun.com/aboutJava/communityprocess/final/jsr005/index.html. 7. XQuery1.0: An XML Query Language, http://www.w3.org/TR/xquery/ 8. XML Query Use Cases, http://www.w3.org/TR/xmlquery-use-cases 9. What is XQuery: Katz, 2004. http://www.gnu.org/software/qexo/XQuery- Intro.html.Akerkar: Foundations of © Narosa Publishing House, 2009 41Semantic Web.