Expand
XslCompiledTransform.Transform Method (XmlReader, XsltArgumentList, XmlWriter, XmlResolver)

Executes the transform using the input document specified by the XmlReader object and outputs the results to an XmlWriter. The XsltArgumentList provides additional run-time arguments and the XmlResolver resolves the XSLT document() function.

Namespace:  System.Xml.Xsl
Assembly:  System.Xml (in System.Xml.dll)
Syntax

'Declaration

Public Sub Transform ( _
	input As XmlReader, _
	arguments As XsltArgumentList, _
	results As XmlWriter, _
	documentResolver As XmlResolver _
)

Parameters

input
Type: System.Xml.XmlReader
An XmlReader containing the input document.
arguments
Type: System.Xml.Xsl.XsltArgumentList
An XsltArgumentList containing the namespace-qualified arguments used as input to the transform. This value can be Nothing.
results
Type: System.Xml.XmlWriter
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. This ensures that the XmlWriter has the correct output settings.
documentResolver
Type: System.Xml.XmlResolver
The XmlResolver used to resolve the XSLT document() function. If this is Nothing, the document() function is not resolved.
Exceptions

ExceptionCondition
ArgumentNullException

The input or results value is Nothing.

XsltException

There was an error executing the XSLT transform.

Examples

The following example uses an XmlSecureResolver to resolve the XSLT document() function.


' Create a resolver and specify the necessary credentials.
Dim resolver As New XmlSecureResolver(New XmlUrlResolver(), "http://serverName/data/")
Dim myCred As System.Net.NetworkCredential
myCred = New System.Net.NetworkCredential(UserName, SecurelyStoredPassword, Domain)
resolver.Credentials = myCred

Dim settings As New XsltSettings()
settings.EnableDocumentFunction = True

' Load the style sheet.
Dim xslt As New XslCompiledTransform()
xslt.Load("http://serverName/data/xsl/sort.xsl", settings, resolver)

' Transform the file.
        Using reader As XmlReader = XmlReader.Create("books.xml")

            Using writer As XmlWriter = XmlWriter.Create("output.xml")
                xslt.Transform(reader, Nothing, writer, resolver)
            End Using

        End Using


Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

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

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Community ContentAdd
Page view tracker