xsl-list
[Top] [All Lists]

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

2012-03-15 13:27:46
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(_at_)rickquatro(_dot_)com>
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
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




--~------------------------------------------------------------------
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>
--~--

--~------------------------------------------------------------------
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>
--~--