xsl-list
[Top] [All Lists]

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

2011-08-18 19:18:33
At 2011-08-18 15:16 -0700, dvint(_at_)dvint(_dot_)com wrote:
I'm working in v2.0. I'm thinking that <xsl:result-document> might be the
solution, but I haven't fully absorbed the implications or process. So
here is the probelm.
I have an input document that has a name like
DMC-GAASIB0-01-32-00-00-00000-051A-B_000-00.xml. In that document is a
bunch of tags that have the data that makeup this name:

            <avee>
               <modelic>GAASIB0</modelic>
               <sdc>01</sdc>
               <chapnum>32</chapnum>
               <section>0</section>
               <subsect>0</subsect>
               <subject>00</subject>
               <discode>00</discode>
               <discodev>000</discodev>
               <incode>051</incode>
               <incodev>A</incodev>
               <itemloc>B</itemloc>
            </avee>
...
The question here is, can I read file of one name and output all this
result to a new file name based upon the values in the mapping file?

Yes.

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

I'm thinking that I have to write all the content to a variable as a
nodeset (not create any output), then send that nodeset content via
xsl:result-document to the new file name.

Not at all. As long as you write nothing to the default result tree, nothing will be created for the standard output. In my example above, the built-in template rule processes the document element without adding anything to the default result tree, and the template above only creates a named result document tree rather than the default result tree, so you only get the document you name above. No need to stage stuff in a variable.

Am I going in the right direction or is there something else I should
consider?

If I've understood your requirement, it is easier than you think.

I hope this helps.

. . . . . . . . . Ken

--
Contact us for world-wide XML consulting & instructor-led training
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--