This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Getting rid of namespace attribute under SQL2000 XML output
- From: Francis Norton <francis at redrice dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 17 Apr 2002 19:49:51 +0100
- Subject: Re: [xsl] Getting rid of namespace attribute under SQL2000 XML output
- References: <MABBJMFEHKCHIPJGLHOKMEPJCJAA.xsl@alfega.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Francois,
Francois Rautenbach wrote:
>I subsequently discovered that IE5
>chokes on the -> xmlns:sql="urn:schemas-microsoft-com:xml-sql" <- attribute
>in the XML (see below). Remove this and data binding works perfectly.
>
Namespaces aren't just attributes for XML elements, they are in fact the
root categories by which elements are grouped.
To get rid of the namespace for an element in XSLT, you need to first
match it, then create another element with the same local-name but in a
different namespace or none at all.
This kind of thing is easily done using a filter type transform, where
you basically copy through, unchanged, everything except the bits you
want to alter.
The copy-through bit can be done using what the xslt spec refers to as
an "identity transform" -
Here's an example which might help your case:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes"/>
<!-- -->
<!-- the "identity" transform - passes stuff through unchanged -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- -->
<!-- for everything except elements in the target namespace -->
<xsl:template match="sql:*"
xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<!-- -->
</xsl:stylesheet>
Cheers -
Francis.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list