Re: [xsl] Removing namespaces from source document (long)

Subject: Re: [xsl] Removing namespaces from source document (long)
From: "Christopher R. Maden" <crism@xxxxxxxxx>
Date: Sun, 07 Apr 2002 16:43:29 -0700
At 15:46 7/4/02, Stephen Ng wrote:
I have some (unused) namespace declarations in my source xml document that I
want to banish.

But if I do:

<xsl:template match="/">
  <xsl:apply-templates mode="copy"/>
</xsl:template>

plus her template, I get the same results:  bad-ns is still declared.  Am I
misunderstanding her example?

I think so. XSLT 1.0 §7.5 says:


The xsl:copy element provides an easy way of copying the current node. Instantiating the xsl:copy element creates a copy of the current node. The namespace nodes of the current node are automatically copied as well, but the attributes and children of the node are not automatically copied. The content of the xsl:copy element is a template for the attributes and children of the created node; the content is instantiated only for nodes of types that can have attributes or children (i.e. root nodes and element nodes).

So when you copy <root>, the namespace nodes for "good" and "bad" are copied along with it. Your later attempt is the right approach, though I'm as surprised as you that re-creating a namespaced element is this difficult. It really ought to be possible to copy a document using <xsl:element> and <xsl:attribute>, but that doesn't seem to be the case.


~Chris
--
Christopher R. Maden, Principal Consultant, crism consulting
DTDs/schemas - conversion - ebooks - publishing - Web - B2B - training
<URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4  5DFC AC52 F825 AFEC 58DA

Attachment: pgp00000.pgp
Description: PGP signature

Current Thread