[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: a weird bug today, tree seems to change mid transf

Subject: Re: a weird bug today, tree seems to change mid transform
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Sat, 08 Sep 2007 16:33:34 +0200
Re:  a weird bug today
Abel Braaksma wrote:
bryan rasmussen wrote:
I don't have access to the code that is doing it, but it
seems evident that somehow it is tampering with the DOM during the
transform.


Just thinking out loud here, but what happens if you do a copy-preprocessing and then re-apply the templates to the msxml:nodeset of the result? That way you force your XSLT to operate on a copy of the input object and there can be no tampering in-between anymore:


<xsl:template match="/">
   <xsl:variable name="copy">
      <xsl:apply-templates mode="copy" />
   </xsl:variable>
   <xsl:apply-templates select="msxml:nodeset($copy)" />
</xsl:template>

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

<xsl:template match="*" mode="copy">
<xsl:copy>
<xsl:attribute name="original-id"><xsl:value-of select="generate-id()" /></xsl:attrribute>
<xsl:apply-templates select="node() | @*" mode="copy" />
</xsl:copy>
</xsl:template>


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

<xsl:template match="*" >
<xsl:copy>
<xsl:attribute name="new-id"><xsl:value-of select="generate-id()" /></xsl:attrribute>
<xsl:apply-templates select="node() | @*" mode="copy" />
</xsl:copy>
</xsl:template>



<xsl:template match="x">
<xsl:copy>
<xsl:attribute name="new-id"><xsl:value-of select="generate-id()" /></xsl:attrribute>
<xsl:variable .... do your thing with @x />
... do some more with x here ...


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



Now your output should also contain, on each node, the attributes "original-id" and "new-id". These should be *different* for each and every node!!! You may take this step even a bit further to see if attributes are treated differently:

<xsl:template match="*">
   <xsl:for-each select="@*">
      <xsl:copy />
      <xsl:attribute name="{concat('id-of-attr-', name())}" />
   </xsl:for-each>
</xsl:template>

do the same for the copy mode. It will get quite messy, but you will get some insight in what is going on under the hood.... (meaning: you will get insight when generated ids are equal and you know it is an MS bug, you won't get insight if all ids are different as they should be).

Hopefully, the copy trick, which is an easy workaround, can be applied to all your stylesheets, if it indeed works. It is bad, but not that bad as a hack per issue (like your following-sibling trick).

Cheers,
-- Abel Braaksma

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.