[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] xsl:copy question


Subject: Re: [xsl] xsl:copy question
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Sun, 26 Jan 2003 13:45:53 +0100

Hi,

I don't know, why the first code didn't work. Probably there is a bug in your Xalan release.

The simplest solution is using the copy-template and add further templates for different behaviour:

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="@*[. = '']"/>

So for adding more special cases you don't need to modify the standard template, but you simply can add some more templates.

Regards,

Joerg

ds5j@xxxxxxxxxx wrote:
Hi, 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



Also:
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?

Hi,

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.

Example:

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




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

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:copy 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?


thanks

D.



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




Current Thread
  • [xsl] xsl:copy question
    • - Mon, 20 Jan 2003 16:04:19 -0500 (EST)
      • <Possible follow-ups>
      • - Fri, 24 Jan 2003 21:31:32 -0500 (EST)
        • Joerg Heinicke - Sun, 26 Jan 2003 13:45:53 +0100 <=
Keywords
xsl