一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

XSLT Transformations with the XslTransform Cl...

 素行 2007-01-11
.NET Framework Developer‘s Guide  

XSLT Transformations with the XslTransform Class

The goal of the Extensible Stylesheet Language Transformation (XSLT) is to transform the content of a source XML document into another document that is different in format or structure. For example, to transform XML into HTML for use on a Web site or to transform it into a document that contains only the fields required by an application. This transformation process is specified by the W3C XSL Transformations (XSLT) Version 1.0 recommendation located at www.w3.org/TR/xslt. In the .NET Framework, the XslTransform class, found in the System.Xml.Xsl namespace, is the XSLT processor that implements the functionality of this specification. There are a small number of features that have not been implemented from the W3C XSLT Version 1.0 recommendation, listed in Outputs from an XslTransform. The following figure shows the transformation architecture of the .NET Framework.

Transformation Architecture

The XSLT recommendation uses XPath to select parts of an XML document, where XPath is a query language used to navigate nodes of a document tree. As shown in the diagram, the .NET Framework implementation of XPath is used to select parts of XML stored in several classes, such as an XmlDocument, an XmlDataDocument, and an XPathDocument. An XPathDocument is an optimized XSLT data store, and when used with XslTransform, it provides XSLT transformations with good performance.

The following table list commonly used classes when working with XslTransform and XPath and their function.

Class or Interface Function
XPathNavigator It is an API that provides a cursor style model for navigating over a store, along with XPath query support. It does not provide editing of the underlying store. For editing, use the XmlDocument class.
IXPathNavigable It is an interface that provides a CreateNavigator method to an XPathNavigator for the store.
XmlDocument It enables editing of this document. It implements IXPathNavigable, allowing document-editing scenarios where XSLT transformations are subsequently required. For more information, see XmlDocument Input to XslTransform.
XmlDataDocument It is derived from the XmlDocument. It bridges the relational and XML worlds by using a DataSet to optimize storage of structured data within the XML document according to specified mappings on the DataSet. It implements IXPathNavigable, allowing scenarios where XSLT transformations can be performed over relational data retrieved from a database. For more information, see XML Integration with Relational Data and ADO.NET.
XPathDocument This class is optimized for XslTransform processing and XPath queries, and it provides a read-only high performance cache. It implements IXPathNavigable and is the preferred store to use for XSLT transformations.
XPathNodeIterator It provides navigation over XPath node sets. All XPath selection methods on the XPathNavigator return an XPathNodeIterator. Multiple XPathNodeIterators can be created over the same store each representing a selected set of nodes.

The following code example loads an XSL style sheet, reads a file called mydata.xml into an XPathDocument, and performs a transformation on the data on a fictitious file called myStyleSheet.xsl, sending the formatted output to the console.

[Visual Basic]
Imports System
Imports System.IO
Imports System.Xml
Imports System.Xml.XPath
Imports System.Xml.Xsl
Public Class Sample
Private filename As [String] = "mydata.xml"
Private stylesheet As [String] = "myStyleSheet.xsl"
Public Shared Sub Main()
Dim xslt As New XslTransform()
xslt.Load(stylesheet)
Dim xpathdocument As New XPathDocument(filename)
Dim writer As New XmlTextWriter(Console.Out)
writer.Formatting = Formatting.Indented
xslt.Transform(xpathdocument, Nothing, writer, Nothing)
End Sub ‘Main
End Class ‘Sample
[C#]
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
public class Sample
{
private const String filename = "mydata.xml";
private const String stylesheet = "myStyleSheet.xsl";
public static void Main()
{
XslTransform xslt = new XslTransform();
xslt.Load(stylesheet);
XPathDocument xpathdocument = new
XPathDocument(filename);
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.Formatting=Formatting.Indented;
xslt.Transform(xpathdocument, null, writer, null);
}
}

See Also

XslTransform Class Implements the XSLT Processor | XSLT Processor Implementation of Discretionary Behaviors in the XslTransform Class | XPathNavigator in Transformations | XPathNodeIterator in Transformations | XPathDocument Input to XslTransform | XmlDataDocument Input to XslTransform | XmlDocument Input to XslTransform | XslTransform Class | XslTransform Members

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多

    亚洲中文字幕视频在线观看| 国产日韩精品欧美综合区| 国产黑人一区二区三区| 大尺度激情福利视频在线观看| 久久精品国产在热久久| 日本人妻精品有码字幕| 丰满少妇被粗大猛烈进出视频| 日韩精品成区中文字幕| 激情综合网俺也狠狠地| 免费观看在线午夜视频| 成人免费视频免费观看| 精品日韩视频在线观看| 亚洲五月婷婷中文字幕| 欧美野外在线刺激在线观看| 激情偷拍一区二区三区视频| 国产av大片一区二区三区| 一区二区三区免费公开| 精品国自产拍天天青青草原| 欧美乱视频一区二区三区| 欧美黑人黄色一区二区| 一级欧美一级欧美在线播| 亚洲一区二区三区国产| 激情少妇一区二区三区| 东北女人的逼操的舒服吗| 91插插插外国一区二区婷婷| 久久精品福利在线观看| 久久99爱爱视频视频| 青青草草免费在线视频| 99久久精品午夜一区二区| 果冻传媒精选麻豆白晶晶| 亚洲最新中文字幕在线视频| 国产精品视频第一第二区| 成人精品一区二区三区综合| 国产又粗又猛又大爽又黄| 日韩欧美三级视频在线| 亚洲一区二区精品免费视频| 高清一区二区三区四区五区| 欧美日韩一区二区午夜| 日韩女优视频国产一区| 九七人妻一区二区三区| 欧美久久一区二区精品|