Loading

JDF ticket creation using XSLT

Introduction

This topic describes:

  • How you can use XSLT to transform JDF tickets and create JDF tickets from XML.

  • Limitations and considerations when using XSLT.

This topic does not explain XSLT or the XSL syntax. You can find XSLT tutorials and documents online, for example, https://www.w3.org/TR/1999/REC-xslt-19991116 and http://lenzconsulting.com/how-xslt-works/.

A few example XSLT files and related XML and JDF files can be downloaded from the Examples of XML files.

XSLT import Workflow

The XSLT import workflow within PRISMAdirect is almost the same as the "standard" JDF import workflow. The only difference is that there is an extra step after the import of the XML or JDF file. And that is the transformation step.

After the transformation step, the XSLT import workflow is the same as the JDF import workflow without the transformation step:



Standard JDF import workflow:



Change the JDF ticket or link to a product in PRISMAdirect

Using XSLT, you can transform the JDF ticket to:

  • Add settings to the JDF ticket when the sending JDF manager does not supply these settings.

    For example:

    • Add a staple to the job settings when the CustomerJobName is "Job x"

  • Alter JDF settings when they are not correct.

    For example:

    • Change plexity setting from "Simplex" to "Duplex" when the job name has a certain string in the content

  • Link the JDF job to a specific product in PRISMAdirect when certain criteria are met.

    For example:

    • If a booklet attributes are used in the original JDF ticket (for instance FoldCatalog F4-1) you can link the job to a certain product with an attached automation template (see image below).



Use XSLT to create a JDF ticket from an XML file

Using XSLT, you can create a JDF ticket from an XML file. The proposed method is to create a JDF ticket template inside the XSLT code. Through the transformation you can fill the required JDF parts from the XML file. You can also create your own "logic" inside the XSLT code. For instance if copies and quantity can be used together, you can multiply them in the XSLT code. A JDF ticket should always contains items for the order and job part in PRISMAdirect

  1. Create your XSLT file.

    For the items that you can use in a JDF ticket, you can take a look at the default mapping files of PRISMAdirect. Because of the flexibility of PRISMAdirect in creating any order or product item, the possibilities in JDF can be almost unlimited.

  2. Test your XSLT files.

    When debugging, you can test the XSLT code in for instance Notepad++ (with the plugin XML tools installed) or Visual Studio Professional.

    XSLT debugging in Notepad++

    1. To test your XSLT code, open the XML file in Visual Studio.

    2. Go to the menu XML > Start XSLT Debugging (Alt+F5)

    3. A dialogue will appear in which you can select the XSL file.

    4. After selecting the XSL file the transformation is started.

    5. If the transformation succeeded a new file will be opened with the transformed XML.

    XSLT debugging in Visual Studio Professional

    1. To test your XSLT code, open the XML file in Visual Studio.

    2. Go to the menu XML > Start XSLT Debugging (Alt+F5)

    3. A dialogue will appear in which you can select the XSL file.

    4. After selecting the XSL file the transformation is started.

    5. If the transformation succeeded a new file will be opened with the transformed XML.

  3. Enable the XSLT file within the settings of an import folder.

    1. Open the import folder to which a translation must be applied.

    2. Upload the XSLT file at the bottom of the window.

    3. Save the import folder.

Please take a look at the limitations in this chapter before creating the XSLT file.

Analyse the transformations applied to the JDF ticket or XML file with the log file

  1. By default only errors are logged to the importservice.log file. The entry will look like this:

    Logger.Error(GenericConstants.PACCESS_LOGGER_NAME, $"TransformXml {xmlFilePath} with XSLT {xltFilePath} FAILED!", ex);

  2. In debug mode also successful translations are mentioned. These entries look like this:

    Logger.Debug(GenericConstants.PACCESS_LOGGER_NAME, $"TransformXml {xmlFilePath} with XSLT {xltFilePath} succeeded!");

Limitations and considerations

  • PRISMAdirect supports XSLT 1.0 to transform JDF tickets or create JDF tickets from XML. Only one order with one job can be created via XSLT.

  • No external lookup files can be used to match an attribute or element value from the JDF or XML.

  • All JDF tickets and XML files that the PRISMAdirect server receives will be transformed using the enabled XSLT file for that import folder.

  • Only one XSLT file can be linked to an import folder.

  • If the XSLT transformation causes an error, the original JDF ticket is used without a transformation.

  • There is no timeout for the transformation by XSLT. This means that badly formed XSLT code can continue to run for a long time, or even do not terminate at all. Such transformations can use up the resources of the PRISMAdirect server making the server unresponsive. The PRISMAdirect server does not detect when a transformation is running for a long time.

  • By default, all JDF tickets and XML files will be transformed by the XSLT file linked to the import folder. However, it is possible to process the files differently based on conditions in the XSLT code. For example, you can create a condition stating when a JDF ticket must be transformed, or not.