使用 URI 指定的输入文档执行转换,然后将结果输出到 XmlWriter。Executes the transform using the input document specified by the URI and outputs the results to an XmlWriter. The XsltArgumentList provides additional run-time arguments.

public:

void Transform(System::String ^ inputUri, System::Xml::Xsl::XsltArgumentList ^ arguments, System::Xml::XmlWriter ^ results);

public void Transform (string inputUri, System.Xml.Xsl.XsltArgumentList? arguments, System.Xml.XmlWriter results);

public void Transform (string inputUri, System.Xml.Xsl.XsltArgumentList arguments, System.Xml.XmlWriter results);

member this.Transform : string * System.Xml.Xsl.XsltArgumentList * System.Xml.XmlWriter -> unit

Public Sub Transform (inputUri As String, arguments As XsltArgumentList, results As XmlWriter)

参数

inputUri

输入文档的 URI。The URI of the input document.

XsltArgumentList,包含用作转换输入的命名空间限定的参数。An XsltArgumentList containing the namespace-qualified arguments used as input to the transform. 此值可为 null。This value can be null.

The XmlWriter to which you want to output.

If the style sheet contains an xsl:output element, you should create the XmlWriter using the XmlWriterSettings object returned from the OutputSettings property. 这样可以确保 XmlWriter 的输出设置是正确的。This ensures that the XmlWriter has the correct output settings.

例外

inputUri 或 results 值为 null。The inputUri or results value is null.

执行 XSLT 转换时出错。There was an error executing the XSLT transform.

inputtUri 值包含无法找到的文件名或目录。The inputtUri value includes a filename or directory cannot be found.

无法解析 inputUri 值。The inputUri value cannot be resolved.

- 或 --or-

处理该请求时出错。An error occurred while processing the request.

inputUri 不是有效的 URI。inputUri is not a valid URI.

加载输入文档时出现分析错误。There was a parsing error loading the input document.

示例

下面的示例使用 XsltArgumentList 对象创建一个表示当前日期和时间的参数。The following example uses an XsltArgumentList object to create a parameter representing the current date and time.

using System;

using System.IO;

using System.Xml;

using System.Xml.Xsl;

public class Sample

{

public static void Main()

{

// Create the XslCompiledTransform and load the stylesheet.

XslCompiledTransform xslt = new XslCompiledTransform();

xslt.Load("order.xsl");

// Create the XsltArgumentList.

XsltArgumentList xslArg = new XsltArgumentList();

// Create a parameter which represents the current date and time.

DateTime d = DateTime.Now;

xslArg.AddParam("date", "", d.ToString());

// Transform the file.

using (XmlWriter w = XmlWriter.Create("output.xml"))

{

xslt.Transform("order.xml", xslArg, w);

}

}

}Imports System.IO

Imports System.Xml

Imports System.Xml.Xsl

Public Class Sample

Public Shared Sub Main()

' Create the XslCompiledTransform and load the stylesheet.

Dim xslt As New XslCompiledTransform()

xslt.Load("order.xsl")

' Create the XsltArgumentList.

Dim xslArg As New XsltArgumentList()

' Create a parameter which represents the current date and time.

Dim d As DateTime = DateTime.Now

xslArg.AddParam("date", "", d.ToString())

Using w As XmlWriter = XmlWriter.Create("output.xml")

' Transform the file.

xslt.Transform("order.xml", xslArg, w)

End Using

End Sub

End Class

该示例使用以下两个数据文件作为输入。The example uses the following two data files as input.

order.xmlorder.xml

The Handmaid's Tale

19.95

Americana

16.95

order .xslorder.xsl

注解

此方法使用 XmlUrlResolver 没有用户凭据的默认值来解析输入文档和 document() 在样式表中找到的任何 XSLT 函数的实例。This method uses a default XmlUrlResolver with no user credentials to resolve the input document and any instances of the XSLT document() function found in the style sheet. 如果这些资源中的任何一个需要身份验证的网络资源,请使用 XmlResolver 以作为其参数之一的重载,并使用 XmlResolver 所需的凭据指定。If any of these resources are located on a network resource that requires authentication, use the overload that takes an XmlResolver as one of its arguments and specify an XmlResolver with the necessary credentials.

使用 XmlReader 带有默认设置的来加载输入文档。An XmlReader with default settings is used to load the input document. 在上禁用 DTD 处理 XmlReader 。DTD processing is disabled on the XmlReader. 如果需要 DTD 处理,请创建一个 XmlReader 启用了此功能的,并将其传递给 Transform 方法。If you require DTD processing, create an XmlReader with this feature enabled, and pass it to the Transform method.

