Generating namespace declarations given a result tree?

Subject: Generating namespace declarations given a result tree?
From: John-Paul Sicotte <jps@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 May 2000 16:04:26 -0600
Hi,

   I am currently doing some work on an xslt processor and have some questions
about the handling of namespaces that I was hoping someone on the list could
help with.  I understand how namespaces work in xml documents; my questions are
about how they are affected by the xslt transformations.

I have looked through the various namespace resources I have seen mentioned on
the list but found nothing. From searching through the xslt specification I
could only find a couple of types of namespace references.

1. Use of namespaces for resolving qnames (including default namespace particulars).
2. Construction of namespace nodes in the result tree (eg. from a literal
   result element or use of <xsl:element>)
3. The exclude-result-prefixes attribute.
4. The following note from the spec.

Section 16.1

NOTE: An XSLT processor may need to add namespace declarations in the course of
outputting the result tree as XML.

This seems clear for example if you use <xsl:element> to create an element with
a namespace not in the source tree.


So I think I understand how to build the result tree with the proper set of
namespace nodes and enough meta-data to handle qnames.

My question is when using the 'xml' output method how do I determine which
namespace declarations to output and does it matter how I choose prefixes.
Its obvious that you must have a namespace declaration for each namespace
actually occurring in the result tree.  But that leaves me with the following
questions:

1. Are you supposed to output a namespace declaration for each namespace node
   in the result tree, regardless of whether the namespace is actually used?
   Should we just retain the namespaces that were actually declared on the
   element (for instance if an xsl:copy is used on the source tree), or is
   there some minimization algorithm that should be used?

2. Does it matter what prefixes are used (this includes using the default namespace)?
3. Is there a convention on removing unused namespaces?

The above 2 items I don't see actually affecting the output semantics but they
will affect any meta langauges that make use of namespaces.  For eg an xpath
expression in an attribute value.

4. Are there any references in the xlst specification or other documents that
   anyone knows of that define the xslt processor behaviour in more detail.



				     Thanks
					John-Paul



----------------------
John-Paul Sicotte
Software Composer
MessagingDirect
mailto:John-Paul@xxxxxxxxxxxxxxxxxxx



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread