Re: [xsl] XPath to Find All Siblings Except Self

Subject: Re: [xsl] XPath to Find All Siblings Except Self
From: Terry Badger <terry_badger@xxxxxxxxx>
Date: Thu, 15 Mar 2012 11:27:36 -0700 (PDT)
Rick,
Here is another one to try. It does work.
Terry<?xml version="1.0"
encoding="UTF-8"?>
<xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:xs="http
://www.w3.org/2001/XMLSchema"exclude-result-prefixes="xs"
version="2.0">
<xsl:outputmethod="xml"/>
<!-- turn off default templates -->
<xsl:templatematch="processing-instruction()|comment()|*|@*|text()"/>
<xsl:templatematch="/chapter">
<xsl:apply-templates/>
</xsl:template>
<xsl:templatematch="section[@level='1']">
<xsl:variablename="all-level-2-sections"select="."/>
<xsl:for-eachselect="section">
<xsl:text>&#x0A;SECTION IS </xsl:text>
<xsl:value-ofselect="title"/>
<xsl:for-eachselect="$all-level-2-sections/self::section/section[not(generate
-id(.) = generate-id(current()))]">
<xsl:text>&#x0A; </xsl:text>
<xsl:value-ofselect="title"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>




________________________________
From: Rick Quatro
<rick@xxxxxxxxxxxxxx>
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
Sent: Thursday,
March 15, 2012 2:10 PM
Subject: RE: [xsl] XPath to Find All Siblings Except
Self

Hi Ken,

Yes, that works great, and makes sense too. Thanks for the
quick response.

Rick

You could use the union of preceding and following
siblings:

   ( preceding-sibling::section | following-sibling::section)/title
I hope this helps.

. . . . . . . Ken

Current Thread