xsl:output

  1. output_1-input.xml

  2. <?xml version="1.0"?>
  3. <products>
  4.   <product>
  5.     <name>Delta</name>
  6.   </product>
  7. </products>
  1. output_1-stylesheet.xsl

  2. <?xml version="1.0"?>
  3. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4. <xsl:output method="xml" omit-xml-declaration="no" encoding="UTF-8" indent="yes"/>  
  5. <xsl:template match="/">
  6.     <Products>
  7.       <Product>
  8.         <Name>
  9.           <xsl:value-of select="products/product/name"/>
  10.         </Name>
  11.       </Product>
  12.     </Products>
  13.   </xsl:template>
  14. </xsl:stylesheet>
  1. output_1-output.xml

  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <Products>
  4.   <Product>
  5.     <Name>Delta</Name>
  6.   </Product>
  7. </Products>

Comment

The element xsl:output is used to control serialization. We use method="xml" to make output to "xml" explicit ("xml" is default). To make you aware of some of the other optional attibutes, we use omit-xml-declaration="no" ("no" is default), and encoding="UTF-8" ("UTF-8" er default.), and we use indention="yes" ("no" is default).

Updated 2009-03-19