XSLT

Overview

This Snap reads the binary data and applies the XSLT transformation rules and writes out the resulting documents. This Snap supports 1.0, 2.0 standards.



Prerequisites

The input binary data must use UTF-8 encoding. If non-UTF-8 encoded data or a special character is passed, it results in an error: "Error view with behavior continue received a new type of error." Refer to the Troubleshooting section below for steps to resolve this error.

Snap views

View Description Examples of upstream and downstream Snaps
Input This Snap has exactly one binary input view, where it accepts binary data.
Output This Snap has exactly one binary output view and produces binary datathat was produced by the XSLT Transformer.
Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:

  • Stop Pipeline Execution Stops the current pipeline execution when an error occurs.
  • Discard Error Data and Continue Ignores the error, discards that record, and continues with the remaining records.
  • Route Error Data to Error View Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap settings

Legend:
  • Expression icon (): Allows using pipeline parameters to set field values dynamically (if enabled). SnapLogic Expressions are not supported. If disabled, you can provide a static value.
  • SnapGPT (): Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
  • Suggestion icon (): Populates a list of values dynamically based on your Snap configuration. You can select only one attribute at a time using the icon. Type into the field if it supports a comma-separated list of values.
  • Upload : Uploads files. Learn more.
Learn more about the icons in the Snap settings dialog.
Field / Field set Type Description
Label String

Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if more than one of the same Snaps is in the pipeline.

Default value: XSLT

Example: XSLT
Schema String/Expression Schema of the incoming data provided as XSD.

Example: sldb:///my_schema/foo.xsd

Validate Input Checkbox

Specifies the incoming data to be validated against the provided XSD schema definition in Inbound Schema property.

Note: If you enter an Inbound schema, then you must select Validate XML and Match data types properties to derive the output as per the defined schema.
Important: Java 8 throws an error if the maxOccurs value in your XSD file is greater than 5000. To overcome this error, set maxOccurs to unbounded. If you cannot modify the XSD, perform the following:
  1. In the SnapLogic application, navigate to Manager > Project Spaces.

  2. Click on your Project.

  3. Click the Snaplexes tab and click on the Snaplex that you want to update.

    The Update Snaplex dialog box appears.

  4. Under Global properties, click + to add a Key and Value.

  5. Enter jcc.jvm_options in Key.

  6. Enter -Djdk.xml.maxOccurLimit=0 in Value.

  7. Click Update.
  8. Restart the JCC.

Default status: Deselected

XSLT String/Expression

Required. Transforms the incoming XML document based on the XSLT Transformation rules.

Important: Pass values dynamically

You can also dynamically pass parameter values to the Snap instead of passing an XML input, by configuring the intended parameter values in an upstream Mapper Snap. Ensure that the intended parameters are defined in the template's header.

For example, consider the following XML:
Sample XML
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
  <cd>
    <title>Empire Burlesque</title>
    <artist>Bob Dylan</artist>
    <country>USA</country>
    <company>Columbia</company>
    <price>10.90</price>
    <year>1985</year>
  </cd>
  <cd>
    <title>Hide your heart</title>
    <artist>Bonnie Tyler</artist>
    <country>UK</country>
    <company>CBS Records</company>
    <price>9.90</price>
    <year>1988</year>
  </cd>
  <cd>
    <title>Greatest Hits</title>
    <artist>Dolly Parton</artist>
    <country>USA</country>
    <company>RCA</company>
    <price>9.90</price>
    <year>1982</year>
  </cd>
</catalog>
To pass a dynamic value for the parameter title, you would include this parameter in the XML stylesheet template (XSLT) as follows:
XSLT to include dynamic parameters
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <xsl:param name="title"/>
   <xsl:template match="/">
      <html>
         <body>
            <xsl:for-each select="catalog/cd">
               <p>Title:<xsl:value-of select="$title"/></p>
            </xsl:for-each>
         </body>
      </html>
   </xsl:template>
</xsl:stylesheet>
Important: Fixes an issue in a previous patch wherein null binary header values are now converted to blank strings when injecting them as parameters in the stylesheet.

Example: sldb:///my_xslt/converter.xslt

Format as canonical XML Checkbox Select to produce a canonical XML output.

The canonical form of an XML output is an XML representation that excludes the XML prolog and includes the start and end tag for all the XML elements.

Default status: Deselected

Snap execution Dropdown list
Choose one of the three modes in which the Snap executes. Available options are:
  • Validate & Execute: Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default value: Execute Only

Example: Validate and Execute

Troubleshooting

Error Message Reason Resolution
Error view with behavior continue received a new type of error. If data with coding other than UTF-8 or a special character is passed to the XSLT Snap, an error is displayed during Pipeline execution. This happens because the XSLT Snap is configured to accept UTF-8 encoded data only.

Add the Transcoder Snap before the XSLT Snap.

In the Transcoder Snap Settings, specify your current character set in the Input character-set field and UTF-8 in the Output character-set field.