RE: HELP! XT is putting namespaces in output tag attributes ...

Subject: RE: HELP! XT is putting namespaces in output tag attributes ...
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 28 Jan 2000 12:45:44 -0500
At 00/01/28 09:38 +0000, Kay Michael wrote:
> > <aTag2 xmlns=""></aTag2>
> >
> >  Why is it doing this ?

When you copy a literal result element to the result tree, all its namespace
nodes are copied too, unless you ask for them not to be. This is what's in
the spec, if you want to know why it's in the spec, don't ask me!

My understanding is as follows:

- if the processor chooses to serialize the result tree instantly, without keeping the entire tree in memory before it is complete, then the design of the language allows the processor to emit an element's start tag as soon as content for that element is defined
- if the processor waited until it came to a bunch of elements that needed a namespace declaration, and the container for those elements did not require a namespace declaration, then all the individual elements would require namespace declarations and you'd see a whole lot of declarations when only one on the container would suffice
- therefore, if the processor knows from the stylesheet there is a chance for the presence of namespaces in a document, then it can preemptively emit the namespace declarations once at the document element and cover the entire scope of the document
- since the start tag of the document element is long gone before the end of the document element is processed, the processor has no way of knowing, a priori, if any of the contingent namespace declarations will ever be needed throughout the document
- the safe way to cover the bases without affecting the parse of the result document downstream by other processes, and without potentially numerous declarations, is to emit a namespace declaration in the document element for every namespace for which literal result elements *might* be used
- the stylesheet writer can inform the processor of the likelihood of not needing a particular namespace declaration (perhaps for stylesheet documentation purposes) using exclude-result-prefixes= and the processor will then hold off emitting the namespace declaration until it absolutely positively needs one ... if the stylesheet writer was correct in their assertion one wasn't needed, then one never shows up

The caveat here is that I'm not a member of the committee, so I don't know what the committee thinks officially ... this is just my justification for the evidence I see.

I hope this helps.

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

G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.   
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999   (Fax:-0995)
Web site: XSL/XML/DSSSL/SGML services, training, libraries, products.
Practical Transformation Using XSLT and XPath      ISBN 1-894049-03-9
Next instructor-led training: 2000-02-27/28,2000-05-11/12,2000-05-15,
-                                    2000-06-12,2000-06-13,2001-01-27

XSL-List info and archive:

Current Thread