At 2011-09-16 14:44 +0000, Raymond Lillibridge wrote:
I'm in need of some assistance with group logic using XSLT 2.0.
I don't think you need group logic for what you are asking.
Given the following sample xml file as input:
<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>
<para>level1 Blah, blah, blah</para>
<para>level1 Dah, dah, dah</para>
<para>level1 Lah, lah, lah</para>
<level2>
<title>level2 AAA</title>
<para>level2 Blah, blah, blah</para>
<para>level2 Dah, dah, dah</para>
<para>level2Lah, lah, lah</para>
<level3>
<title>level3 AAA</title>
<para>level3 Blah,
blah, bl= ah</para>
<para>level3 Dah,
dah, dah<= /para>
<para>level3 Lah,
lah, lah<= /para>
</level3>
<level3>
<title>level3 AAA</title>
<para>level3 Blah,
blah, bl= ah</para>
<para>level3 Dah,
dah, dah<= /para>
<para>level3 Lah,
lah, lah<= /para>
</level3>
</level2>
</level1>
</book>
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#>?
If you are at the root: book/* except book/level1
If you are at book: * except level1
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>
...&c.
You don't have mixed content in your paragraphs or titles. If that
can be relied upon, then you can generalize the solution to:
<xsl:template match="*[*]">
<xsl:result-document ...>
<xsl:copy/>
<xsl:copy-of select="@*,node() except *[*]"/>
</xsl:result-document>
<xsl:apply-templates select="*[*]"/>
</xsl:template>
I hope this helps.
. . . . . . . . . . Ken
--
Contact us for world-wide XML consulting and instructor-led training
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
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>
--~--