Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > multiple pass with XSL on same XML file

Reply
Thread Tools

multiple pass with XSL on same XML file

 
 
andrew_nuss@yahoo.com
Guest
Posts: n/a
 
      02-16-2007
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.

 
Reply With Quote
 
 
 
 
A. Bolmarcich
Guest
Posts: n/a
 
      02-17-2007
On 2007-02-16, http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:
> 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.
 
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
write to the same file from multiple processes at the same time? gabor Python 19 05-31-2005 01:57 PM
Re: write to the same file from multiple processes at the same time? Jp Calderone Python 4 05-31-2005 07:54 AM
Re: write to the same file from multiple processes at the same time? Jp Calderone Python 7 05-28-2005 06:47 PM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
Re: write to the same file from multiple processes at the same time? Jp Calderone Python 0 05-27-2005 02:17 PM



Advertisments