|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Ignore namespaces
Filipe:
> Now I want to use an XML document with namespaces in some of its
> elements but those namespaces should be ignored by the XSL and the
> elements processed as if no namespace existed.
>
> Is there an easy way to do this?
Jeni:
>Unfortunately not in XSLT 1.0. As far as XPath and XSLT are concerned,
>an element with a namespace is completely different from an element
>without a namespace. To change an XSLT 1.0 stylesheet from working
>over a source document without namespaces to one with, you have to
>change every XPath that refers to elements that now have a namespace,
>so that they include prefixes pointing to that namespace.
sorry to join thread half-way....
Is it not possible to do an indentity transform first to remove the
namespaces on the nodes, then apply the usual stylesheet?
This would require two passes, but it would cater for any namespace.
Something along the lines of:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node()">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
Is there anything wrong with this approach??
cheers
andrew
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.350 / Virus Database: 196 - Release Date: 17/04/2002
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








