This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Repost: How to make namespace declarations all global (i.e. in root element)
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 8 Aug 2002 17:45:48 +0100
- Subject: RE: [xsl] Repost: How to make namespace declarations all global (i.e. in root element)
- Reply-to: xsl-list at lists dot mulberrytech dot com
You can get a namespace node onto an element that doesn't actually need
it by copying the namespace node from another document.
<xsl:element name="rootElement">
<xsl:copy-of select="//namespace::[.='http:www.example.com/foo']"/>
This is defined in an erratum to XSLT 1.0.
In XSLT 2.0 there is an <xsl:namespace> instruction to achieve this
effect.
I would be interested to know why your receiving application expects to
find a namespace declaration on an element that doesn't need it.
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of Wes Kubo
> Sent: 08 August 2002 16:43
> To: Xsl-List
> Subject: [xsl] Repost: How to make namespace declarations all
> global (i.e. in root element)
>
>
> Warning: repost follows. Can anyone at least let me know if
> this is possible or not?
> --------------------------------------------------------------
> --------------
> --------
>
> Hello all.
>
> First posting...checked all the archives and FAQ's but
> couldn't find an answer to this (though it was probably in
> there somewhere). I have a stylesheet that creates an output
> document that has elements in multiple namespaces. I want the
> result to be of this form:
>
> <rootElement xmlns="http://www.example.com/bar"
> xmlns:foo="http:www.example.com/foo>
> <foo:fooElement1>foo1</fooElement>
> <foo:fooElement2>foo2</fooElement>
> </rootElement>
>
> but this is what I get:
>
> <rootElement xmlns:bar="http://www.example.com/bar" >
> <foo:fooElement1
> xmlns:foo="http:www.example.com/foo>foo1</fooElement>
> <foo:fooElement2
> xmlns:foo="http:www.example.com/foo>foo2</fooElement>
> </rootElement>
>
> While I realilze that both forms are of course valid, the
> program that uses the output document expects to see the foo
> namespace declaration in the root element (i.e. globally
> accessible throughout the document).
>
> Is there anyway to force the foo namespace declaration to
> appear in the root element so that it is available globally?
>
> From what I've read my impression is no, but I welcome any
> advice. Btw, I'm using MSXML 4.0, not sure whether the choice
> of processor matters or not.
>
> Thanks.
>
> Wes
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list