[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XPath selecting chain of following siblings of the

Subject: Re: XPath selecting chain of following siblings of the same name
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Sun, 11 Mar 2007 10:24:03 +0530
Re:  XPath selecting chain of following siblings of the
Thanks Ken for the answer. Now it's clear to me.

On 3/11/07, G. Ken Holman <gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:
At 2007-03-10 17:13 +0530, Mukul Gandhi wrote:
>I wonder, why this XSLT 1.0 solution doesn't work:

 From what I can tell it is because you only look at the "next" a and
not all contiguous a elements that follow:

> <xsl:apply-templates select="following-sibling::*[1][self::a]" />

Did you mean to do what is in the code below? This appears to work just fine.

I hope this helps.

. . . . . . . . . Ken

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output method="xml" indent="yes"/>

<!--identity transform for all nodes other than 'a'-->
<xsl:template match="node() | @*">
  <xsl:copy>
    <xsl:apply-templates select="node() | @*" />
  </xsl:copy>
</xsl:template>

<!--the first a-->
<xsl:template match="a[not(preceding-sibling::*[1][self::a])]">
  <a-block>
    <xsl:apply-templates select="." mode="nested"/>
  </a-block>
</xsl:template>

<!--other a's when nested-->
<xsl:template match="a" mode="nested">
  <xsl:copy-of select="."/>
  <xsl:apply-templates select="following-sibling::*[1][self::a]"
                       mode="nested"/>
</xsl:template>

<!--other a's when not nested can be ignored-->
<xsl:template match="a"/>

</xsl:stylesheet>


-- World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal


--
Regards,
Mukul Gandhi

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.