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

two-level grouping

Subject: two-level grouping
From: Terry Ofner <tofner@xxxxxxxxxxx>
Date: Wed, 5 Mar 2008 14:22:39 -0500
 two-level grouping
I am stuck on a two-level grouping problem. This one is slightly
different from the last one. I believe it involves nested grouping
sequences, but I have been wrong on numerous occasions before.

Here is a snippet of the imput:

<book>
 <bodymatter>
   <chapter>Fun and Games</chapter>
    <a-head><img src="BK_Vocab_G09-5P2-web-images/embossed%
20arrow_opt.jpeg" alt="embossed arrow.eps"/>Definitions</a-head>

    <p>Directions: The words in this lesson may be associated with
sports and leisure activities.</p>
    <p><strong>adversary</strong> (ad<strong>B+</strong>vIr-
serB+<strong>eL</strong>) <em>n. </em>An opponent; an enemy.</p>
    <p>Tyler groaned when he saw his <strong>adversary</strong>
spinning his basketball on one finger.</p>
    <p><strong>backstretch</strong> (bak<strong>B+</
strong>stre&#774;chB+) <em>n. </em>The part  of the oval...</p>
<!--more paragraphs elements here-->
   <p>Lesson 1 b" Level I b" VOCABULARY SKILLBOOK</p>
   <pagenum page="normal" id="page_1">1</pagenum><p>PARTIAL
PRONUNCIATION KEY</p>
	<p>a&#774; pat, a&#772; pay, b0r care, E  father, e&#774; pet,
e&#772; bee,  I  about, D1&#774; pit, D1&#772; pie, br pier,
o&#774; pot,
	 o&#772; toe, b" paw, oi boy, ou out, oMo took, oMo boot, u&#774;
cut, E> urge</p>
	<image><img src="BK_Vocab_G09-5P2-web-images/BW%20oval_opt.jpeg"
alt="BW oval.eps"/></image>
   <p>LESSON 1</p>

   <a-head><img src="BK_Vocab_G09-5P2-web-images/embossed%
20arrow_opt.jpeg" alt="embossed arrow.eps"/>Completing the Sentence</
a-head>

   <p>Directions: Choose the letter of the word that best completes
the sentence.</p>
<!--more a-heads and paragraphs pagenums, etc here-->

  <chapter>Letbs Eat!</chapter>
   <a-head><img src="BK_Vocab_G09-5P2-web-images/embossed%
20arrow_opt.jpeg" alt="embossed arrow.eps"/>Definitions</a-head>
   <p>Directions: The words in this lesson may be associated with
food, eating, and cooking.</p>
   <!--more chapter and a-head sequences -->
 </bodymatter>
</book>


I am trying to add two levels <book> <bodymatter> <level1> <chapter>Fun and Games</chapter> <level2> <a-head>Definitions</a-head> <p>...</p> <p>...</p> <p>...</p> <!--etc.--> </level2>

		<level2>
			<a-head>Head Text</a-head>
			<p>...</p>
			<p>...</p>
			<p>...</p>
			<!--etc.-->
		</level2>
</level1>
<level1>
	<chapter>Let's Eat</chapter>
		<level2>
			<a-head>Definitions</a-head>
			<p>...</p>
			<p>...</p>
			<p>...</p>
			<!--etc.-->
		</level2>
<!--etc-->
</level1>
</bodymatter>
</book>

Here is my latest sheet:

<xsl:stylesheet version="2.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>

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

 <xsl:template match="bodymatter">
   <xsl:copy>
       <xsl:apply-templates select="@*"/>
           <xsl:for-each-group select="*" group-starting-
with="chapter">
        <level1 class="chapter">
         <xsl:apply-templates select="current-group()"/>
        </level1>
          <xsl:for-each-group select="current-group()" group-
starting-with="a-head">
            <level2>
            <xsl:copy-of select="current-group()"/>
            </level2>
          </xsl:for-each-group>
        </xsl:for-each-group>
     </xsl:copy>
 </xsl:template>

This captures the <chapter> level1 but doesn't touch the <a-head>
level2.

Some hints in the right direction would be much appreciated.

Terry

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.