Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] XML with Default Namespace

From: "Andrew Welch" <andrew.j.welch@--------->
To:
Date: 8/2/2007 8:20:00 AM
On 8/2/07, Karl Stubsjoen <kstubs@xxxxxxxxx> wrote:
> Ok, some progress, but I can't seem to get rid of the attribute, xmlns:o.
> In my identity copy, I am trying match on attribute o, like this:
>
>         <xsl:template match="@o" mode="transform"/>
>
> My node match looks like this:
>
> <xsl:template match="@* | node()" mode="transform">
> <xsl:copy>
> <xsl:apply-templates select="@*" mode="transform"/>
> <xsl:apply-templates select="node()" mode="transform"/>
> </xsl:copy>
> </xsl:template>
>
> My XSL decleration includes the exclude prefix for "o", but thinking
> that that is out of context, this just excludes prefixes that the xsl
> document would produce, correct?  Not prefixes associated with the
> source xml.

When you copy a node you copy it's namespace too - the two are bound
in stone and cannot be separated :)

exclude-result-prefixes will only exclude namespaces that aren't used
in the output (think about the "xs" namespace in 2.0) - it cannot
change the names of nodes that are copied to the output.... so if you
want to a have a node in the output with the same local-name as the
current node, then you need to create it:

<xsl:template match="*">
  <xsl:element name="{local-name()}">
    <xsl:apply-templates select="@*|node()"/>
  </xsl:element>
</xsl:template>

and for attributes:

<xsl:template match="@*">
	<xsl:attribute name="{local-name()}">
		<xsl:value-of select="."/>
	</xsl:attribute>
</xsl:template>


> Wow!  I feel like such a beginner when it comes to namespaces!

You're not alone, I think everyone struggles with them.  The Excel
worksheet XML doesn't exactly use them well either....


-- 
http://andrewjwelch.com


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent