> [EMAIL PROTECTED] wrote:
> >>This appears to be covered by XALANJ-2032, so the following is 
> >>supplemental info.  The idea is to remove the namespace declarations 
> >>from the output root element using exclude-result-prefixes as 
specified 
> >>in the XSLT 1.0 spec Section 7.1.1.  This problem was produced by 
> >>XALAN-J 2.7.0.
> > 
> > 
> > exclude-result-prefixes only works for namespace declarations that are 
not 
> > required in the serialized result tree.  Also, it does not affect 
> > namespaces copied from the source tree using xsl:copy.
> 
> The conf: elements are "meta-elements" that are expanded by the 
> stylesheet.

I don't know what you mean by the term "meta-elements" -- that term is not 
used anywhere in the XSLT recommendation. 

When this template in your stylesheet is instantiated, you are creating 
element and text nodes in the results tree:

> <!-- Success criteria -->
> <xsl:template match="conf:pass">
>    <prompt>pass</prompt>
>    <exit/>
> </xsl:template>

The XSLT recommendation defines calls the "prompt" and "exit" elements 
literal result elements:

http://www.w3.org/TR/xslt#literal-result-element

Because you have a default namespace declaration in your stylesheet, the 
"prompt" and "exit" elements have a namespace URI of 
"http://www.testxsl.org/1999/ournamespace";.  When the result tree is 
serialized, the serializer will have to generate a namespace declaration 
for the default namespace when necessary.

> There are NO conf: elements in the result tree and as such, 
> the xmlns:conf declaration is not required at the root element of the 
> result tree.

It's not there because it's "required," it's there because your stylesheet 
copied it to the result tree through xsl:copy, which also copies any 
namespace nodes:

http://www.w3.org/TR/xslt#copying

"The xsl:copy element provides an easy way of copying the current node. 
Instantiating the xsl:copy element creates a copy of the current node. The 
namespace nodes of the current node are automatically copied as well, but 
the attributes and children of the node are not automatically copied."

> This was exactly what I was hoping exclude-result-prefixes 
> would eliminate, and it doesn't appear to.  It is harmless if the 
> default xlmns declaration is placed on the output root element since the 

> entire output tree is in a single (the default) namespace, but it would 
> be nice if exclude-result-prefixes="#default" actually had that effect, 
> as appears to be suggested by XSLT 1.0 7.1.1  xsl:copy is used in order 
> for the stylesheet to be insensitive to the elements of the input 
> document other than the conf: elements.

As I said previously, exclude-result-prefixes cannot exclude a namespace 
node that is required.  If it didn't copy the namespace node that binds 
the default namespace to "http://www.testxsl.org/1999/ournamespace,"; the 
names of the nodes created by the literal result elements would change.

> If you feel my argument has flaws, could you indicate how the desired 
> result can be achieved

<?xml version="1.0"?>
<xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
     xmlns:conf="http://www.testxsl.org/2005/conformance";
     exclude-result-prefixes="conf"
     version="1.0">

<xsl:output cdata-section-elements="script"/>

<!-- copy PIs -->
<xsl:template match="processing-instruction()">
   <xsl:copy/>
</xsl:template>

<!-- strip comments -->
<xsl:template match="comment()"/>

<!-- create an attribute, using only the local part of the
     expanded name of the matched attribute  -->
<xsl:template match="@*">
   <xsl:attribute name="{local-name()}">
     <xsl:value-of select="."/>
   </xsl:attribute>
</xsl:template>

<!-- create an element, using only the local part of the
     expanded name of the matched element  -->
<xsl:template match="*">
   <xsl:element name="{local-name()}" namespace="">
     <xsl:apply-templates select="@* | node()"/>
   </xsl:element>
</xsl:template>

<!-- Success criteria -->
<xsl:template match="conf:pass">
   <prompt>pass</prompt>
   <exit/>
</xsl:template>

<!-- Failure criteria -->
<xsl:template match="conf:fail">
   <prompt>fail</prompt>
   <exit/>
</xsl:template>

</xsl:stylesheet>

Dave

Reply via email to