Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

XML:Creating XML Document Using XSL (For-Each)

Friday, 24 February 2012
Step 1:
First Create XML File And Name It As Fourth.XML
<?xml version="1.0" encoding="utf-8"?>
<?xml:stylesheet type="text/xsl" href="Fourth.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 Fourth.xsl
<?xml version="1.0" encoding="utf-8"?>

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

<?xml version="1.0" encoding="utf-8"?>

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

<xsl:template match="/">
    <xsl:for-each select="PRODUCTDATA/PRODUCT">
        <xsl:sort select="PRODUCTNAME" data-type="text" order="ascending"/>
    PRODUCT NAME:<xsl:value-of select="PRODUCTNAME"/><BR/>
    DESCRIPTION:<xsl:value-of select="DESCRIPTION"/><BR/>
    PRICE:<xsl:value-of select="PRICE"/><BR/>
    QUANTITY:<xsl:value-of select="QUANTITY"/><BR/>
    <html>
    <body>
    <!--
        This is an XSLT template file. Fill in this area with the
        XSL elements which will transform your XML to XHTML.
    -->
    </body>
    </html>
    </xsl:for-each>
</xsl:template>

</xsl:stylesheet>






XML:Creating XML Document Using XSL

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>



XML:Creating XML Document Using CSS

Step 1:
First Create XML File And Name It As Second.XML
<?xml version="1.0" encoding="utf-8"?>
<?xml:stylesheet type="text/css" href="Second.css"?>
<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 Second.css
PRODUCTNAME
{
font-family=Arial;
font-size=20pt;
font-weight:bold;
color:red;
display:block;
padding-top:6pt;
padding-bottom:6pt;
}



Price,Description,Quantity
{
font-family=Arial;
font-size=20pt;
color:teal;
display:block;
padding-top:2pt;
padding-bottom:2pt;
}

XML:Simple XML File

<?xml version="1.0" encoding="utf-8"?>
<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>