XSLT question

M

Mike King

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

Bjoern Hoehrmann

* 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...
 
M

Mike King

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

David Carlisle

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
 
M

Mike King

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top