XML XSLT XPath XQuery 5 Aug 2002 Introduction

  • Slides: 13
Download presentation
XML, XSLT, XPath, XQuery 5 Aug 2002

XML, XSLT, XPath, XQuery 5 Aug 2002

Introduction n XML (e. Xtensible Markup Language) – Holding data n XSLT (e. Xtensible

Introduction n XML (e. Xtensible Markup Language) – Holding data n XSLT (e. Xtensible Style Language Transform) – Transform one XML to another XML or other text such as HTML n XPath (XML Path) – A way to locate items in a XML file n XQuery (XML Query) – Query on one or more XML file to produce another XML file

Analogy XML view Database view XML Data XSLT HTML with ASP, JSP XPath Referring

Analogy XML view Database view XML Data XSLT HTML with ASP, JSP XPath Referring to a field, such as Student. id XQuery SQL Semi-structured Exchange and sharing storage Self-describing RDMS enforced constraint Properties

Sample XML (link) <? xml: stylesheet type="text/xsl" href="classical. xsl"? > <authors> <author period="Classical"> Specify

Sample XML (link) <? xml: stylesheet type="text/xsl" href="classical. xsl"? > <authors> <author period="Classical"> Specify <name>Mozart</name> <nationality>Austrian</nationality> XSL for display </author> <author period="Classical"> <name>Beethoven</name> <nationality>German</nationality> </author> <author period="Baroque"> <name>Bach</name> <nationality>German</nationality> </author> <author period="Romance"> <name>Mahler</name> <nationality>Austrian</nationality> </authors>

DOM Tree Root Node Element Node Text Node authors author period name Attribute Node

DOM Tree Root Node Element Node Text Node authors author period name Attribute Node author nationality Classical name period author nationality Classical Mozart Austrian Beethoven period name nationality Bach German Baroque German

Sample XSL (link) <xsl: stylesheet xmlns: xsl="http: //www. w 3. org/TR/WD-xsl"> <xsl: template match="/">

Sample XSL (link) <xsl: stylesheet xmlns: xsl="http: //www. w 3. org/TR/WD-xsl"> <xsl: template match="/"> <HTML> XSL version <HEAD><TITLE>Authors</TITLE></HEAD> <BODY> <H 1>Composers from Austria</H 1> <TABLE BORDER="1"><TR><TH>Name</TH></TR> XPath <xsl: for-each select="/authors/author[nationality='Austrian']"> <TR><TD><xsl: value-of select="name" /></TD></TR> </xsl: for-each> </TABLE> </BODY> </HTML> </xsl: template> </xsl: stylesheet>

Output (link) Original XML Transformed XML

Output (link) Original XML Transformed XML

Sample XSL <xsl: stylesheet xmlns: xsl="http: //www. w 3. org/TR/WD-xsl"> <xsl: template match="/"> <HTML>

Sample XSL <xsl: stylesheet xmlns: xsl="http: //www. w 3. org/TR/WD-xsl"> <xsl: template match="/"> <HTML> <HEAD><TITLE>Authors</TITLE></HEAD> <BODY> <H 1>Composers from classical period</H 1> <TABLE BORDER="1"> <TR><TH>Name</TH></TR> <xsl: for-each select="/authors/author[@period='Classical']"> <TR><TD><xsl: value-of select="name" /> </TD></TR> </xsl: for-each> </TABLE> </BODY> </HTML> </xsl: template> </xsl: stylesheet>

Output Original XML Transformed XML

Output Original XML Transformed XML

P 2 P Example (link) <peer ip=“ 137. 189. 7”> <image name=“a. jpg”> <signature>15</signature>

P 2 P Example (link) <peer ip=“ 137. 189. 7”> <image name=“a. jpg”> <signature>15</signature> </image> <image name=“b. jpg”> <signature>20</signature> </image> <image name=“c. jpg”> <signature>13</signature> </image> <image name=“d. jpg”> <signature>5</signature> </image> </node>

XQuery (link) (xquery) <result> { FOR $i IN document(“index. xml")/peer/image WHERE $i/signature > “

XQuery (link) (xquery) <result> { FOR $i IN document(“index. xml")/peer/image WHERE $i/signature > “ 10” AND $i/signature < “ 16” RETURN $i } </result> > sample –f index. xml –a index. xml –q query. xqu <result> <image filename="a. jpg"> <signature>15</signature> </image> <image filename="c. jpg"> <signature>13</signature> </image> </result>

Illustration XQuery Validating parser DTD/ schema XML XQuery engine XML Browser XSL Assist XPath

Illustration XQuery Validating parser DTD/ schema XML XQuery engine XML Browser XSL Assist XPath XML/ text/ HTML

Possible Application XML index file XQuery Web/ Gnutella gateway XML Web XML index file

Possible Application XML index file XQuery Web/ Gnutella gateway XML Web XML index file XQuery XML index file P 2 P Other P 2 P client Other presentation method