Re: [xsl] output the result of the transformation twice, indented and not indented, without duplicating the code

Subject: Re: [xsl] output the result of the transformation twice, indented and not indented, without duplicating the code
From: "Wolfhart Totschnig wolfhart.totschnig@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 23 May 2022 20:16:32 -0000
Thank you very much, Ken, Martin, and Graydon!

Martin's solution seems the simplest. I found that it can be shortened 
to the following:

 B B  <xsl:output method="xml" indent="no"/>
 B B  <xsl:template match="/">
 B B B B B  <xsl:apply-templates/>
 B B B B B  <xsl:result-document href="indented.xml" indent="yes">
 B B B B B B B B  <xsl:apply-templates/>
 B B B B B  </xsl:result-document>
 B B  </xsl:template>

That is, I can omit one of the <xsl:result-document>, given <xsl:output/>.

@Ken: I don't understand why <xsl:next-match/> would be better than 
<xsl:apply-templates/> and where and why I should put "priority='1000'". 
You write: "That will allow Wolfhart's stylesheet also to support a 
template rule for the root node." But the above code *is* the template 
for the root node, no?


On 23-05-22 15:29, Martin Honnen martin.honnen@xxxxxx wrote:
>
> On 23.05.2022 21:07, G. Ken Holman g.ken.holman@xxxxxxxxx wrote:
>> Martin, I would suggest a slight change to your code:
>>
>> B  <xsl:next-match/>
>>
>> ... rather than:
>>
>> B  <xsl:apply-templates/>
>>
>> ... and when the heavy-lifting code is not being imported, then put a
>> priority="1000" on the suggested match.
>>
>> That will allow Wolfhart's stylesheet also to support a template rule
>> for the root node.
>>
>>
>
> Agreed, that is a better way, should have thought about it probably as
> it is an easy way in XSLT 2 and 3.

Current Thread