Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - xslt not working when xml has xmlns="urn" in root element. [Thread Next] Re: xslt not working when xml has xmlns="urn" in root element.To: NULL Date: 4/4/2007 12:54:00 AM
On Apr 3, 9:09 pm, "Lee" <lee.jenkins...@gmail.com> wrote:
> <?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:aprodshttp://api.shopping.yahoo.com/shoppingservice/v2/aproductsearch.xsd">
> ..................
> </ProductSearch>
>
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output 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>
Using tabs or 8 spaces for indentation on the usenet is not
particularly wise.
> 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.
What did you expect? ProductSearch element in the XML
document you've provided is really
{urn:yahoo:aprods}ProductSearch, and you're selecting
{}ProductSearch elements in your for-each. Consider reading
some introductory material on XML Namespaces overall and on
using XML Namespaces in XSL Transformations in particular.
--
Pavel Lepin
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
