xsl-list
[Top] [All Lists]

Re: Grouping immediate follow sibling

2005-01-31 08:44:46
Tempore 13:44:35, die 01/31/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Paul Clarke <pclarke(_at_)rcpsolutions(_dot_)com>:

Hello,

I receive XML similar to that shown below:>
        <ProgAbs>More text</ProgAbs>
        <ProgAbs>Even more</ProgAbs>
</bodyFrag>

Using 'following-sibling::ProgAbs' gives me all the siblings of that name, as it should. I just need to know how to construct an expression to select
only those <ProgAbs> that follow on immendiately after the <p> element.
Hi,

In an XPath one-liner, that could be something like
'following-sibling::ProgAbs[count(current()|preceding-sibling::p[1])=1]'

But because of performance reasons, a recursive approach would be better I think.
e.g:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

<xsl:template match="bodyFrag">
<xsl:apply-templates select="p"/>
</xsl:template>

<xsl:template match="p">
<h1><xsl:value-of select="."/></h1>
<p>
<xsl:apply-templates select="following-sibling::*[1][self::ProgAbs]"/>
</p>
</xsl:template>

<xsl:template match="ProgAbs">
<xsl:value-of select="."/>
<xsl:apply-templates select="following-sibling::*[1][self::ProgAbs]"/>
</xsl:template>

</xsl:stylesheet>


regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
Spread the wiki (http://www.wikipedia.org)

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