473,465 Members | 3,216 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

multiple pass with XSL on same XML file

Hi,

I have simplified my DTD for the purposes of this question. Let's say
that I have the following tags: <section1>, <section2>, <section3>
with xsl that uses <xsl:template match="section1"etc for each
section tag and corresponding <xsl::template match="blah"for all of
the implied subtags.

Now, lets say I need to concatenate the results of 2 passes thru the
document, such that I (a) spit out some predefined HTML, (2) make a
pass thru the XML file using one interpretation of each section and
concatenate to the HTML already output, (3) spit out some more HTML,
(3) make a second pass thru the XML file using a different
interpretation of each section and concatenate to HTML already output,
and (4) spit out my final predefined HTML section.

My question is how with <xsl:template match ...do I have different
xsl:template tags for the same sections and ask the transformation to
use the appropriate one. Can anyone give me some sample xsl code?

Thanks,
Andy

P.S. I'm wanting to identify my header sections and create a left nav
for the final HTML file, with the
left nav being the results of the first transformation and the content
being the result of the second transformation, all to the same output
HTML file.

Feb 16 '07 #1
1 2736
On 2007-02-16, an*********@yahoo.com <an*********@yahoo.comwrote:
Hi,

I have simplified my DTD for the purposes of this question. Let's say
that I have the following tags: <section1>, <section2>, <section3>
with xsl that uses <xsl:template match="section1"etc for each
section tag and corresponding <xsl::template match="blah"for all of
the implied subtags.

Now, lets say I need to concatenate the results of 2 passes thru the
document, such that I (a) spit out some predefined HTML, (2) make a
pass thru the XML file using one interpretation of each section and
concatenate to the HTML already output, (3) spit out some more HTML,
(3) make a second pass thru the XML file using a different
interpretation of each section and concatenate to HTML already output,
and (4) spit out my final predefined HTML section.

My question is how with <xsl:template match ...do I have different
xsl:template tags for the same sections and ask the transformation to
use the appropriate one. Can anyone give me some sample xsl code?

Thanks,
Andy

P.S. I'm wanting to identify my header sections and create a left nav
for the final HTML file, with the
left nav being the results of the first transformation and the content
being the result of the second transformation, all to the same output
HTML file.
Use the mode attribute of xsl:template to have different templates
with the same match pattern. For example have

<xsl:template match="section1" mode="leftnav">
<!-- template body for the left nav; uses -->
<!-- <xsl:apply-templates mode="leftnav"/-->
</xsl:template>

and
<xsl:template match="section1">
<!-- template body for the second transform -->
</xsl:template>

In the template body that produces the whole output document use

<!-- spit out some predefined HTML -->
<xsl:apply-templates select="pass1nodeset" mode="leftnav"/>
<!-- spit out some more HTML -->
<xsl:apply-templates select="pass2nodeset"/>
<!-- spit out some more HTML -->

Where "pass1nodeset" and "pass2nodeset" are the node sets you
apply the templates to for the two passes.
Feb 17 '07 #2

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

Similar topics

17
by: Andrae Muys | last post by:
Found myself needing serialised access to a shared generator from multiple threads. Came up with the following def serialise(gen): lock = threading.Lock() while 1: lock.acquire() try: next...
2
by: RJ | last post by:
We currently send product releases to our customers, and often have to include scripts that need to be ran on the Oracle databases (also do it for SqlServer customers, but we use a different set of...
4
by: Dave Edwards | last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot figure out how to fill a dataset with the same query but run against multiple SQL servers, the query , table structure...
3
by: Matt D | last post by:
I've got two web services that use the same data types and that clients will have to consume. I read the msdn article on sharing types...
18
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site...
5
by: paul_zaoldyeck | last post by:
does anyone know how to validate an xml file against multiple defined schema? can you show me some examples? i'm making here an xml reader.. thank you
13
by: Samir Chouaieb | last post by:
Hello, I am trying to find a solution to a login mechanism for different domains on different servers with PHP5. I have one main domain with the user data and several other domains that need...
1
by: Michael Hines | last post by:
Hello, I have a class factory that supports single inheritance but it is an error if the base appears twice. e.g class Foo(hclass(h.Vector), hclass(h.List)): should raise an exception since...
2
by: Paul McGuire | last post by:
On May 25, 8:37 am, Michael Hines <michael.hi...@yale.eduwrote: Here's a more general version of your testing code, to detect *any* diamond multiple inheritance (using your sample classes). --...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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,...
1
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
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...
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,...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.