RE: [xsl] xsl:copy question

Subject: RE: [xsl] xsl:copy question
From: "" <ds5j@xxxxxxxxxx>
Date: Wed, 5 Feb 2003 12:19:34 -0500 (EST)
    I tested the same stylesheet in xalan j 2_3 and the atribute was not copied to the next element .  So it seems it was a bug.

    But even in the later version of xalan the attribute ocurring after the empty attribute still is not copied.

    It is like when the condition 'a*[.!=''] | node()'  is being matched(against the element with 3 atributes 'elementA att1='1' att2='' att3='5') it matches and copies the first attribute which is not empty but when it encounters the next attribute which is empty it jumps to the next node( due to the or clause)  instead of matching the non empty attribute after the empty attribute.  This leaves attributes in the same node ocurring after an empty attribute not copied.

Is this also a bug or is this how xslt is supposed to work?  thanks

 --- On Fri 01/24,  < ds5j@xxxxxxxxxx > wrote:
From:  [mailto: ds5j@xxxxxxxxxx]
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 24 Jan 2003 21:31:32 -0500
Subject: RE: [xsl] xsl:copy question

Somehow the xsl in my email did not make it to the post.  So I have written some pseudo code this time.  Please see below

WHile using xalan I notice when a deep copy is done empty attributes are not copied.  

But when shallow copies are done empty attributes get copied.  To address the fact that empty attributes were being copied I had to fix the traditional code tp have an attribute not equal to empty test.

Does anyone why this happens as well?


   While editing a copy stylesheet to copy everything except empty attributes I came across some weird results.

   I got th stylesheet to work but did not understand why some attributes were being copied to the next node.


xsl:template match='@*[.!='']|node()'
xsl:apply-templates match='@*'

The problem ocurred with following input:
'elementA att1='1' att2='' att3='5'

Output was:
elementA att1='1' 
elementB had att3='5'

Somehow the stylesheet was copying until it encountered an empty attributed and then it went to the next node and copied the rest of the attributes from the previous node into the next node.

I fixed the stylsheet but would like to understand what was going on and why I go weird results.

My fix was :

xsl:template match='@*|node()'
xsl:apply-templates match='@*[.!='']'

I just would to undersrand what was happening , I'm sure the original code was buggy but what was wrong with it?



Join Excite! -
The most personalized portal on the Web!

 XSL-List info and archive:

<font size=2 face=geneva><b>Join Excite! - <a href= target=_blank></a></b>
The most personalized portal on the Web!</font>

Join Excite! -
The most personalized portal on the Web!

 XSL-List info and archive:

Current Thread