Creating a new file with output in XSL

Sometimes its useful to create several files from one huge input xml file. To do this in version 1.0 you have to make use of extensions in your xsl processor.

XSL 1.0

Saxon

Use the saxon:output command


  <saxon:output method="xml" href="articles.xml">
    <fishtank>
      <fish>Green fish</fish>
      <fish>Blue Fish</fish>
    </fishtank>
  </saxon:output>
      

XSL 2.0

Finally you do not have to rely on extensions but can use official xsl to do this.


  <xsl:result-document href="articles.xml">
    <fishtank>
      <fish>Green fish</fish>
      <fish>Blue Fish</fish>
    </fishtank>
  </xsl:result-document>
    

xsl:output attributes

encoding

When outputting HTML you can set this to US-ASCII. This might help if you see strange chars such as  in your output.

Published: Tuesday, 24 August 2004