Project

Profile

Help

Redundancy check condition

Added by Anonymous about 20 years ago

Legacy ID: #2795411 Legacy Poster: Lawrence Michel, CH (arkean_forge)

Hi all, First, the code sample : (not copy-pasted) <xsl:for-each select="/allNodes"> <xsl:sort select="@nodeName"/> <xsl:if test="not(@nodeName=/following-sibling::*[position()=1]/@nodeName)"> < do this.... > </xsl:if> </xsl:for-each> The if condition check for each sorted node, whether it's name attribute might not be found in the following ones. This part of code works using xmlspy's xslt processor. But I'm unable to have it processed properly using saxon8... Any help would be greatful Cheers


Replies (3)

Please register to reply

RE: Redundancy check condition - Added by Anonymous about 20 years ago

Legacy ID: #2795448 Legacy Poster: Michael Kay (mhkay)

/allNodes selects an allNode element that is the outermost element of the document. There can only be one, so why use for-each? /following-sibling::* is even stranger: it selects elements that are following siblings of the document (root) node - and of course the root has no siblings. Let's suppose these "/"s are a typo and weren't really there. Then following-sibling::* refers to the element that immediately follows the allNodes element in the original source tree. Your code looks as if you might be under the impression that it is looking for the node that follows immediately in sorted order. This isn't the case: sorting changes the order in which the nodes are processed, but it doesn't affect the result of following the axes. Michael Kay

RE: Redundancy check condition - Added by Anonymous about 20 years ago

Legacy ID: #2795472 Legacy Poster: Lawrence Michel, CH (arkean_forge)

Hello :-) Maybe I should copy-paste directly the code : ... <xsl:result-document href="procXml.bat" format="bat"> <xsl:for-each select="/Classes/Class/SADefinition[contains(@SAObjName,'app_')]"> <xsl:sort select="@SAObjName"/> <xsl:if test="not(@SAObjName=/following-sibling::*[position()=1]/@SAObjName)"> <xsl:text>fop -fo </xsl:text> <xsl:value-of select="@SAObjName"/> <xsl:text>.fo -pdf </xsl:text> <xsl:value-of select="@SAObjName"/> <xsl:text>.pdf&#13;&#10;</xsl:text> </xsl:if> </xsl:for-each> </xsl:result-document> ... 1. It selects all /Classes/Class/SADefinition nodes where their @SAObjName attribute contains the 'app_' letters. ->ok 2. Its sorts the result tree according to th @SAObjName attributes ->ok 3. Because the XML Data contains redundancy SADefinition nodes, I need it to apply the following instructions only once per unique node (and not to its "twins"). Well... I hope the code won't appear too messy ;-)

RE: Redundancy check condition - Added by Anonymous about 20 years ago

Legacy ID: #2795612 Legacy Poster: Michael Kay (mhkay)

Well, as I said before, the /following-sibling is clearly wrong. If you're looking for XSLT programming advice, a better place to go is the xsl-list at www.mulberrytech.com. This forum is intended for Saxon-specific problems. Michael Kay

    (1-3/3)

    Please register to reply