xsl-list
[Top] [All Lists]

Re: [xsl] Only child test

2013-10-09 23:45:19
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">
                    <hr/>
                </xsl:if>

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:

  test="count(../*)!=1"

... 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(_at_)CraneSoftwrights(_dot_)com 
|
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>