xsl-list
[Top] [All Lists]

Re: [xsl] for-each-group for multiple nodes

2009-07-20 15:50:45
On 17 Jul 2009, at 03:36 , Ramkumar wrote:

...
I am not able to achieve my expected output through for-each-group for
multiple nodes in a single template match. Please look into my detailed
inputs and find mistakes in my below code.
...
xslt
=====
...

<xsl:template match="book">
<book>
 <xsl:for-each-group select="*"
group-starting-with="para[contains(@aid:pstyle,'Level')]">

If the sample input you showed is typical, this is equivalent
to

  <xsl:for-each-group select="*" group-starting-with="para"/>

I think that since you want each LevelF para to generate a
distinct qandaset element in the output, you might think
about whether you really want a distinct group for every
para, or just a distinct group for every sequence of elements
beginning with para aid:pstyle="LevelF".



  <xsl:choose>
            <xsl:when test="self::para/@aid:pstyle[contains(.,'LevelF')]">
             <qandaset>
              <xsl:call-template name="g">
               <xsl:with-param name="e" select="current-group()"/>
              </xsl:call-template>
             </qandaset>
            </xsl:when>

The code above seems to expect that the current-group()
will contain the following LevelM and LevelM_sub para elements.
It won't:  each time the input contains a new para element
with contains(@aid:pstyle,'Level'), a new group will be
started.  So your Level M paragraphs and their subordinate
parts will be in the next group, not this one.

As a first step, try to get the outermost grouping to work;
don't worry about the inner groupings.  Since you want
each LevelF paragraph to produce an element containing its
following siblings up to but not including the next level
F paragraph, you want a grouping based on the LevelF value,
not on the string 'Level'.

Within those groups, you may want to make use of recursive
groupings for Level M.

I hope this helps; if it does not help sufficiently, please ask
again.

Michael Sperberg-McQueen

--
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com
* http://cmsmcq.com/mib
* http://balisage.net
****************************************************************





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