473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

XSLT question

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>

Jul 20 '05 #1
4 2021
* 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...
Jul 20 '05 #2
> 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>
Jul 20 '05 #3
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
Jul 20 '05 #4
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.
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ringo Langly | last post by:
Hi all, I'm a seasoned web programmer, but I've never touched XSLT. It's always been one of those acronyms I've never needed to educate myself on. Now... we're working with a web content...
0
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag,...
3
by: Ian Roddis | last post by:
Hello, I want to embed SQL type queries within an XML data record. The XML looks something like this: <DISPLAYPAGE> <FIELD NAME="SERVER" TYPE="DROPDOWN"> <OPTION>1<OPTION> <OPTION>2<OPTION>...
0
by: DAnne | last post by:
Hi, I'm very new to xslt and this is my first time posting to a Forum so please forgive me if I transgress any protocols. I have to do a tally report. This report is divided up into sections....
18
by: yinglcs | last post by:
Hi, I have a newbie XSLT question. I have the following xml, and I would like to find out the children of feature element in each 'features' element. i.e. for each <featuresI would like to...
15
by: Jeff Uchtman | last post by:
Can I draw from 2 XML sources, the structure is exactly the same execpt for data contained into 1 xslt using math to add some structrure, and displaying others as node 1 and node 2? This data is...
2
by: MichaelRKramer | last post by:
Hi, I'm new to dotnet 2.0, but I'm an expert in asp 3 or classic asp. Most of my sites are all done with XSLT and ASP which basically writes XMLs. Now I'm reading about the new cool stuff in...
14
by: Lee | last post by:
I have a xml file, here is sample part: <?xml version="1.0" encoding="UTF-8"?> <ProducsList> <Product id="1"> <SpecList> <Spec> <SpecLabel>Height</SpecLabel> <SpecValue>10</SpecValue>...
1
by: nayijitu | last post by:
Hi, I need some thing like this. I have an XML file and it contain some elements(tag) with a proper hierarchy... In that XML a particular element <page> contain some child node element like...
2
by: astroboiii | last post by:
New to the whole xml thing and finding w3schools to be an excellent resource. Now down to my question: I have several xml files I need to parse through and grab relevant information from and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.