XML:Creating XML Document Using XSL

Friday, 24 February 2012
Step 1:
First Create XML File And Name It As Third.XML
<?xml version="1.0" encoding="utf-8"?>
<?xml:stylesheet type="text/xsl" href="Third.xsl"?>
<PRODUCTDATA>
    <PRODUCT PRODID="P001"  CATEGORY="TOY">
        <PRODUCTNAME>Mini Bus</PRODUCTNAME>
        <DESCRIPTION>This is a toy for children aged 4 and above</DESCRIPTION>
        <PRICE>75</PRICE>
        <QUANTITY>54</QUANTITY>
    </PRODUCT>
<PRODUCT PRODID="P002"  CATEGORY="TOY">
        <PRODUCTNAME>Barbie Doll</PRODUCTNAME>
        <Description>This is a toy for children age group of 5-10</Description>
        <Price>20</Price>
        <Quantity>200</Quantity>
    </PRODUCT>
    </PRODUCTDATA>

Step 2:
Then Create CSS File And Name It As Third.xsl
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
    PRODUCT NAME:<xsl:value-of select="PRODUCTDATA/PRODUCT/PRODUCTNAME"/><BR/>
    DESCRIPTION:<xsl:value-of select="PRODUCTDATA/PRODUCT/DESCRIPTION"/><BR/>
    PRICE:<xsl:value-of select="PRODUCTDATA/PRODUCT/PRICE"/><BR/>
    QUANTITY:<xsl:value-of select="PRODUCTDATA/PRODUCT/QUANTITY"/><BR/>
 
</xsl:template>

</xsl:stylesheet>



0 comments:

Post a Comment