XSLT question

Discussion in 'XML' started by Mike King, Jul 23, 2004.

  1. Mike King

    Mike King Guest

    Can anyone help me. I need to process groups of elements and their children
    nodes very high on the template stack. Is it possible?

    :::Source XML document:::
    <root xmlns="urn:tempuri.org">
    <child>
    <!-- many children nodes here -->
    </child>
    <child>
    <!-- many children nodes here -->
    </child>
    <child>
    <!-- many children nodes here -->
    </child>
    <child>
    <!-- many children nodes here -->
    </child>
    </root>

    :::Resulting Tranformed XML document:::
    <root xmlns="uri:someother.org">
    <group>
    <!-- and some children nodes -->
    </group>
    <group>
    <!-- and some children nodes -->
    </group>
    </root>
     
    Mike King, Jul 23, 2004
    #1
    1. Advertising

  2. * Mike King wrote in comp.text.xml:
    >Can anyone help me. I need to process groups of elements and their children
    >nodes very high on the template stack. Is it possible?


    Yes, searching for Grouping and XSLT using Google should help. I can't
    work out from your example what the pattern for grouping should be, so
    I can't provide example code...
     
    Bjoern Hoehrmann, Jul 25, 2004
    #2
    1. Advertising

  3. Mike King

    Mike King Guest

    > Yes, searching for Grouping and XSLT using Google should help. I can't
    > work out from your example what the pattern for grouping should be, so
    > I can't provide example code...


    I have searched an haven't found the solution yet. Maybe it would help if I
    provide more information. I'm trying to produce a PDF document. I have
    written an application that will take a XML document as an input and produce
    a PDF document based on that document. The problem I'm having is the XML
    structure that I have chosen requires that each sheet be represented as an
    <sheet> element. So here's a sample document that represents that PDF
    document:

    <sheets>
    <sheet>
    <table>
    <column>
    <cell>some text</cell>
    </column>
    </table>
    </sheet>
    </sheets>

    The problem is I want to take ten or some other number of test-results
    elements and group them together on one sheet and then another ten or so on
    the next sheet and so on. Here's an example of a XML document where I'm
    trying to group the Test Results on a sheet.

    ::: Source document:::
    <root>
    <test-results title="some title" date-time="2004-01-01 01:01:00">
    <start-up-time passed="true">
    <spec min="1" max="4" />
    <results>2.31</results>
    </start-up-time>
    <!-- many other tests -->
    </test-results>
    <test-results>
    <start-up-time passed="true">
    <spec min="1" max="4" />
    <results>2.64</results>
    </start-up-time>
    <!-- many other tests -->
    </test-results>
    <!-- many other test results -->
    </root>

    :::Resultant document:::
    <sheets>
    <sheet>
    <table>
    <column>
    <cell>Start Up Time</cell>
    </column>
    <column>
    <cell>2.31</cell>
    </column>
    <column>
    <cell>2.64</cell>
    </column>
    </table>
    </sheet>
    </sheets>
     
    Mike King, Jul 26, 2004
    #3

  4. > The problem is I want to take ten or some other number of test-results
    > elements and group them together on one sheet and then another ten or so on
    > the next sheet and so on.


    <xsl:variable name="n" select="10"/>

    <xsl:for-each select="test-results[position() mod $n = 1]">
    <sheet>
    .... whatever ...
    <xsl:apply-templates
    select=".|following-sibling::test-results[position() &lt; $n]"/>
    .... whatever ...

    </sheet>
    </xsl:for-each>

    David
     
    David Carlisle, Jul 26, 2004
    #4
  5. Mike King

    Mike King Guest

    Thank you very much!! You enabled me to meet my deadline - thank you.

    I was trying something similar but I couldn't get it to work.
     
    Mike King, Jul 27, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    736
    Stylus Studio
    Aug 3, 2004
  2. Benjamin Hillsley
    Replies:
    3
    Views:
    1,731
    Dimitre Novatchev
    Sep 25, 2003
  3. ted
    Replies:
    1
    Views:
    647
    Laurens
    Jan 26, 2004
  4. Replies:
    2
    Views:
    733
    Henry S. Thompson
    Oct 19, 2005
  5. Replies:
    18
    Views:
    2,793
    Joseph Kesselman
    Oct 4, 2006
Loading...

Share This Page