Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
XML
This XSLT problem makes no sense to me
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Jean-François Michaud, post: 3475556"] Context: I'm trying to compare XML tree fragments and I'm doing so by outputting the attributes of each element in the tree and outputting it to a string then normalizing the strings. Then I'm doing a contains of the current string against the following-sibling::* to determine if we have duplicates. If we have a duplicate, we move to the next item, if there is no duplicate, we output the small tree. I'm hitting a completely ridiculous problem that I can't wrap my head around. I spend easily 2 hours trying to understand why this happened yesterday and I'm about to punch the computer. When I output a string that's not directly tied to the logic (or at least apparently not tied to the logic), the logic works. When I remove the string output, the logic stops working. Argh! Here's the XSLT snippet <xsl:template match="item-wrapper" mode="string"> <xsl:variable name="current"> <xsl:apply-templates mode="string" /> </xsl:variable> <xsl:variable name="rest"> <xsl:apply-templates select="following-sibling::*" mode="string" /> </xsl:variable> <xsl:variable name="current-normalized"> <xsl:value-of select="normalize-space($current)" /> </xsl:variable> <xsl:variable name="rest-normalized"> <xsl:value-of select="normalize-space($rest)" /> </xsl:variable> <!-- <fix/> What the hell? --> <!-- <xsl:value-of select="$current-normalized"/>--> <xsl:choose> <xsl:when test="contains($rest-normalized, $current- normalized)"> <duplicate/> </xsl:when> <xsl:otherwise> <noproblem/> </xsl:otherwise> </xsl:choose> </xsl:template> When <xsl:value-of select="$current-normalized"/> is not commented out, I get the string representation of the XML tree in a normalized form in the output for each item and the correct <duplicate/> and <noproblem/> get outputted in the correct location after the normalized strings. When I comment out the <xsl:value-of select="$current-normalized"/>, the normalized current string, as expected, stops being outputted, but all my outputs are <noproblem/>. What the hell? What am I missing here? Regards Jean-Francois Michaud [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
XML
This XSLT problem makes no sense to me
Top