5 users online. Create an account or sign in to join them.Users
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-idwill betrueeven though<xsl:value-of select="concat( $current-node/@id, ' = ', $test-id, ' = ' )" /><xsl:value-of select="$current-node/@id = $test-id" />will output3 = 4 = trueWhat I’m attempting to do here is look at the
@idof a givenpageelement and see if it matches with$test-id. If it doesn’t and thepageelement has a parentpagenode we recurse substituting the parent for the$current-node.Here’s the code as it stands right now…
<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="//page[@id = $ancestor-id]/../../page" /> <p><xsl:value-of select="concat( $current-node/@id, ' = ', $test-id, ' = ' )" /><xsl:value-of select="$current-node/@id = $test-id" /></p> <xsl:choose> <xsl:when test="$current-node/@id = $test-id">yes, even though <xsl:value-of select="concat( $current-node/@id, ' = ', $test-id, ' = ' )" /><xsl:value-of select="$current-node/@id = $test-id" /></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>