Altova XMLSpy 2024 Enterprise Edition

Processing with XSLT and XQuery

Home Prev Top Next

XML documents can be processed with XSLT or XQuery documents to produce output documents. XMLSpy has built-in XSLT 1.0, XSLT 2.0, XSLT 3.0, XQuery 1.0, and XQuery 3.0 processors. The following processing-related features are available in the GUI:

 

Assigning XSLT stylesheets

Go to XSLT

XSLT parameters and XQuery variables

XSLT transformations

XQuery executions

Automating XML tasks with RaptorXML

 

Assigning XSLT stylesheets

You can assign an XSLT stylesheet to an XML document via the XSL/XQuery | Assign XSL command (browse for the file in the dialog (screenshot below) that pops up). The assignment is entered in the XML document as a processing instruction (PI) having the standard XSLT target defined by the W3C: xml-stylesheet. This assignment is used when an XSLT transformation is invoked (XSL/XQuery | XSL Transformation).

 

Additionally, an XSLT-for-FO stylesheet can be assigned with the XSL/XQuery | Assign XSL:FO command (browse for the file in the dialog (screenshot below) that pops up). The assignment is entered in the XML document as a processing instruction (PI) having the Altova-defined target: altova_xslfo.  This assignment is used when an XSLT-for-FO transformation is invoked (XSL/XQuery | XS:FO Transformation).

XSLTAssign

You can also select a global resource to specify the XSLT file. A global resource is an alias for a file or folder. The target file or folder can be changed within the GUI by changing the active configuration of the global resource (via the menu command Tools | Active Configuration). Global resources therefore enable the assigned XSLT file to be switched from one to another, which can be useful for testing. How to use global resources is described in the section Altova Global Resources.

 

If a previous assignment using either of these PI targets exists, then you are asked whether you wish to overwrite the existing assignment.

 

Go to XSLT

The XSL/XQuery | Go to XSL command opens the XSLT file that has been assigned to the XML document.

 

XSLT parameters and XQuery variables

XSLT parameters and XQuery variables can be defined, edited, and deleted in the dialog that appears on clicking the command XSL/XQuery | XSLT Parameters / XQuery Variables. The parameter/variable values defined here are used for all XSLT transformations and XQuery executions in XMLSpy. However, these values will not be passed to external engines such as MSXML. For the details of how to use this feature, see the User Reference section.

 

XSLT transformations

Two types of XSLT transformation are available:

 

Standard XSLT transformation (XSL/XQuery | XSL Transformation): The output of the transformation is displayed in a new window or, if specified in the stylesheet, is saved to a file location. The engine used for the transformation is specified in the XSL tab of the Options dialog (Tools | Options).

XSL-for-FO transformation (XSL/XQuery | XSL-FO Transformation): The XML document is transformed to PDF in a two-step process. In the first step, the XML document is transformed to an FO document using the XSLT processor specified in the XSL tab of the Options dialog (Tools | Options); note that you can also select (at the bottom of the tab) the XSLT engine that comes with some FO processors such as FOP. In the second step, the FO document is processed by the FO processor specified in the XSL tab of the Options dialog (Tools | Options) to produce PDF output.

 

Note: An FO document (which is a particular type of XML document) can be transformed to PDF by clicking the XSL:FO transformation command. When the source document is an FO document, the second step of the two-step process for this command is executed directly.

 

XQuery executions

An XQuery document can be executed on the active XML document by clicking the command XSL/XQuery | XQuery Execution. You are prompted for the XQuery file, and the result document is displayed in a new window in the GUI.

 

Automating XML tasks with RaptorXML

Altova RaptorXML is an application that provides XML validation, XSLT transformations, and XQuery executions. It can be used from the command line, via a COM interface, in Java programs, and in .NET applications. Tasks such as XSLT transformation can therefore be automated with the use of RaptorXML. For example, you can create a batch file that calls RaptorXML to transform a set of documents. See the RaptorXML documentation for details.

 

© 2017-2023 Altova GmbH