Re: [xsl] Transformation Grouping Problem (XSLT 2.0, Saxon-PE 9.3.0.5)

Subject: Re: [xsl] Transformation Grouping Problem (XSLT 2.0, Saxon-PE 9.3.0.5)
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Fri, 16 Sep 2011 15:50:29 +0100
> <book>
>            <title>My Book Title</title>
>
>            <para>book Blah, blah, blah</para>
>            <para>book Dah, dah, dah</para>
>            <para>book Lah, lah, lah</para>
>
>            <level1>
>                        <title>level1 AAA</title>

> using 'for-each-group'  I can group by the different levels, but how can I =
isolate just the 'top' content of the <book> or  <level#>?
>
> For instance, I'd like to create an XML result-document that contains only:
>
> <book>
>            <title>My Book Title</title>
>
>            <para>book Blah, blah, blah</para>
>            <para>book Dah, dah, dah</para>
>            <para>book Lah, lah, lah</para> </book>
>
>
> ...and another XML result-document that contains only:
>
> <level1>
>            <title>level1 AAA</title>
>            <para>level1 Blah, blah, blah</para>
>            <para>level1 Dah, dah, dah</para>
>            <para>level1 Lah, lah, lah</para> </level1>


You can do:

<xsl:apply-templates select="*[not(*)]"/>

...which means "apply templates to the child elements which do not
have child elements".

eg:

<xsl:template match="book">
  <xsl:copy>
    <xsl:result-document ...>
      <xsl:apply-templates select="*[not(*)]"/>



--
Andrew Welch
http://andrewjwelch.com

Current Thread