Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT question

Reply
Thread Tools

XSLT question

 
 
Mike King
Guest
Posts: n/a
 
      07-23-2004
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>





 
Reply With Quote
 
 
 
 
Bjoern Hoehrmann
Guest
Posts: n/a
 
      07-25-2004
* 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...
 
Reply With Quote
 
 
 
 
Mike King
Guest
Posts: n/a
 
      07-26-2004
> 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>


 
Reply With Quote
 
David Carlisle
Guest
Posts: n/a
 
      07-26-2004

> 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
 
Reply With Quote
 
Mike King
Guest
Posts: n/a
 
      07-27-2004
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT question: How to lookup another tag's children in XSLT yinglcs@gmail.com XML 18 10-03-2006 11:22 PM
Multiple XSLT Transforms using a Controller XSLT sneill@mxlogic.com XML 2 10-19-2005 11:00 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
xslt alone or xslt/java for static site? ted XML 1 01-26-2004 10:41 AM
[XSLT]Passing values from Javascript to a XSLT variable Benjamin Hillsley XML 3 09-25-2003 04:50 AM



Advertisments