473,564 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select multiple nodes in XSL

Hello,

I am creating an XSL that is going to create a report from XML we
recieve from another system. The XML would look like:

<report>
<page>
<header1>
<data1>asdf</data1>
<data2>fdas</data2>
</header1>
<header2>
<dataA>xyz</dataA>
<dataB>zyx</dataB>
</header2>
<reportSection1 >
<!-- Some Data Here -->
</reportSection1>
<reportSection2 >
<!-- Some More Data Here -->
</reportSection2>
</page>
</report>

Due to the size of the XML, I'm attempting to modularize the XSL. I
want to pull out the data for the header into a seperate template.
Currently I have the template as:

<xsl:template match="header1 | header2">
<!-- rest of the template -->
</xsl:template>

And I call it by:

<xsl:apply-templates select="header1 | header2"/>

The issue I'm having is that my XSL is being executed twice, once for
each node (header1 and header2) rather than going thru both nodes at
once. The goal is to go thru both nodes at once. Any assistance
would be appreciated.

Thanks,
Michael
Jul 20 '05 #1
3 7613
<xsl:template match="header1 | header2">
<!-- rest of the template -->
</xsl:template>

And I call it by:

<xsl:apply-templates select="header1 | header2"/>

The issue I'm having is that my XSL is being executed twice, once for
each node (header1 and header2) rather than going thru both nodes at
once. The goal is to go thru both nodes at once. Any assistance
would be appreciated.


you select all header1 and header2 nodes and apply templates to them,
each of those templates is going to execute
-- rest of the template --
actualy they may be executed in any (time) order but the results will be
merged in to the result tree based on position of the nodes in the
source.

So since you have a header1 and a header2 in your example source you get
the results of transforming those nodes.

I can't guess from your description what result you _did_ want so can't
suggest any change to the xsl. It may be that the templates for header1
and header2 are exeecuted "at once" in a concurrent xslt implementation,
but clearly (or not?) the results of each template exeution have to be
attatched to the result tree at different points.

It would help if you said what output you need from your sample input.

If you only want to process at most one header you could do

<xsl:apply-templates select="(header 1 | header2)[1]"/>

but that processes one and ignores the other, which doesn't seem to
match the description of your desired outcome.

David
Jul 20 '05 #2
> Hello,

I am creating an XSL that is going to create a report from XML we
recieve from another system. The XML would look like:

<report>
<page>
<header1>
<data1>asdf</data1>
<data2>fdas</data2>
</header1>
<header2>
<dataA>xyz</dataA>
<dataB>zyx</dataB>
</header2>
<reportSection1 >
<!-- Some Data Here -->
</reportSection1>
<reportSection2 >
<!-- Some More Data Here -->
</reportSection2>
</page>
</report>

Due to the size of the XML, I'm attempting to modularize the XSL. I
want to pull out the data for the header into a seperate template.
Currently I have the template as:

<xsl:template match="header1 | header2">
<!-- rest of the template -->
</xsl:template>

And I call it by:

<xsl:apply-templates select="header1 | header2"/>

The issue I'm having is that my XSL is being executed twice, once for
each node (header1 and header2) rather than going thru both nodes at
once. The goal is to go thru both nodes at once. Any assistance
would be appreciated.


Hi,

I think - but could be wrong - that you are in fact looking for a template you can call instead of apply.

<xsl:template name="headers">
<!-- rest of the template -->
</xsl:template>

And call it by:

<xsl:call-template name="headers"/>

regards,

--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #3
On 2 Dec 2004 13:09:39 -0800, mm******@sark.c om (Michael) wrote:
Hello,

I am creating an XSL that is going to create a report from XML we
recieve from another system. The XML would look like:

<report>
<page>
<header1>
<data1>asdf</data1>
<data2>fdas</data2>
</header1>
<header2>
<dataA>xyz</dataA>
<dataB>zyx</dataB>
</header2> ....</report>

Due to the size of the XML, I'm attempting to modularize the XSL. I
want to pull out the data for the header into a seperate template.
Currently I have the template as:

<xsl:templat e match="header1 | header2">
<!-- rest of the template -->
</xsl:template>

And I call it by:

<xsl:apply-templates select="header1 | header2"/>

The issue I'm having is that my XSL is being executed twice, once for
each node (header1 and header2) rather than going thru both nodes at
once. The goal is to go thru both nodes at once. Any assistance
would be appreciated.


If you want to process both nodes at once, and process the header in a
separate template, why not call a named template?

<xsl:call-template name="header"/>

<xsl:template name="header">
<element><xsl:v alue-of select="header1/data1"/></element>
<another-element><xsl:va lue-of select="header2/dataB"/>
</another-element>
...
</xsl:template>
--
Morris M. Keesan -- ke****@alum.bu. edu

Jul 20 '05 #4

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

Similar topics

5
3661
by: Colman | last post by:
Howdy all! I guess I'm a newbie, because I am stumped (or maybe just too durned tired). Here's what I got... CREATE TABLE `nodecat_map` ( `nodecat_id` mediumint(8) unsigned NOT NULL auto_increment, `nodecat_cat_id` mediumint(8) unsigned NOT NULL default '0', `nodecat_node_id` mediumint(8) unsigned NOT NULL default '0', PRIMARY KEY...
4
6152
by: Marco Alting | last post by:
Hi I have two table which are related: table1 holds personellinformation table2 holds nodeInformation The nodes in table2 can have a nodeOwner which will then get a recordID from table1. A person can own multiple nodes.
2
2880
by: RanDeep | last post by:
I have two nodes that both exist underneath the root node. They are linked, however, in the sense that one of the nodes contains a copy of an id that is used to refer to the other. However, when I try create a param using this search critieria it can never seem to locate what I am looking for. For example, check out the following XML file:...
2
1656
by: Cali | last post by:
Please bear with me, I have been reading about XSL for a couple hours. I have an XML document that contains multiple <page> tags interspersed throughout the tree. <text> .... <page>1</page> .... <page>2</page>
3
1225
by: Andreas Håkansson | last post by:
Is it possible to create an id over multiple nodes? I would like to use generate-id which includes all of the Route nodes which has a direction of 1. So I don't want to for-each each Route node and run generate-id on each on of them but bulk them all together and generate an id for the nodes <Routes> <Route>
16
13548
by: Brian D | last post by:
I have a multiple select list that is created dynamically based on a previous selection on an asp page. The first thing I do is to clear the curent option list by document.form1.itemcross.length = 0; The only problem is that it leaves the optgroups. How do I also get rid of the optgroups? Thanks
1
1900
by: gplott | last post by:
I have an XML document that has multiple childe nodes like the one at the end of this message What syntax would I use with selectNodes to select all viewentry nodes that have an entrydata child node with a name attribute equal to "CourseOrMeetingName" that has a text childe node with the text Course ABC
1
1975
by: icfai | last post by:
hi friends.... I have got a problem regarding loading of multiple assemblies, actually its required for an editor which implements the intellisenseas in vb or dotnet. for that it is required to load that assembly whose sub-classes are required to be loaded into the list box after pressing dot. for example in the code given below i have...
1
2734
by: karthee | last post by:
I am creating a custom treeview with multiple selection, if i select multiple nodes and right click, the selection is disappearing, i tried with somany things like on mouse click my code is like this if (e.Button != MouseButtons.Right) { if (ModifierKeys == Keys.None &&
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6255
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.