xsl-list
[Top] [All Lists]

[xsl] two-level grouping

2008-03-05 12:24:34
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>«</strong>vər- ser«<strong>ē</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>«</ strong>stre&#774;ch«) <em>n. </em>The part of the oval...</p>
<!--more paragraphs elements here-->
   <p>Lesson 1 • Level I • VOCABULARY SKILLBOOK</p>
<pagenum page="normal" id="page_1">1</pagenum><p>PARTIAL PRONUNCIATION KEY</p> <p>a&#774; pat, a&#772; pay, ‰r care, Š father, e&#774; pet, e&#772; bee, ə about, ı&#774; pit, ı&#772; pie, ”r pier, o&#774; pot, o&#772; toe, ™ paw, oi boy, ou out, o͝o took, o͞o boot, u&#774; cut, ž 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>Let’s 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


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