XslCompiledTransform.OutputSettings Özellik

Tanım

Stil sayfasının xsl:output öğesinden türetilen çıkış bilgilerini içeren bir XmlWriterSettings nesnesi alır.

C#
public System.Xml.XmlWriterSettings? OutputSettings { get; }
C#
public System.Xml.XmlWriterSettings OutputSettings { get; }

Özellik Değeri

XmlWriterSettings

Stil sayfasının xsl:output öğesinden türetilen çıkış bilgilerini içeren salt XmlWriterSettings okunur nesne. Bu değer olabilir null.

Örnekler

Aşağıdaki örnekte, konsola metin yazan bir XmlWriter nesne oluşturmak için özelliğinin nasıl kullanılacağı OutputSettings gösterilmektedir.

C#
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();
  }
}

Örnekte giriş olarak ve outputConsole.xsl dosyaları kullanılırbooks.xml.

books.xml

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

XML
<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>

Açıklamalar

Bu özellik, yöntemine yapılan başarılı bir çağrıdan Load sonra doldurulur. Derlenmiş stil sayfasının öğesinden xsl:output türetilen bilgileri içerir. Bu XmlWriterSettings nesne, çıkışını XmlWriter.Create almak istediğiniz nesneyi oluşturmak XmlWriter için yöntemine geçirilebilir.

Şunlara uygulanır

Ürün Sürümler
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 2.0, 2.1

Ayrıca bkz.