Re: [xsl] redirecting ouput to a different file?

Subject: Re: [xsl] redirecting ouput to a different file?
From: Dan Vint <dvint@xxxxxxxxx>
Date: Thu, 18 Aug 2011 18:07:57 -0700
Ah! my xml sample was just a small part of the document. So you used avee as the root node and anything processed after that will be written to the result-document. So I would move the <xsl:result-document> up to the highest level element that I want the output to be generated.

I think I follow you now, I was in the weeds of my bigger document.

thanks, great help as always!


At 06:01 PM 8/18/2011, you wrote:
At 2011-08-18 17:49 -0700, Dan Vint wrote:
So I can drop that <xsl:result-document href="DMC-{modelic}-{sdc}-{chapnum}-.... into all of my templates?

No ... not all. You build the result tree under <xsl:result-document> that is targeted for that file. <xsl:result-document> just starts the building of a new result tree and you build it just like you build the default result tree when not using that instruction.

I hadn't found any complex examples in my searches, but was hoping it would work like what you describe.

It does work like I describe, but I don't think you see how I'm describing it:

  <xsl:template match="avee">
    <xsl:result-document href="DMC-{modelic}-{sdc}-{chapnum}-....
      <xsl:apply-templates select="..."/>

  <xsl:template match="whatever">
    ... some stuff that goes into that result document...

The <xsl:apply-templates/> above will end up building nodes under <xsl:result-document/> even if that building is done from other templates. You mustn't copy the <xsl:result-document> into the other templates.

Once you finish building the tree and you process something after the <xsl:result-document> instruction, the tree is done with and the file is written (though likely it was being written along the way).

BTW, you can nest the instructions in order to create a separate file on the side while you are in the middle of creating another file. You just cannot re-open an <xsl:result-document/> file and add to it.

I hope this clarifies things for you.

. . . . . . . . . Ken

Contact us for world-wide XML consulting & instructor-led training
Crane Softwrights Ltd.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Legal business disclaimers:

--------------------------------------------------------------------------- Danny Vint

Panoramic Photography

voice: 619-938-3610

Current Thread