Subject: Re: [xsl] I need to make sure that all namespace declarations get output to a particular element, not the document element|
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Mar 2007 15:23:34 +0100
David Carlisle wrote:Not sure if the processor is allowed to, I think it is, to cleanup the namespaces the way it likes and instead put the namespace decl. to 'test:other-ns-now' element.
That wouldn't be allowed, The XSLT1 output serialisation is allowed to move declarations up the tree, meaning a namespace is in scope earlier than one might expect, but it can never move a namespace declaration down the tree. If an element node in the result has a namespace node (even if that namespace is not used in any element or attribute) the namespace declaration must be serialised on the element or an ancestor.
How then, would you explain the behavior that in the following stylesheet, the namespace declaration created before it is used, but in the serialized output, it is placed on a descendant (namely the descendant that first uses the namespace)?
If I read your words correctly, this should not be allowed to happen, but it does:
which means, imo, that the declaration for the 'http://www.xyz.com' namespace, which is put on the RLE 'elem' is moved to an descendant,
This does not change the output in any way, except for the location of the namespace declaration. If I remove the exclude-result-prefixed, the namespace is put on 'root',
-- World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal