Re: [xsl] Grouping problem. 2.0

Subject: Re: [xsl] Grouping problem. 2.0
From: Dave Pawson <davep@xxxxxxxxxxxxx>
Date: Fri, 04 Jul 2008 19:21:03 +0100
Dave Pawson wrote:

Andrews solution is good, but outputs

<bk>
   <block sect="1">
      <para>Copyright ) OASIS. 20022007. 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

Current Thread