Re: with XPath 1.0, select all following sibling elements of name "foo" up to the first non-"foo" element

"Wendell Piez [email protected]" <[email protected]> Fri, 19 Feb 2021 17:00:53 -0000
Newsgroups gmane.text.xml.xsl.general.mulberrytech
Message-ID <[email protected]>
Hi again,

Then too:

<xsl:template match="node() | @*">
  <xsl:copy>
    <xsl:apply-templates select="node() | @*"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="foo[preceding-sibling::*[not(self::foo)]]"/>

(I know it probably doesn't solve the problem as given, which I'm not sure
I remember. So, modes.)

Cheers, Wendell



On Fri, Feb 19, 2021 at 11:43 AM Leo Studer [email protected] <
[email protected]> wrote:

> David, sibling recursion over the foo elements...
>
>     <xsl:template match="b">
>         <zzz>
>             <xsl:apply-templates select="*[1]/self::foo"/>
>         </zzz>
>     </xsl:template>
>
>     <xsl:template match="foo">
>         <xsl:copy-of select="."/>
>         <xsl:apply-templates select="following-sibling::*[1]/self::foo"/>
>     </xsl:template>
>
> Cheers
> Leo
>
>
>
> On 18 Feb 2021, at 22:35, David Carlisle [email protected] <
> [email protected]> wrote:
> Given
>
> <x>
>
>  <b>
>   <foo>1</foo>
>   <foo>2</foo>
>   <bar>x</bar>
>   <foo>3</foo>
>  </b>
>
>  <b>
>   <foo>4</foo>
>   <foo>5</foo>
>   <foo>6</foo>
>  </b>
>
>  <b>
>   <bar>y</bar>
>   <foo>7</foo>
>   <foo>8</foo>
>  </b>
>
> </x>
>
>
> this stylesheet
>
> <xsl:stylesheet version="1.0" xmlns:xsl="
> http://www.w3.org/1999/XSL/Transform">
>
>  <xsl:template match="b">
>    <zzz>
>    <xsl:apply-templates mode="onlyfoo" select="*[1]"/>
>    </zzz>
>  </xsl:template>
>
>  <xsl:template mode="onlyfoo" match="*"/>
>
>  <xsl:template mode="onlyfoo" match="foo">
>   <xsl:copy-of select="."/>
>   <xsl:apply-templates mode="onlyfoo" select="following-sibling::*[1]"/>
>  </xsl:template>
>
> </xsl:stylesheet>
>
>
> produces
>
>
>  <zzz><foo>1</foo><foo>2</foo></zzz>
>
>  <zzz><foo>4</foo><foo>5</foo><foo>6</foo></zzz>
>
>  <zzz/>
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/174322> (by
> email <>)
>


-- 
...Wendell Piez... ...wendell -at- nist -dot- gov...
...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org...
...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/3329386
or by email: [email protected]
--~--