Hello,
I currently have to compare two nodelist to each other for differences.
I have in one XML file a structure 'before' and a structure 'after'. Let's
say a recipe and a variation of this recipe. I now need to pick out all
differences, for to mark them in my output report, like the diff command
does. If I found a difference I need to pick out some attributes and values
from this and it's child nodes.
this is my current [not working] idea:
<xsl:template name="recipe-compare">
<xsl:param name="pattern"/>
<xsl:param name="recipe"/>
<xsl:variable name="variation">
<xsl:for-each select="$pattern">
<xsl:variable name="current-findnumber"
select="./Attribute[(_at_)Name='FindNumber']/Value"/>
<xsl:variable name="compare-node">
<xsl:for-each select="$recipe">
<xsl:if test="./Attribute[(_at_)Name='FindNumber']/Value =
$current-findnumber">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:if test=". != $compare-node">
<xsl:copy-of select="."/>
<xsl:attribute name="different">current</xsl:attribute>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="$recipe">
<xsl:variable name="current-findnumber"
select="./Attribute[(_at_)Name='FindNumber']/Value"/>
<xsl:variable name="compare-node">
<xsl:for-each select="$pattern">
<xsl:if test="./Attribute[(_at_)Name='FindNumber']/Value =
$current-findnumber">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:if test=". != $compare-node">
<xsl:copy-of select="."/>
<xsl:attribute name="different">pattern</xsl:attribute>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="$variation">
<xsl:sort select="./Attribute[(_at_)Name='FindNumber']/Value"/>
<fo:table-row>
<xsl:choose>
<xsl:when test="@different = 'current'">
<fo:table-cell><fo:block><xsl:value-of
select="./object/Attribute[(_at_)Name='PartNumber']/Value"/></fo:block></fo:table-cell>
<fo:table-cell><fo:block>100</fo:block></fo:table-cell>
<fo:table-cell></fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell><fo:block><xsl:value-of
select="./object/Attribute[(_at_)Name='PartNumber']/Value"/></fo:block></fo:table-cell>
<fo:table-cell><fo:block>100</fo:block></fo:table-cell>
<fo:table-cell></fo:table-cell>
</xsl:otherwise>
</xsl:choose>
</fo:table-row>
</xsl:for-each>
</xsl:template>
Still learning... Any suggestion or correction highly appreciated...
Regards,
Kai
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--