[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Only child test

Subject: Re: [xsl] Only child test
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Oct 2013 00:45:00 -0400

At 2013-10-09 21:38 -0700, you wrote:
Just curious how other's might approach a test to determine if the
current node is *not* an only child. This works fine but it feels a
little heavy to me.  Thoughts?

                <xsl:if test="(count(preceding-sibling::*) +
count(following-sibling::*)) &gt; 1">

I think you need "... >0" in your test above to know that the current element has no siblings.

But if you know your current node is an element you could ask:


... which would return true if the current element is not an only child element.

I hope this helps.

. . . . . . Ken

-- Public XSLT, XSL-FO, UBL & code list classes: Melbourne, AU May 2014 | Contact us for world-wide XML consulting and instructor-led training | Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm | Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ | G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx | Google+ profile: https://plus.google.com/116832879756988317389/about | Legal business disclaimers: http://www.CraneSoftwrights.com/legal |

Current Thread