Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm trying to figure out how to check if a node has children in xslt in 4.5 schema...
In this navigation xslt:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets "><xsl:output method="xml" omit-xml-declaration="yes" /><xsl:param name="currentPage"/><!-- Input the documenttype you want here --><xsl:variable name="level" select="2"/><xsl:template match="/"><!-- The fun starts here --> <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']"> <xsl:if test="$currentPage/@id = current()/@id or $currentPage/../@id = current()/@id or $currentPage/../../@id = current()/@id"> <!-- output navigation Title --> <a class="leftnavtitle" href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> <ul> <!-- 1st navigation items --> <xsl:for-each select="./child::* [@isDoc]"> <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"></xsl:if> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:if test="@id = $currentPage/@id"><xsl:attribute name="class">selected</xsl:attribute></xsl:if> <xsl:value-of select="@nodeName"/>a: <xsl:value-of select="count(./descendant/* [@isDoc])"/> </a> <!--output 2nd level nevigation items --> <xsl:if test="$currentPage/@id = current()/@id or $currentPage/../@id = current()/@id or $currentPage/../../@id = current()/@id"> <ul> <!--output 3rd level nevigation items --> <xsl:for-each select="./child::* [@isDoc]"> <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"></xsl:if> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:if test="@id = $currentPage/@id"><xsl:attribute name="class">selected</xsl:attribute></xsl:if> <xsl:value-of select="@nodeName"/>b: <xsl:value-of select="count(./descendant/* [@isDoc])"/> </a> </li> </xsl:for-each> </ul> </xsl:if> <!--end of 4th level children --> </li> </xsl:for-each> </ul> </xsl:if> </xsl:for-each></xsl:template></xsl:stylesheet>
This line always returns 0:
<xsl:value-of select="count(./descendant/* [@isDoc])"/>
appears to be this syntax:
count(current()/child::* [@isDoc]) > 0
Hi Rik,
You don't even need the "current()/child::" part, you can just use "*[@isDoc]". Also if you are testing this in an <xsl:if>, you don't need the count - the XPath with just evaluate the nodeset, like so...
<xsl:if test="*[@isDoc]"> ... </xsl:if>
Cheers, Lee.
Thanks Lee, i'll clean up some more ;)
Thanks Rik and Lee
That was just what I was looking for!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
how do i check if a node has children in 4.5 ?
I'm trying to figure out how to check if a node has children in xslt in 4.5 schema...
In this navigation xslt:
This line always returns 0:
appears to be this syntax:
count(current()/child::* [@isDoc]) > 0
Hi Rik,
You don't even need the "current()/child::" part, you can just use "*[@isDoc]". Also if you are testing this in an <xsl:if>, you don't need the count - the XPath with just evaluate the nodeset, like so...
Cheers, Lee.
Thanks Lee, i'll clean up some more ;)
Thanks Rik and Lee
That was just what I was looking for!
is working on a reply...