Language

XslCompiledTransform.OutputSettings Property

Definition

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

public:
 property System::Xml::XmlWriterSettings ^ OutputSettings { System::Xml::XmlWriterSettings ^ get(); };
public System.Xml.XmlWriterSettings? OutputSettings { get; }
public System.Xml.XmlWriterSettings OutputSettings { get; }
member this.OutputSettings : System.Xml.XmlWriterSettings
Public ReadOnly Property OutputSettings As 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 null.

Examples

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();
    xslt.Load(stylesheet);

    // 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);
    writer.Close();
  }
}
Imports System.IO
Imports System.Xml
Imports System.Xml.Xsl
Imports System.Xml.XPath

Public Class Sample
    
    Private Const filename As String = "books.xml"
    Private Const stylesheet As String = "outputConsole.xsl"   
    
    Public Shared Sub Main() 
        
        ' Create the XslTransform object and load the style sheet.
        Dim xslt As New XslCompiledTransform()
        xslt.Load(stylesheet)
        
        ' Load the file to transform.
        Dim doc As New XPathDocument(filename)
        
        ' Create the writer.             
        Dim writer As XmlWriter = XmlWriter.Create(Console.Out, xslt.OutputSettings)
        
        ' Transform the file and send the output to the console.
        xslt.Transform(doc, writer)
        writer.Close()
    
    End Sub
End Class

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

books.xml




  
    The Autobiography of Benjamin Franklin
    
      Benjamin
      Franklin
    
    8.99
  
  
    The Confidence Man
    
      Herman
      Melville
    
    11.99
  
  
    The Gorgias
    
      Plato
    
    9.99
  

outputConsole.xsl


  
  
      Sorted Book Titles:
        
          
        
   
  
          Title:  
  

Remarks

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 XmlWriter.Create method to create the XmlWriter object to which you want to output.

Applies to

See also