Well, aside from how to generate the output (xsl:result-document in 2.0 or
various processor-specific extensions in 1.0), you need to figure out how
to process the same material twice in the same stylesheet. Perhaps modes
would work.
For example, consider the following very simple document:
<exchange>
<greeting>What's up, doc?</greeting>
<response>Oooooo, you're despicable!</response>
</exchange>
and then an XSLT stylesheet (this one's 2.0, so I can use result-document)
to produce two documents:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates mode="one"/>
<xsl:apply-templates mode="two"/>
</xsl:template>
<xsl:template match="exchange" mode="one">
<xsl:result-document href="one.txt">
<xsl:apply-templates select="greeting"/>
<xsl:apply-templates select="response"/>
</xsl:result-document>
</xsl:template>
<xsl:template match="exchange" mode="two">
<xsl:result-document href="two.txt">
<xsl:apply-templates select="response"/>
<xsl:apply-templates select="greeting"/>
</xsl:result-document>
</xsl:template>
<xsl:template match="greeting">
Bugs says, "<xsl:apply-templates/>."
</xsl:template>
<xsl:template match="response">
Daffy says, "<xsl:apply-templates/>."
</xsl:template>
</xsl:stylesheet>
And the output is two text files, each with the lines in reverse order
relative to the other file.
So that's one way. As ever, there are probably others.
I have never used Microsoft's XSL processors, so I don't know how to
generate two different files with those tools. I bet someone on the list
knows that part, though.
Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)
ADAM PATRICK <adampatrick(_at_)btinternet(_dot_)com>
09/12/2005 01:43 PM
Please respond to
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
cc
Subject
Re: [xsl] Create two xml files from one xsl file
using msxml 4.0 (don't boo me please company microsoft
policy)
to explain myself a bit more... I have two xsl files
that work on one xml file what I would like is to be
able to run a single xsl file (containing the logic of
both xsl files) to create two xml files...
any avenues I should look down to work it all out
would be appreciated...
please treat me like an idiot at spelling things out
as I am new to this game...
--- David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
In pure XSLT 1.0, no, but most systems offer an
extension to do this
(saxon:output, xalan:redirect, exslt:document or
whatever) IN XSLT2.0
draft there is a standard xsl:result-document
element that does this.
David
________________________________________________________________________
This e-mail has been scanned for all viruses by
Star. The
service is powered by MessageLabs. For more
information on a proactive
anti-virus service working around the clock, around
the globe, visit:
http://www.star.net.uk
________________________________________________________________________
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--