适用于

android transform xml xsl,XslCompiledTransform.Transform 方法 (System.Xml.Xsl) | Microsoft Docs相关推荐

  1. c#endread怎么打印出来_NetworkStream.EndRead(IAsyncResult) 方法 (System.Net.Sockets) | Microsoft Docs...

    处理异步读取的结束.Handles the end of an asynchronous read. public: override int EndRead(IAsyncResult ^ async ...

  2. android语音识别服务,使用语音服务 API 的语音识别 - Xamarin | Microsoft Docs

    使用 Azure Speech Service 进行语音识别Speech recognition using Azure Speech Service 01/14/2020 本文内容 Azure Sp ...

  3. expander菜单控件_Expander 类 (System.Windows.Controls) | Microsoft Docs

    Adds a specified object as the child of a ContentControl. (继承自 ContentControl) 为指定的路由事件添加路由事件处理程序,并将 ...

  4. 详解Java解析XML的四种方法

    http://developer.51cto.com  2009-03-31 13:12  cnlw1985  javaeye  我要评论(8) XML现在已经成为一种通用的数据交换格式,平台的无关性 ...

  5. xsl调用java方法传参_Java中的XSL转换:一种简单的方法

    xsl调用java方法传参 XSL转换 (XSLT)是将一个XML文档转换为另一个XML文档的强大机制. 但是,在Java中,XML操作相当冗长和复杂. 即使是简单的XSL转换,也必须编写几十行代码- ...

  6. php xmlreader nodetype,XmlNodeReader.NodeType 属性 (System.Xml) | Microsoft Docs

    获取当前节点的类型.Gets the type of the current node. public: virtual property System::Xml::XmlNodeType NodeT ...

  7. php xmlreader nodetype,XmlReader.NodeType 属性 (System.Xml) | Microsoft Docs

    当在派生类中被重写时,获取当前节点的类型.When overridden in a derived class, gets the type of the current node. public: ...

  8. php 字符串转换xml,php 数组转xml字符串、xml字符串转数组方法案例

    数组转xml字符串方法:两种方法/** * 数组转xml字符串方法1 * @param  arary $data 数组数据 * @param  boolean $type 是否需要根节 */ func ...

  9. XML序列之System.Xml.Serialization

    1,对象 public class School{public string Name { get; set; }public List<Classes> listClasses { ge ...

最新文章

  1. datafactory生成mysql数据_测试数据生成工具DataFactory的使用
  2. PHP学习笔记-GD库与Jpgraph的使用
  3. stm32f10x_it.c 定义的程序列表模板(stm32f103x_it.c中放的是中断的空函数)
  4. Pokemon Go火了,他却要破产了...
  5. 【专栏必读】王道考研408数据结构万字笔记(有了它不需要你再做笔记了):各章节内容概述导航和思维导图
  6. python 第13天作业
  7. Android模拟器——Windows上比较适合王者荣耀的是腾讯手游助手
  8. Qt配置使用VS2010进行开发
  9. 比较有深度的博客收藏
  10. 吴恩达机器学习Optional Lab - Neurons and Layers
  11. 阿里云运行python_阿里云运行python代码
  12. 联想服务器光驱安装win7系统,联想光盘安装win7系统教程
  13. xp启用计算机共享打印机,Win7如何共享xp的打印机
  14. 如何给Ubuntu系统清理垃圾
  15. 高分系列(GF1-GF7)卫星介绍
  16. MySQL架构原理(三)线程模型和文件模型
  17. HDU 6078 Wavel Sequence
  18. DELL服务器 ubuntu系统 全新硬盘识别不到问题解决及对硬盘做GPT分区
  19. a或b search vim_vim入门,进阶与折腾
  20. 学习笔记-零基础学习人工智能(0)

热门文章

  1. 文巾解题 1046. 最后一块石头的重量
  2. 深度学习核心技术精讲100篇(五十五)- 基于OpenCV实现棋盘图像识别
  3. 深度学习核心技术精讲100篇(三十)-ClickHouse在字节跳动广告业务中的应用
  4. 电脑进入pe时蓝屏_电脑密码忘记不要慌!学会这一招帮大忙
  5. BERT入门讲解(内附源码)【自然语言处理NLP-100例】
  6. Python入门100题 | 第004题
  7. LeetCode-位运算-36. 只出现一次的数字
  8. Java的clone()用法实例解析
  9. Int,Long比较重使用equal替换==
  10. spring data redis使用示例