crazyboybert
Programmer
Hi All
I'm writing an XSLT to transform some XHTML content from an RSS feed to the markup I want to use in a website. I'm encoutnering a problem matching elements with an xmlns attribute. Heres an example..
XML
XSL
When transforming the XML file using the stylesheet shown I would only expect the output to be...
some markup
what actually outputs is...
some markupsome more markup
This is because the body element does not get captured by the template match due to the xmlns attribute. I did some playing around in XMLSPY and found the following matches/failures for XPATH expressions
xpath: body
This matches the following
<body>
<body attribute="value">
but does not match
<body xmlns="value">
xpath: body[attribute]
This only matches
<body attribute="value">
xpath: body[xmlns]
This doesn't seem to match any body elements.
It seems like you can't write an xpath expression to match an element with an xmlns attribute. Whats goign on here, am i missing something fundamental? I've googled for answers and come up empty handed!
Thanks in advance
Rob
Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
I'm writing an XSLT to transform some XHTML content from an RSS feed to the markup I want to use in a website. I'm encoutnering a problem matching elements with an xmlns attribute. Heres an example..
XML
Code:
<item>
<title>title</title>
<link>link</link>
<category>category</category>
<pubDate>Wed, 01 Sep 2004 12:20:00 GMT</pubDate>
<description>description</description>
<body xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<h4>some markup</h4>
<p>some more markup</p>
</body>
<guid isPermaLink="false">someguid</guid>
</item>
XSL
Code:
<xsl:template match="/item"><xsl:apply-templates /></xsl:template>
<xsl:template match="title" />
<xsl:template match="link" />
<xsl:template match="category" />
<xsl:template match="pubDate" />
<xsl:template match="description" />
<xsl:template match="body">some markup</xsl:template>
<xsl:template match="guid" />
When transforming the XML file using the stylesheet shown I would only expect the output to be...
some markup
what actually outputs is...
some markupsome more markup
This is because the body element does not get captured by the template match due to the xmlns attribute. I did some playing around in XMLSPY and found the following matches/failures for XPATH expressions
xpath: body
This matches the following
<body>
<body attribute="value">
but does not match
<body xmlns="value">
xpath: body[attribute]
This only matches
<body attribute="value">
xpath: body[xmlns]
This doesn't seem to match any body elements.
It seems like you can't write an xpath expression to match an element with an xmlns attribute. Whats goign on here, am i missing something fundamental? I've googled for answers and come up empty handed!
Thanks in advance
Rob
Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927