XSLT

Transformations with XSLT stylesheets

Tab: Single

Tab: Folder

Tab: Pipeline

Tab: Parameters

Background

With this feature you have the possibility to transform files and entire folders by means of XSLT stylesheets as well as to pass on parameters.

Further links on the subject XSLT:
data2type: XML technologies → XSLT

Modifications of the transformation process

You may make various settings on the Saxon XSLT processor used.

A description of these possibilities can be found in the following section:
data2type: antillesXML help → Settings

Tab: Single

Transformations of single files

Here you can see how a single file can be transformed with XSLT into a new output file. Usually, such a file is already a XML file.

Calling up the XSLT window
  1. Select the XSLT entry in the XSL menu.
    → The XSLT window appears.
  2. → The Single tab is already selected by default with the first call.
    If this is not the case, please select now the Single tab.

XSLT window with active Single tab

Selection of the input document

As input document you need a file whose elements and data shall be transformed.
Depending on the purpose of application and the XSL stylesheet used, this file may consist of different forms of processible data.

  1. Press the Button for opening a XML filebutton.

    → The Open dialogue appears.

  2. Choose the path to the input document in your file system.
  3. Click Open.
Indication of the stylesheet file

As stylesheet you need a XSLT file which transforms the input document into the new output format.
The parameters set in the stylesheets can later be modified in antillesXML. In addition, further parameters can be added.

  1. Press the Button for opening a stylesheet button.

    → The Open dialogue appears.

  2. Choose the path to the stylesheet in your file system.
  3. Click Open.
Selection of the target document

As target document you need a file in which the transformation can be written in.

  1. Press the Button for saving the target filebutton.

    → The Save as dialogue appears.

  2. Choose the path to the target file in your file system.
  3. Enter a unique name for the target document under File name.

    XSLXSLTSingle → Selection of the target document → <xsl:output>

    The top-level element <xsl:output> basically indicates which kind of output the processor has to generate. Three output formats are possible: XML, HTML and text and in XSLT 2.0 also XHTML. They are indicated as values of the method attribute. The standard output of XSLT is XML. Except there is a HTML tag in the document, then HTML 4.0 is generated.

    Further links regarding the <xsl:output> element:
    data2type: XML technologies → XSLT → XSLT introduction → The output element

    <xsl:output method="xml|html|text|name"/>

    Please refer to the target format indicated in the stylesheet when choosing the file extension.

  4. Click Save.
Starting the transformation

Press the  Button for starting the transformation button.

→ The target document has been written to the location selected by you.

In addition, the result of the transformation is shown in the Statistics window in the Results tag.
In case error messages occur during the transformation, they are displayed in the Statistics window in the Log tag.

Tab: Folder

Transformations of entire folders

Here you can see how entire folders are transformed with XSLT into new output files.

Usually, such data are already XML files.

Calling up the XSLT window
  1. Select the XSLT entry in the XSL menu.

    → The XSLT window appears.

  2. Select the Folder tab.

XSLT window with active Folder tab

Selection of the input folder

As input folder you need a folder whose files shall be transformed.

Depending on the purpose of application and the XSL stylesheet used, this folder may consist of different forms of processible files.

  1. Press the  Button for opening a XML file button.

    → The Search folder dialogue appears.

  2. Choose the path to the input folder in your file system.
  3. Click OK.
Indication of the stylesheet file

As stylesheet you need a XSLT file which transforms the input documents into the new output format.

  1. Press the  Button for opening a stylesheet button.

    → The Open dialogue appears.

  2. Choose the path to the stylesheet in your file system.
  3. Click Open.
Selection of the target folder

As target folder you need a folder in which the target documents are stored.

  1. Press the  Button for saving the target file button.

    → The Search folder dialogue appears.

  2. Choose the path to the target folder in your file system.
  3. Click OK.
Starting of the transformation
  1. Press the  Button for starting the transformation button.

    → The target documents have been written to the location selected by you.

    In addition, the result of the transformation is displayed in the Statistics window in the Results tab.
    In case error messages occur during the transformation, they are displayed in the Statistics window in the Log tab.

Tab: Pipeline

Transformations with several XSL stylesheets

Here you can see how to transform an input document with several, successive stylesheets.

With the help of this feature, processing loops can be realised. After each transformation, the input document is passed on to the following stylesheet in virtual form and passes through a further transformation process.
Only after the sequential processing by an included stylesheet the final target document is generated and stored in the folder.

Further links on the subject XSL pipelines:
Sam Page Blog: Using XML → XSL Pipeline Processing

Calling up the XSLT window
  1. Select the XSLT entry in the XSL menu.

    → The XSLT window appears.

  2. Select the Pipeline tab.

XSLT window with active Pipeline tab

Selection of the input document

As input document you need a file whose elements and data shall be transformed.

Depending on the purpose of application and the XSL stylesheet used, this file may consist of different forms of processible data.

  1. Press the  Button for opening a XML file button.

    → The Open dialogue appears.

  2. Choose the path to the input document in your file system.
  3. Click Open.
Selection of the target document

As target document you need a file in which the transformation can be written in.

  1. Press the  Button for saving the target file button.

    → The Save as dialogue appears.

  2. Choose the path to the target folder in your file system.
  3. Enter a unique name for the target document under File name.

    XSLXSLTPipeline → Selection of the target document → <xsl:output>

    The top-level element <xsl:output> basically indicates which kind of output the processor has to generate. Three output formats are possible: XML, HTML and text and in XSLT 2.0 also XHTML. They are indicated as values of the method attribute. The standard output of XSLT is XML. Except there is a HTML tag in the document, then HTML 4.0 is generated.

    Further links regarding the <xsl:output> element:
    data2type: XML technologies → XSLT → XSLT introduction → The output element

    <xsl:output method="xml|html|text|name"/>

    Please refer to the target format indicated in the last stylesheet when choosing the file extension.

  4. Click Save.
