[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: output the result of the transformation twice, in
On Mon, May 23, 2022 at 06:39:30PM -0000, Wolfhart Totschnig wolfhart.totschnig@xxxxxxxxxxx scripsit: > I have an XSL stylesheet that produces a large XML document. I would like to > output the XML document twice, once indented (for human readability) and > once not indented (for faster access by other scripts). I am wondering > whether this can be done from within a single stylesheet. Sure; you store the result document in a variable, minimally: <xsl:template name="xsl:initial-template"> <xsl:variable name="result"> <xsl:apply-templates select="/node()"/> </xsl:variable> <xsl:result-document href="$path-for-humans" format="main" indent="true"> <xsl:sequence select="$result"/> </xsl:result-document> <xsl:result-document href="$path-for-machines" format="main" indent="false"> <xsl:sequence select="$result"/> </xsl:result-document> </xsl:template> <xsl:output name="main" /> has all the other things like doctype or encoding or method you would want to define for the result documents, so you can change them in one place. This works in XSLT 2 or XSLT 3; it won't work in 1. The second result document can just be xsl:sequence and will emit the variable as the transform's result document, but that way you can't use the single named output to control everything but the indent for both result documents. -- Graydon Saunders | graydonish@xxxxxxxxx ^fs oferiode, pisses swa mfg. -- Deor ("That passed, so may this.")
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|