XSLT is the abbreviation of Extensible Stylesheet Language Transformations, which is a language that converts XML documents. T in XSLT represents transformation in English. It is part of the XSL (Extensible stylesheet language) specification. Another part of the XSL specification is XSLF (F stands for Formatting Objects), also known as XSL-FO or XSLFO.
XSLT is an XML conversion language that converts XML documents into another XML document. That is, all data or part of the data of the source document (selected with XPath) are generated in another XML document or other file formats that can be directly displayed or printed (such as HTML files, RTF files or TeX files). In this conversion process, the following are specifically involved:
Add some fixed tags like HTML documents
Move text
Sort text
The converted source XML document has a tree structure. XSLT language is a declarative language, that is, the XSLT program itself only contains some conversion rules. And these rules can be applied recursively to the transformation process. XSLT itself is also an XML document, so it must also comply with strict XML specifications.
How to: Start debugging XSLTYou can use the XSLT debugger to debug an XSLT stylesheet or XSLT application. During debugging, you can execute one line of code at a time by entering and executing the code line by line, executing the code line by line, or jumping out of the code. The commands that use code to execute functions line by line in XSLT debuggers and other Visual Studio debuggers are the same. After debugging begins, the XSLT debugger opens a window to display the input document and XSLT output.
XML Editor
The debugger can be started from the XML editor. This allows debugging when designing style sheets.
Start debugging from the stylesheet
Open the stylesheet in the XML editor.
Select Debug XSL from the XML menu.
Start debugging from XML input document
Open an XML document in the XML editor.
Select Debug XSL from the XML menu.
XSLT in other languages
It is also possible to enter and execute XSLT line by line while debugging the application. When the F11 key is pressed in the System.Xml.Xsl.XslCompiledTransform.Transform call, the debugger can enter and execute the XSLT code line by line.
Notice: |
|---|
Entering and executing XSLT from the XslTransform class is not supported. The XslCompiledTransform class is the only XSLT processor that supports entry and execution of XSLT line by line while debugging. |
Start debugging an XSLT application
When instantiating the XslCompiledTransform object, set the enableDebug parameter to true in the code.
This setting notifies the XSLT processor to create debug information when compiling the code.
Press F11 to enter and execute the XSLT code line by line.
The XSLT stylesheet is loaded into the new document window and the XSLT debugger will also be started.
Alternatively, you can add breakpoints to the stylesheet and run the application.
Example
Here is an example of a C# XSLT program. This example shows how to enable XSLT debugging.
How to open XSLT file:using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
namespace ConsoleApplication
{
class Program
{
private const string sourceFile = @c:/data/xsl_files/books.xml;
private const string stylesheet = @c:/data/xsl_files/belowAvg.xsl;
private const string outputFile = @c:/data/xsl_files/output.xml;
static void Main(string[] args)
{
// Enable XSLT debugging.
XslCompiledTransform xslt = new XslCompiledTransform(true);
// Compile the style sheet.
xslt.Load(stylesheet)
// Execute the XSLT transform.
FileStream outputStream = new FileStream(outputFile, FileMode.Append);
xslt.Transform(sourceFile, null, outputStream);
}
}
}
When opening XSLT files, you can refer to the HTML file opening method . The two types of file opening methods are the same!