Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
HIERARCHICAL SCHEMA
XML FILE:
<book>
<bookid> 1000</bookid>
<bookname>XML & Web services</bookname>
<authorname>Frankle</authorname>
<publication>O'Reilly</publication>
<year>2004</year>
<price> 750</price>
<noofcopies> 100 </noofcopies>
</book>
<book>
<bookid> 1001</bookid>
<bookname>Java Programming</bookname>
<authorname>Herbert schildt</authorname>
<publication>Mc-Graw Hill</publication>
<year>2005</year>
<price> 920 </price>
<noofcopies> 90 </noofcopies>
</book>
<cd>
<cdno> 2000 </cdno>
<cdcomp> Sony </cdcomp>
<cdtype> Mini CD </cdtype>
<price> 60 </price>
<noofcopies> 75 </noofcopies>
<year>2007</year>
</cd>
<cd>
<cdno> 2001 </cdno>
<cdcomp> Moserbear </cdcomp>
<cdtype> Max CD </cdtype>
<price> 75 </price>
<noofcopies> 90 </noofcopies>
<year> 2009</year>
</cd>
</catalog>
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
SCHEMA FILE:
<xs:element name="catalog">
<xs:complexType>
<xs:sequence>
<xs:element name="book" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="bookid">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:minExclusive value="999"> </xs:minExclusive>
<xs:maxExclusive value="10000"> </xs:maxExclusive>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="bookname">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Java Programming"/>
<xs:enumeration value="XML & Web services"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="year">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:pattern value="[0-9]{4}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="price">
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:minInclusive value="500"/>
<xs:maxInclusive value="1000"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="noofcopies">
<xs:simpleType>
<xs:restriction base="xs:byte">
<xs:enumeration value="100"/>
<xs:enumeration value="90"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="cdcomp">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value=" Moserbear "/>
<xs:enumeration value=" Sony "/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="cdtype">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value=" Max CD "/>
<xs:enumeration value=" Mini CD "/>
</xs:restriction>
</xs:simpleType>
</xs:element>
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<xs:element name="price">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="600"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="noofcopies">
<xs:simpleType>
<xs:restriction base="xs:byte">
<xs:enumeration value="75"/>
<xs:enumeration value="90"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="year">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:pattern value="[0-9]{4}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
GENERIC SCHEMA
XML FILE:
</book>
<cd>
<cdno> 2000 </cdno>
<cdcomp> Sony </cdcomp>
<cdtype> Mini CD </cdtype>
<price> 60 </price>
<noofcopies> 75 </noofcopies>
<year> 2008</year>
</cd>
<cd>
<cdno> 2001 </cdno>
<cdcomp> Moserbear </cdcomp>
<cdtype> Max CD </cdtype>
<price> 75 </price>
<noofcopies> 90 </noofcopies>
<year> 2009</year>
</cd>
</catalog>
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
SCHEMA FILE:
<xs:element name="authorname">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Frankle"/>
<xs:enumeration value="Herbert schildt"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="publication">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Mc-Graw Hill"/>
<xs:enumeration value="O'Reilly"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:simpleType name="printYear">
<xs:restriction base="xs:int">
<xs:pattern value="[0-9]{4}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="priceType">
<xs:restriction base="xs:int">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="1000"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="noofcopies">
<xs:simpleType>
<xs:restriction base="xs:byte">
<xs:enumeration value="100"/>
<xs:enumeration value="75"/>
<xs:enumeration value="90"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="catalog">
<xs:complexType>
<xs:sequence>
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<xs:element name="bookname">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Java Programming"/>
<xs:enumeration value="XML & Web services"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element ref="authorname"/>
<xs:element ref="publication"/>
<xs:element name="year" type="printYear"/>
<xs:element name="price" type="priceType"/>
<xs:element ref="noofcopies"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="cdcomp">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value=" Moserbear "/>
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<xs:element name="cdtype">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value=" Max CD "/>
<xs:enumeration value=" Mini CD "/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element ref="noofcopies"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<!DOCTYPE catalog [
<!ELEMENT catalog (book*,cd)>
<!ELEMENT book (bookid, bookname,authorname,publication, year,
comment)>
<!ATTLIST book
material CDATA #FIXED "paper"
style (paperback | hardcover) #IMPLIED>
<catalog>
<year>2007</year>
<comment> ®Cust; </comment>
</book>
<cd>
<cdno> 2000 </cdno>
<cdcomp> Sony </cdcomp>
<cdtype> Mini CD </cdtype>
<price> 60 </price>
<noofcopies> 75 </noofcopies>
</cd>
</catalog>
XSLT
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/">
<html>
<body>
<table border="2“>
<tbody>
<tr>
<th>bookid</th>
<th>bookname</th>
<th>authorname</th>
<th>publication</th>
<th>year</th>
<th>comment</th>
</tr>
<xsl:for-each select="//book">
<tr>
<td><xsl:value-of select="./bookid"></xsl:value-of></td>
<td><xsl:value-of select="./bookname"></xsl:value-of></td>
<td><xsl:value-of select="./authorname"></xsl:value-of></td>
<td><xsl:value-of select="./publication"></xsl:value-of></td>
<xsl:apply-templates select="year"/>
<td><xsl:value-of select="./comment"></xsl:value-of></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="year[.>2007]">
<td>
<font color="red">
<xsl:value-of select="."/>
</font>
</td>
</xsl:template>
<xsl:template match="year">
<td>
<font color="blue">
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<xsl:value-of select="."/>
</font>
</td>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
Orders.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="invoice4.xsl"?>
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<orders>
<order>
<orderno>101</orderno>
<supplyid>1</supplyid>
<orderdate>2 april 07</orderdate>
</order>
<order>
<orderno>102</orderno>
<supplyid>2</supplyid>
<orderdate>12 may 07</orderdate>
</order>
</orders>
Suppliers.xml
<?xml version="1.0"?>
<suppliers>
<supply>
<supplyid>1</supplyid>
<supplyname>Martin</supplyname>
<supplyaddress>Benz park</supplyaddress>
</supply>
<supply>
<supplyid>2</supplyid>
<supplyname>Smith</supplyname>
<supplyaddress>von Mouston</supplyaddress>
</supply>
</suppliers>
Order_details.xml
<?xml version="1.0"?>
<order_details>
<list>
<orderno>101</orderno>
<itemno>11</itemno>
<quantity>6</quantity>
</list>
<list>
<orderno>101</orderno>
<itemno>12</itemno>
<quantity>7</quantity>
</list>
<list>
<orderno>101</orderno>
<itemno>13</itemno>
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<quantity>6</quantity>
</list>
<list>
<orderno>101</orderno>
<itemno>14</itemno>
<quantity>5</quantity>
</list>
<list>
<orderno>102</orderno>
<itemno>21</itemno>
<quantity>16</quantity>
</list>
<list>
<orderno>102</orderno>
<itemno>22</itemno>
<quantity>15</quantity>
</list>
</order_details>
Items.xml
<?xml version="1.0"?>
<items>
<item>
<itemno>11</itemno>
<itemname>TATA TEA</itemname>
<itemrate>65</itemrate>
</item>
<item>
<itemno>12</itemno>
<itemname>TATA HONEY</itemname>
<itemrate>35</itemrate>
</item>
<item>
<itemno>13</itemno>
<itemname>TATA SALT</itemname>
<itemrate>15</itemrate>
</item>
<item>
<itemno>14</itemno>
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<itemname>TATA TYRES</itemname>
<itemrate>35</itemrate>
</item>
<item>
<itemno>21</itemno>
<itemname>WIPRO HONEY</itemname>
<itemrate>75</itemrate>
</item>
<item>
<itemno>22</itemno>
<itemname>WIPRO JAM</itemname>
<itemrate>63</itemrate>
</item>
</items>
Invoice.xsl
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<xsl:value-of select="supplyid"/>
</xsl:variable>
<tr>
<td width="152"><span class="style2"><strong>ORDER
NO</strong>:</span><xsl:value-of select="orderno"/></td>
<td width="232"><span class="style3"><strong>ORDER
DATE</strong>:</span><xsl:value-of select="orderdate"/></td>
</tr>
<tr></tr>
<tr>
<td><span class="style4"><strong>SUPPLY ID</strong>:</span><xsl:value-
of select="supplyid"/></td>
<xsl:for-each select="document('suppliers.xml')//supply[supplyid=$id]">
<td><span class="style4"><strong>SUPPLIER NAME:</strong></span>
<xsl:value-of select="./supplyname"/></td>
<td width="277"><span class="style4"><strong>SUPPLIER
ADDRESS</strong>:</span><xsl:value-of select="./supplyaddress"/></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
<p></p>
<table border="2" align="center">
<tr bgcolor="#99FFFF">
<th><div align="center">ITEM NO</div></th>
<xsl:for-each select="document('order_details.xml')//list[orderno=101]">
<xsl:variable name="ino">
<xsl:value-of select=".//itemno"/> </xsl:variable>
<tr><td><xsl:value-of select=".//itemno"/></td>
<xsl:for-each select="document('items.xml')//item[itemno=$ino]">
<td><xsl:value-of select="./itemname"/></td>
<xsl:variable name="ra">
<xsl:value-of select="./itemrate"/> </xsl:variable>
<td><span class="style5"><xsl:value-of
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
select="./itemrate"/></span></td>
<xsl:for-each select="document('order_details.xml')//list[itemno=$ino]">
<xsl:variable name="qu">
<xsl:value-of select=".//quantity"/> </xsl:variable>
<td><span class="style6"><xsl:value-of select=".//quantity"/></span></td>
OUTPUT:
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
Student.xml
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<?xml version="1.0"?>
<studinfo>
<student>
<sid>101</sid>
<sname>
<first>Tommy</first>
<last>Hilbunger</last>
</sname>
<dob>
<date>24</date>
<month>April</month>
<year>1986</year>
</dob>
<sex>male</sex>
<dept>computer</dept>
<address>
<street>432 Clay</street>
<city>Houston</city>
<state>TX</state>
<zip>77004</zip>
</address>
<parent>
<father>George</father>
<mother>Mary</mother>
</parent>
<phno>9991112220</phno>
<email>tommy@gmail.com</email>
</student>
<student>
<sid>102</sid>
<sname>
<first>John</first>
<last>Martin</last>
</sname>
<dob>
<date>09</date>
<month>Sept</month>
<year>1987</year>
</dob>
<sex>male</sex>
<dept>computer</dept>
<address>
<street>15A bridge</street>
<city>London</city>
<state>TX</state>
<zip>77032</zip>
</address>
<parent>
<father>Kelvin</father>
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<mother>Rose</mother>
</parent>
<phno>9767879900</phno>
<email>jmartin@gmail.com</email>
</student>
<student>
<sid>103</sid>
<sname>
<first>Gold</first>
<last>Smith</last>
</sname>
<dob>
<date>31</date>
<month>July</month>
<year>1986</year>
</dob>
<sex>male</sex>
<dept>computer</dept>
<address>
<street>38 pigeon</street>
<city>MaxStreet</city>
<state>TX</state>
<zip>77126</zip>
</address>
<parent>
<father>Ron</father>
<mother>Diane</mother>
</parent>
<phno>9635897024</phno>
<email>gsmithron@gmail.com</email>
</student>
</studinfo>
SAXDemo.java
import java.io.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import javax.xml.parsers.*;
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
{
System.out.println("****END OF THE XML FILE****");
}
OUTPUT:
E:\xml&webservices>path=c:\jdk1.5.0_01\bin
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
E:\xml&webservices>set classpath=%classpath%;.;
E:\xml&webservices>javac SAXDemo.java
<sid>101
</sid>
<sname>
<first>Tommy
</first>
<last>Hilbunger
</last>
</sname>
<dob>
<date>24
</date>
<month>April
</month>
<year>1986
</year>
</dob>
<sex>male
</sex>
<dept>computer
</dept>
<address>
<street>432 Clay
</street>
<city>Houston
</city>
<state>TX
</state>
<zip>77004
</zip>
</address>
<parent>
<father>George
</father>
<mother>Mary
</mother>
</parent>
<phno>9991112220
</phno>
<email>tommy@gmail.com
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
</email>
</student>
<student>
<sid>102
</sid>
<sname>
<first>John
</first>
<last>Martin
</last>
</sname>
<dob>
<date>09
</date>
<month>Sept
</month>
<year>1987
</year>
</dob>
<sex>male
</sex>
<dept>computer
</dept>
<address>
<street>15A bridge
</street>
<city>London
</city>
<state>TX
</state>
<zip>77032
</zip>
</address>
<parent>
<father>Kelvin
</father>
<mother>Rose
</mother>
</parent>
<phno>9767879900
</phno>
<email>jmartin@gmail.com
</email>
</student>
<student>
<sid>103
</sid>
<sname>
01107903054
ANNA UNIVERSITY TIRUCHIRAPPALLI
<first>Gold
</first>
<last>Smith
</last>
</sname>
<dob>
<date>31
</date>
<month>July
</month>
<year>1986
</year>
</dob>
<sex>male
</sex>
<dept>computer
</dept>
<address>
<street>38 pigeon
</street>
<city>MaxStreet
</city>
<state>TX
</state>
<zip>77126
</zip>
</address>
<parent>
<father>Ron
</father>
<mother>Diane
</mother>
</parent>
<phno>9635897024
</phno>
<email>gsmithron@gmail.com
</email>
</student>
</studinfo>****END OF THE XML FILE****
01107903054