Weird Math
This is an open discussion with 1 reply, filed under General.
Search
Err… here, I fixed it:
<xsl:template name="page-in-lineage"> <xsl:param name="test-id" select="''" /> <xsl:param name="ancestor-id" select="''" /> <xsl:param name="current-node" select="//page[@id = $ancestor-id]" /> <xsl:param name="parent-node" select="$current-node/parent::page" /> <xsl:choose> <xsl:when test="$current-node/@id = $test-id">yes</xsl:when> <xsl:otherwise> <xsl:if test="$parent-node"> <xsl:call-template name="page-in-lineage"> <xsl:with-param name="ancestor-id" select="$parent-node/@id" /> <xsl:with-param name="test-id" select="$test-id" /> </xsl:call-template> </xsl:if> </xsl:otherwise> </xsl:choose> </xsl:template>
Create an account or sign in to comment.
$current-node/@id = $test-id
will betrue
even though<xsl:value-of select="concat( $current-node/@id, ' = ', $test-id, ' = ' )" /><xsl:value-of select="$current-node/@id = $test-id" />
will output3 = 4 = true
What I’m attempting to do here is look at the
@id
of a givenpage
element and see if it matches with$test-id
. If it doesn’t and thepage
element has a parentpage
node we recurse substituting the parent for the$current-node
.Here’s the code as it stands right now…