android transform xml xsl,XslCompiledTransform.Transform 方法 (System.Xml.Xsl) | Microsoft Docs
使用 URI 指定的輸入文檔執(zhí)行轉(zhuǎn)換,然后將結(jié)果輸出到 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)
參數(shù)
inputUri
輸入文檔的 URI。The URI of the input document.
XsltArgumentList,包含用作轉(zhuǎn)換輸入的命名空間限定的參數(shù)。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.
執(zhí)行 XSLT 轉(zhuǎn)換時出錯。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.
加載輸入文檔時出現(xiàn)分析錯誤。There was a parsing error loading the input document.
示例
下面的示例使用 XsltArgumentList 對象創(chuàng)建一個表示當前日期和時間的參數(shù)。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
該示例使用以下兩個數(shù)據(jù)文件作為輸入。The example uses the following two data files as input.
order.xmlorder.xml
The Handmaid's Tale19.95
Americana16.95
order .xslorder.xsl
注解
此方法使用 XmlUrlResolver 沒有用戶憑據(jù)的默認值來解析輸入文檔和 document() 在樣式表中找到的任何 XSLT 函數(shù)的實例。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. 如果這些資源中的任何一個需要身份驗證的網(wǎng)絡資源,請使用 XmlResolver 以作為其參數(shù)之一的重載,并使用 XmlResolver 所需的憑據(jù)指定。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 處理,請創(chuàng)建一個 XmlReader 啟用了此功能的,并將其傳遞給 Transform 方法。If you require DTD processing, create an XmlReader with this feature enabled, and pass it to the Transform method.
適用于
《新程序員》:云原生和全面數(shù)字化實踐50位技術專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的android transform xml xsl,XslCompiledTransform.Transform 方法 (System.Xml.Xsl) | Microsoft Docs的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android m版本 root,And
- 下一篇: android应用兼容报告,手机资讯导报