Re: [xsl] Q: XSLT 1.0 output of namespace

Subject: Re: [xsl] Q: XSLT 1.0 output of namespace
From: Lars Huttar <lars_huttar@xxxxxxx>
Date: Mon, 16 Aug 2010 11:08:29 -0500
On 8/16/2010 7:35 AM, Hermann Stamm-Wilbrandt wrote:
> Hello,
>
> this is a pure XSLT 1.0 question.
>
> Below template does the (readable) output of the current node even for
> attribute and namespace nodes.
> In the spec the following is stated:
>   "There is no pattern that can match a namespace node, ...".
>
> So I tried it with negative matches for node, pi, comment and text.
> But now the differentiation between namespace node and attribute node
> ( for output of  xnlns:ns1="..." / xmlns="..." / attr="..." )
> seems a bit complex to me.
>
> Can this be simplified?
>
>
>   <xsl:template match="@*">
>     attribute
>   </xsl:template>
>
>   <xsl:template name="doOutput">
>     <xsl:choose>
>       <!-- attribute could be matched, namespace not - handle both -->
>       <xsl:when test="not(node()|processing-instruction()|comment()|text
> ())">
>   

A question for my own edification....
The test above tests the child axis, correct?
So it is not testing whether the current node is a node/pi/comment/text
node, but whether the current node has such children. Right?
So an empty element would pass this not() test; in other words, an empty
element would be treated the same as an attribute or a namespace node.
It seems like that is not the intent... more likely the intent was to
test whether the current node is (not) an element or anything else
besides an attribute or a namespace node?

Also, the above test seems redundant, since anything matched by
"processing-instruction()|comment()|text()" will also be matched by
"node()".
I'm not saying this to be critical, but because I believe the OP is a
smart guy, and this area is a confusing one for me, I want to check my
own comprehension.

Thanks,
Lars

Current Thread