xsl-list
[Top] [All Lists]

Re: [xsl] Grouping problem. 2.0

2008-07-04 11:22:22
Dave Pawson wrote:

Andrews solution is good, but outputs

<bk>
   <block sect="1">
      <para>Copyright © OASIS® 2002–2007. All Rights ....</para>
      <para>All capitalized terms in the following t ....</para>
      <para>This document and translations of it may ....</para>
      <para>The limited permissions granted above ar ....</para>
      <para>This document and the information contai ....</para>
      <para>OASIS requests that any OASIS Party or a ....</para>
      <para>OASIS invites any party to contact the O ....</para>
      <para>OASIS takes no position regarding the va ....</para>
      <para>The names "OASIS", “OpenDocument”, “Open ....</para>
   </block>

I.e. the numbering is out by one since the document
doesn't start with a header.
I'm working on Andrews Solution to see if I can hack round it

<xsl:template match="/">
  <bk>

    <!-- Collate all blocks (== title, para* ) -->
    <xsl:variable name="blocks">
<xsl:for-each-group select="/book/*" group-starting-with="*[self::title]">
        <block>
          <xsl:copy-of select="current-group()"/>
        </block>  
      </xsl:for-each-group>
    </xsl:variable>

    <xsl:variable name="nested">
      <xsl:call-template name="nest">
<xsl:with-param name="nodes" select="$blocks//block[not(position() = 1)]"/>
      </xsl:call-template>
    </xsl:variable>       

    <xsl:apply-templates select="$nested/*"/>
  </bk>   
</xsl:template>


Just needed to ignore the first block.
Now working.

Many thanks Andrew. Numbering now matches the spec

<bk>
   <block sect="1">
      <title>Introduction</title>
   </block>
   <block sect="1.1">
      <title>Introduction</title>
      <para>This document defines an XML schema for ....</para>
      <para>The schema provides for high-level infor ....</para>
      <para>Chapter 1 contains the introduction to t ....</para>
      <para>Chapter 8 describes the table content of ....</para>
      <para>The OpenDocument format makes use of a p ....</para>
   </block>
   <block sect="1.2">
      <title>Notation</title>
      <para>Within this specification, the key words ....</para>
   </block>




regards

--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

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