Altova StyleVision 2024 Professional Edition

XSLT Templates

Home Prev Top Next

XSLT files can be imported into an SPS, and XSLT templates in them will be available to the stylesheet as global templates. If, during the processing of the XML document, one of the XML nodes matches a node in an imported XSLT template, then the imported XSLT template is applied to that node. If the imported XSLT file contains named templates, these are available for placement in the design.

 

Note the following points:

 

Imported XSLT templates cannot be modified in StyleVision.

XSLT templates are not supported in Authentic View.

 

Importing the XSLT file

To import an XSLT File, do the following:

 

1.In the Design Overview sidebar (screenshot below), click the Add New XSLT File link.

 

DesOviewXSLTFiles

 

2.In the Open dialog that appears, browse for the required XSLT file, select it, and click Open. The XSLT file is imported. An xsl:import statement is added to the XSLT stylesheet, and, in the Design Tree sidebar (screenshot below), the XSLT Templates contained in the imported XSLT file are displayed under the XSLT Templates heading.

 

DesTreeXSLTTemplates

 

There are two types of imported XSLT templates: (i) match templates (indicated by Match), and (ii) named templates (indicated by Name). In the Design Tree, these two types are listed with (i) the value of the select attribute of match templates, and (ii) by the value of the name attribute of named templates, respectively.

 

Match templates

Match templates will be used when a template, in the course of processing, applies templates to a node in the XML document instance, and the match template is selected to be applied. This will happen when the qualified name of the XML node matches the qualified name of the imported match template. If a global template has been created in the SPS that has the same qualified name, then it has precedence over an imported template and will be used. If there are several imported XSLT files, the file imported first (and listed first in the XSLT code) has the lowest precedence, followed by the second lowest precedence for the file imported second, and so on.

 

Named templates

A named template can be dragged from the Design Tree to any location in the design. At this location, it will be created as an xsl:call-template element (screenshot below) that calls the named template.

 

CallNamedTemplate

 

The effect of this in the output is to implement the named template at that location in the design. This can be useful for inserting content that is independent of both the XML instance document as well as of the XSLT stylesheet.

 

© 2017-2023 Altova GmbH