xsl-list
[Top] [All Lists]

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

2022-05-23 15:16:38
Thank you very much, Ken, Martin, and Graydon!

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

   <xsl:output method="xml" indent="no"/>
   <xsl:template match="/">
      <xsl:apply-templates/>
      <xsl:result-document href="indented.xml" indent="yes">
         <xsl:apply-templates/>
      </xsl:result-document>
   </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(_dot_)honnen(_at_)gmx(_dot_)de wrote:

On 23.05.2022 21:07, G. Ken Holman 
g(_dot_)ken(_dot_)holman(_at_)gmail(_dot_)com wrote:
Martin, I would suggest a slight change to your code:

  <xsl:next-match/>

... rather than:

  <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.


--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>