[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] XSLT 2.0 & Grouping


Subject: [xsl] XSLT 2.0 & Grouping
From: Mark Brand <mark.brand@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 06 Aug 2003 02:11:26 +1000

Hi all

I am having some issues with understanding the for-each-group mechanism in XSLT 2.0
and how I can apply it to my particular situation. Michael Kay yesterday pointed me at some positional grouping information which may appear to offer a solution. But i can't get my head around how to manage the nesting aspects. That is having to output
an opening <PART> tag and then managing all the child tags and then
coming back somehow to put in the closing </PART> tag. I am using XSLT 2.0 Saxon 7.5 and I would really like some help on this - as I am a bit stuck.


===Problem Context =============================================
I need to iterate through each paragraph in the Source XML document (below)
and depending on what the paragraph style is i need to output
some markup & content whilst keeping the nesting (PARTS, contain DIVISIONS,
contain SUBDIVISIONS contain REGULATIONS contain SUB-REGULATIONS etc.) intact


=== Source XML Document ========================================
<Document>
   <Paragraph StyleName="PART">..................</Paragraph>
   <Paragraph StyleName="DIVISION">..............</Paragraph>
   <Paragraph StyleName="SUBDIVISION">...........</Paragraph>
   <Paragraph StyleName="REGULATION">............</Paragraph>
   <Paragraph StyleName="SUB-REGULATION">........</Paragraph>
   <Paragraph StyleName="PARAGRAPH">.............</Paragraph>
   <Paragraph StyleName="SUB-PARAGRAPH">.........</Paragraph>
   <Paragraph StyleName="SUB-PARAGRAPH">.........</Paragraph>
   <Paragraph StyleName="SUB-SUB-PARAGRAPH">.....</Paragraph>
   <Paragraph StyleName="SUB-SUB-PARAGRAPH">.....</Paragraph>
   <Paragraph StyleName="SUB-PARAGRAPH">.........</Paragraph>
   <Paragraph StyleName="SUB-PARAGRAPH">.........</Paragraph>
   <Paragraph StyleName="SUB-SUB-PARAGRAPH">.....</Paragraph>
   <Paragraph StyleName="SUB-SUB-PARAGRAPH">.....</Paragraph>
   <Paragraph StyleName="PARAGRAPH">.............</Paragraph>
   <Paragraph StyleName="SUB-PARAGRAPH">.........</Paragraph>
   <Paragraph StyleName="SUB-SUB-PARAGRAPH">.....</Paragraph>
   <Paragraph StyleName="SUB-SUB-PARAGRAPH">.....</Paragraph>
   <Paragraph StyleName="SUB-PARAGRAPH">.........</Paragraph>
   <Paragraph StyleName="SUB-PARAGRAPH">.........</Paragraph>
   <Paragraph StyleName="SUB-SUB-PARAGRAPH">.....</Paragraph>
   <Paragraph StyleName="SUB-SUB-PARAGRAPH">.....</Paragraph>
   <Paragraph StyleName="SUB-SUB-PARAGRAPH">.....</Paragraph>
   <Paragraph StyleName="SUB-PARAGRAPH">.........</Paragraph>
   <Paragraph StyleName="SUB-REGULATION">........</Paragraph>
   <Paragraph StyleName="SUB-REGULATION">........</Paragraph>
   <Paragraph StyleName="SUB-REGULATION">........</Paragraph>
   <Paragraph StyleName="SUB-REGULATION">........</Paragraph>
   <Paragraph StyleName="NOTE">..................</Paragraph>
</Document>

=== Required Output ======================
<Regulation>
   <Part Category="PART">
       <Part Category = "DIVISION">
           <Part Category = "SUBDIVISION">
               <Article>
                   <Sub-Article>
                       <Paragraph>
                           <Sub-Paragraph/>
                           <Sub-Paragraph>
                               <Sub-Sub-Paragraph>
                               <Sub-Sub-Paragraph>
                           <Sub-Paragraph/>
                           <Sub-Paragraph/>
                           <Sub-Paragraph>
                               <Sub-Sub-Paragraph/>
                               <Sub-Sub-Paragraph/>
                           </Sub-Paragraph>
                       </Paragraph>
                   </Sub-Article>
              </Article>
           </Part>
       </Part>
   </Part>
</Regulation>


Best Regards & Thanks Mark Brand



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords