XslCompiledTransform.OutputSettings Property

Note: This property is new in the .NET Framework version 2.0.

Gets an XmlWriterSettings object that contains the output information derived from the xsl:output element of the style sheet.

Namespace: System.Xml.Xsl
Assembly: System.Xml (in system.xml.dll)

public XmlWriterSettings OutputSettings { get; }
/** @property */
public XmlWriterSettings get_OutputSettings ()

public function get OutputSettings () : XmlWriterSettings

Property Value

A read-only XmlWriterSettings object that contains the output information derived from the xsl:output element of the style sheet. This value can be a null reference (Nothing in Visual Basic).

This property is populated after a successful call to the Load method. It contains information derived from the xsl:output element of a compiled style sheet. This XmlWriterSettings object can be passed to the System.Xml.XmlWriter.Create method to create the XmlWriter object to which you want to output.

The following example shows how to use the OutputSettings property to create an XmlWriter object that writes text to the console.

using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;

public class Sample {

  private const String filename = "books.xml";
  private const String stylesheet = "outputConsole.xsl";

  public static void Main() {

    // Create the XslTransform object and load the style sheet.
    XslCompiledTransform xslt = new XslCompiledTransform();

    // Load the file to transform.
    XPathDocument doc = new XPathDocument(filename);

    // Create the writer.             
    XmlWriter writer = XmlWriter.Create(Console.Out, xslt.OutputSettings);

    // Transform the file and send the output to the console.
    xslt.Transform(doc, writer);


The example uses the books.xml and outputConsole.xsl files as input.


<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
  <book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
    <title>The Confidence Man</title>
  <book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
    <title>The Gorgias</title>


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="text" omit-xml-declaration="yes"/>
  <xsl:template match="bookstore">
      Sorted Book Titles:
        <xsl:apply-templates select="book">
          <xsl:sort select="title"/>
  <xsl:template match="book">
          Title:  <xsl:value-of select="node()"/>

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0