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

Subject: Re: [xsl] redirecting ouput to a different file?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 18 Aug 2011 21:01:32 -0400
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:

Current Thread