Hello guys, I am new to XML and working on a XSLT to transforn yahoo shopping search result to html. my problem is the return XML contain xmlns in root element, here is the sample xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="aproductsearch.xslt"?> <ProductSearch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:aprods" xsi:schemaLocation="urn:yahoo:aprods http://api.shopping.yahoo.com/shoppingservice/v2/aproductsearch.xsd"> ...................
</ProductSearch>
I am testing my xslt file:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl
utput method="html" encoding="utf-8" omit-xml- declaration="yes" indent="yes"/>
<xsl:template match="/">
<HTML>
<BODY>
<TABLE BORDER="2">
<TR>
<TD>From</TD>
<TD>To</TD>
</TR>
<xsl:for-each select="ProductSearch/ Products/Product"> <TR> <TD> <xsl:value-of select="Catalog/PriceFrom"/> </TD> <TD> <xsl:value-of select="Catalog/PriceTo"/> </TD> </TR> </xsl:for-each> </TABLE> </BODY> </HTML> </xsl:template>
</xsl:stylesheet>
if I remove the xmlns="urn:yahoo:aprods" from the XML, then the xslt works fine, otherwise, nothing shows up. I don't know what is the problem of my xslt file.
Thanks a lot!
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="aproductsearch.xslt"?> <ProductSearch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:aprods" xsi:schemaLocation="urn:yahoo:aprods http://api.shopping.yahoo.com/shoppingservice/v2/aproductsearch.xsd"> ...................
</ProductSearch>
I am testing my xslt file:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl
<xsl:template match="/">
<HTML>
<BODY>
<TABLE BORDER="2">
<TR>
<TD>From</TD>
<TD>To</TD>
</TR>
<xsl:for-each select="ProductSearch/ Products/Product"> <TR> <TD> <xsl:value-of select="Catalog/PriceFrom"/> </TD> <TD> <xsl:value-of select="Catalog/PriceTo"/> </TD> </TR> </xsl:for-each> </TABLE> </BODY> </HTML> </xsl:template>
</xsl:stylesheet>
if I remove the xmlns="urn:yahoo:aprods" from the XML, then the xslt works fine, otherwise, nothing shows up. I don't know what is the problem of my xslt file.
Thanks a lot!