Export (0) Print
Expand All

XslCompiledTransform.OutputSettings Property

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)

'Declaration
Public ReadOnly Property OutputSettings As XmlWriterSettings

Property Value

Type: System.Xml.XmlWriterSettings
A read-only XmlWriterSettings object that contains the output information derived from the xsl:output element of the style sheet. This value can be Nothing.

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.

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

Imports System
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 'Main 
End Class 'Sample 

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

books.xml

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

outputConsole.xsl

<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:apply-templates>
   </xsl:template>
  <xsl:template match="book">
          Title:  <xsl:value-of select="node()"/>
  </xsl:template>
</xsl:stylesheet>

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft