Re: [xsl] I need to make sure that all namespace declarations get output to a particular element, not the document element

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 19:10:18 +0100
Hi Abel,

I didn't want to belabour the point, but I did want to clarify something for readers of the archive.

At 2007-03-22 15:38 +0100, Abel Braaksma wrote:
I did not mean that anything unexpected was happening there. I just wanted to make a point. Apparently, when you have an RLE like this:

<elem xmlns:test="urn:test">
    <test:xyz />

then, when serializing, Saxon leaves that RLE precisely as-is.

I was saying that this isn't a "Saxon" behaviour ... it is a result of your use of exclude-result-prefixes.

It does not move the namespace declaration to the first element that needs it,

It "needs" it on <elem> because that is where you put it and you didn't prune it off.

neither does it move it up the tree to the root (like you, I don't expect it too). However, once you add this namespace to the xsl:stylesheet (with exclude-result-prefixes), it does seem to do some cleanup

This is where I was saying that there is no "cleanup" going on ... the reason the declaration is on <test> is that you pruned it off of <elem> with the exclude-result-prefixes directive.

and move the namespace declaration down the tree to the moment where it is first needed.

No, it isn't "moved" ... it is just being declared at the first place where the namespace node is being found. The namespace node is not found on <elem> because of the result of being pruned.

I think this extra level of control is nice and will help the OP.

It isn't extra ... it is what is expected from the use of exclude-result-prefixes.

I don't think that I am saying something that is different from what you or David says, I only add that Saxon leaves the namespace declaration where it is on any RLE, even when it is not needed directly on that very RLE (unless you put that namespace to the xsl:stylesheet and/or when you add exclude-result-prefixes)

But what I think is different is that I am saying that this isn't a feature of Saxon to do so ... it is an expected result based on the presence of namespace nodes in the XPath data model for the stylesheet tree in the presence or absence of the exclude-result-prefixes directive.

Well, I was not the one in need of help, but thanks, it does clarify things.

My only objective in adding this comment is to underscore for archive readers the behaviour cited is not Saxon-specific but is a direct consequence of the directives added by the stylesheet writer and is what I would expect for all XSLT processors.

. . . . . . . . . . . . Ken

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.
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05
Legal business disclaimers:

Current Thread