Indication of the stylesheet files

As stylesheet you need one or more XSLT files which transform the input document into the new output format.

Manual selection of the stylesheets
  • Generation of the first stylesheet
    Window for the generation of the first stylesheet
    1. Double-click the empty field in the Stylesheets column.
      → The Open dialogue appears.
    2. Choose the path to the stylesheet in your file system.
    3. Click Open.
  • Generation of the following stylesheets
    Window for the generation of the following stylesheets
    1. Double-click the newly generated empty field in the Stylesheets column.
      → The Open dialogue appears.
    2. Choose the path to the stylesheet in your file system.
    3. Click Open.
  • Removing of stylesheets in the list entries

    Removing of single rows

    Window for the removal of single stylesheets in the list entries
    1. Select the stylesheet to be removed with a click in the first column before the appropriate row.
      → The appropriate row is now highlighted in blue.
    2. In order to remove the row, press now the Delete key.
      → Now, the appropriate row is deleted.

    Removing of several rows at the same time

    Window for the removal of several rows at the same time
    • In case the stylesheets shall be selected individually:
      1. Press and hold the Ctrl key.
      2. Select the stylesheets to be removed with a click in the first column before the appropriate row.
        → The appropriate rows are now highlighted in blue.
      3. In order to remove the rows, press now the Delete key.
        → Now, the appropriate rows are deleted.
    • In case the stylesheets lie below each other:
      1. Press and hold the Shift key.
      2. Select the top and bottom stylesheet to be removed with a click in the first column before the appropriate row.
        → The appropriate rows are now highlighted in blue.
      3. In order to remove the rows, press now the Delete key.
        → Now, the appropriate rows are deleted.
  • Activation & deactivation of the stylesheets in the pipeline

    Activation of the stylesheets in the pipeline

    Window for activating the stylesheets in the pipeline

    Activate the check box in the Include Stylesheet column next to the stylesheets to be used.
    → The stylesheets having a check mark are part of the pipeline chain.

    Deactivation of the stylesheets in the pipeline

    Deactivate the check box in the Include Stylesheet column next to the stylesheet to be used.
    → Only the stylesheets having a check mark are part of the pipeline chain.

  • Saving a pipeline in a file

    You may save the generated pipelines to a XML file and then reuse them.

    XSLXSLTPipeline → Saving a pipeline → The structure of the pipeline in XML

<?xml version="1.0"?>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <string>
      C:\workspace\antillesXML\testFiles\XSL\XSLT\style\style_01.xsl
   </string>                                            
   <string>
      C:\workspace\antillesXML\testFiles\XSL\XSLT\style\style_02.xsl
   </string>
   <string>
      C:\workspace\antillesXML\testFiles\XSL\XSLT\style\style_03.xsl
   </string>
   <string>
      C:\workspace\antillesXML\testFiles\XSL\XSLT\style\style_04.xsl
   </string>
</ArrayOfString>

The XML file which is generated for the pipeline contains the paths to the stylesheets. The sequential order of the pipline is taken into account.

The XML file does not contain information regarding the stylesheets being already activated for the transformation process.
→ These have to be reactivated manually.

Selection of the already generated pipeline

  1. Press the  Button for selecting an already generated pipeline  button.

    → The Open dialogue appears.

  2. Choose the path to the already generated pipeline in your file system.
  3. Click Open.
  4. Activate the required stylesheets in the pipeline.
Starting the transformation

Press the  Button for starting the transformation button.

→ The stylesheets are now run through in the pipeline and the target document is written to the location selected by you.

In addition, the result of the transformation is shown in the Statistics window in the Results tab.
In case error messages occur during the transformation, they are displayed in the Statistics window in the Log tag.

Tab: Parameters

Transformations with passing of parameters

Here you can see how to pass parameters to a XSLT stylesheet.

Requirements for the passing of parameters:

Select the required tab in the XSLT window and there the files or folders needed for the transformation process.

Then select the Parameters tab.

XSLT window with active Parameters tab

Passing the parameters

XSL → XSLT → Parameters → <xsl:param>

Parameters can be found in the XSLT stylesheet in the following form:

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:param name="collection"/> 
<html> 
<body> 
<h1><xsl:value-of select="$collection"/></h1>

Here a parameter is declared as global element.

The argument for the parameter passed on by the XSLT processor is called up within the <h1> element.

Further links regarding the <xsl:param> element:

data2type: XML technologies → XSLT → XSLT 1.0 reference → xsl:param 
">w3schools: XSLT → <xsl:param> element

Indication of the parameter values

Display of the parameter names of the previously selected XSLT stylesheet

The parameter names of the previously selected XSLT styesheets are listed in the left column under Parameter.

Entering the value to be passed on

Enter the value to be passed on to the appropriate parameter in the right column under Value.

Saving the parameter values

Press the  Button for saving the parameters  button.

→ During the next transformation process, the values are passed on as arguments to the XSLT processor.

Switch back to the previously selected tab and start the transformation.

XSL → XSLT → Parameters → <xsl:param>

The result of the passing of parameters from our example:
<html> <body> <h1>data2type</h1>

The argument passed on during the transformation can now be found as headline in the HTML code.