Subject: Re: [xsl] compare two nodes (the child elements, not the string values) in XSLT 1.0 From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Wed, 06 Jul 2011 16:45:39 -0400 |
<xsl:variable name="author-string"> <!-- generating an RTF containing a string --> <xsl:apply-templates select="$author" mode="string"/> </xsl:variable> <xsl:variable name="person-string"> <!-- again --> <xsl:apply-templates select="$person" mode="string"/> </xsl:variable> <xsl:if test="$author-string = $person-string"> ...
<xsl:template name="compare-person"> <xsl:param name="author" select="/.."/> <xsl:param name="person" select="."/> <xsl:variable name="author-string"> <xsl:apply-templates select="$author" mode="string"/> </xsl:variable> <xsl:variable name="person-string"> <xsl:apply-templates select="$person" mode="string"/> </xsl:variable> <xsl:if test="$author-string = $person-string"> TRUE </xsl:if> </xsl:template>
<xsl:template match="author"> <xsl:variable name="author" select="."/> <xsl:variable name="compare-result"> <xsl:for-each select="$persons"> <!-- generating an RTF containing a string, possibly including 'TRUE' --> <xsl:call-template name="compare-person"> <xsl:with-param name="author" select="$author"> </xsl:call-template> <xsl:for-each> </xsl:variable> <xsl:if test="contains($compare-result,'TRUE')"> ...
Cheers, Wendell
Am 06.07.2011 um 20:54 schrieb Wolfhart Totschnig:
I have a seemingly simple xslt problem to which I cannot find the solution. I want to test whether the context node, which is an<author> element with the form (first?, middle?, last), is equal to one of a set of<person> elements. By "equal" I mean having the same child elements and values of these elements. At first, I thought it would be as easy as
test="path/person = ."
But then I realized that the "=" operator compares the string values of the nodes
Wolfhart,
How about this (not very cool):
test="concat(path/person/first, '|', path/person/first, '|', path/person/first) = concat(first, '|', middle, '|', last)"
- Michael M|ller-Hillebrand
-- ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] compare two nodes (the ch, Wolfhart Totschnig | Thread | Re: [xsl] compare two nodes (the ch, Wolfhart Totschnig |
Re: [xsl] compare two nodes (the ch, Wolfhart Totschnig | Date | Re: [xsl] compare two nodes (the ch, Wolfhart Totschnig |
Month |