You are on page 1of 2

XML+XSD+XSL

Assignment NO:
Roll No:3165
XSD:
<?xml version="1.0"?>
<Schema name ="audiocollection"
xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml-datatypes">
<ElementType name ="title" content = "textOnly"/>
<ElementType name ="artist" content ="textOnly"/>
<ElementType name ="track" content ="textOnly"/>
<AttributeType name ="type" dt:type ="enumeration"
dt:value ="rock pop classical" default="rock"/>
<AttributeType name ="review" dt:type="enumeration"
dt:values="1 2 3 4" default="1"/>
<AttributeType name = "year" dt:type ="int"/>
<ElementType name = "audio" content ="eltOnly">
<elementType name = "title" minOccurs ="1" maxOccurs ="1"/>
<elementType name = "artist" minOccurs ="1" maxOccurs ="*"/>
<elementType name = "track" minOccurs="1" maxOccurs ="*"/>
<elementType name = "comments" minOccurs ="1" maxOccurs ="1"/>
<attributeType name="type"/>
<attributType name="review"/>
<attributeType name="year"/>
<ElementType name="audiocollection" content="eltOnly"/>
<ElemenType name="audio" minOccurs="1" maxOccurs="*"/>
</ElementType>
</Schema>
XSL:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<head>
<title>audiocollection</title>
</head>
<body bgcolor="pink">
<h2>Audiocollection</h2>
<xsl:for-each select="audiocollection/audio">
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="@year"/>
<xsl:apply-templates select="track"/>
<xsl:apply-templates select="comments"/>
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template match="title">
<b>Title : </b>
<i><xsl:value-of/></i>
</xsl:template>
<xsl:template match="@year">
<b>Year : </b>
<i><xsl:value-of/></i><br/>
</xsl:template>
<xsl:template match="artist">
<b>Artist : </b>
<i><xsl:value-of/></i><br/>
</xsl:template>
<xsl:template match="track">
<b>Track : </b>
<i><xsl:value-of/></i><br/>
</xsl:template>
<xsl:template match="comments">
<b>Comments : </b>
<i><xsl:value-of/></i><br/>
</xsl:template>

</xsl:stylesheet>
XML:
<?xml version="1.0"?>
<?xml-schema href="audio11.xsd" type="text/xsd"?>
<?xml-stylesheet href="audio1.xsl" type="text/xsl"?>
<audiocollection>
<audio type="pop" review="2" year="1998">
<title>Ghost</title>
<artist>MJ</artist>
<track>A</track>
<comments>Best</comments>
</audio>
<audio type="pop" review="2" year="1998">
<title>Linking Park</title>
<artist>LP</artist>
<track>A</track>
<comments>Best</comments>
</audio>
</audiocollection>

You might also like