How to: Execute an XSLT Transformation from the XML Editor
Note
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
The XML Editor allows you to associate an XSLT style sheet with an XML document, perform the transformation, and view the output. The resulting output from the XSLT transformation is displayed in a new document window.
The Output property specifies the filename for the output. If the Output property is blank, a filename is generated in your temporary directory. The file extension is based on the xsl:output
element in your style sheet and can be .xml, .txt or .htm.
If the Output property specifies a filename with an .htm or .html extension, the XSLT output is previewed using Windows Server 2008 Internet Explorer. All other file extensions are opened using the default editor chosen by Windows Server 2008 Visual Studio. For example, if the file extension is .xml, Visual Studio uses the XML Editor.
To execute an XSLT transformation from an XML document
Open an XML document in the XML Editor.
Associate an XSLT style sheet with the XML document.
Add an
xml-stylesheet
processing instruction to the XML document. For example, add the following line<?xml-stylesheet type='text/xsl' href='filename.xsl'?>
to the document prolog.-or-
Add the XSLT style sheet using the Properties window. In the document Properties Window, click the Browse button for the Stylesheet field, select the XSLT style sheet, and click Open.
Click the ShowXSL Output button on the XML Editor toolbar.
Note
If there is no style sheet associated with the XML document, a dialog box prompts you to provide the style sheet to use.
The resulting output from the XSLT transformation is displayed in a new document window.
To execute an XSLT transformation from an XSLT style sheet
Open an XSLT style sheet in the XML Editor.
Specify an XML document in the Input field of the document Properties window.
Note
The XML document is the input document used for transformation. If a document is not specified when the XSLT transformation is started, the File Open dialog box appears, and you can specify a document at that time.
Click the ShowXSLT Output button on the XML Editor toolbar.
The resulting output from the XSLT transformation is displayed in a new document window.
To provide a different output file name
Specify a file name in the Output field of the document Properties window.
Click the ShowXSLT Output button on the XML Editor toolbar.
The resulting output from the XSLT transformation is displayed in a new document window and the editor used in the output window depends on the file extension of your Output document property.