Gretyl's Portal

Heretto Help

Show Page Sections

Advanced XSL Transformations

You can use advanced XSL to perform complex transformations in PDF Generator outputs. When planning to use advanced XSLT in your PDF Generator scenarios, consider this important information.

Important Considerations

  • We recommend that users experienced with advanced XSL complete these procedures.

  • You need to be assigned the Administrator role in Heretto CCMS to modify PDF Generator publishing scenarios.

  • PDF Generator uses an API call that calls the resource UUID. The path to a resource is UUID.file-extension. For example, 33573366-bfc8-445c-8322-203d83bbc1mr.svg.

  • You need to add namespaces to your XSLT stylesheets. Add xs:preservens="true" as presented here:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"    xmlns:xs="http://www.w3.org/2001/XMLSchema" xs:preservens="true" exclude-result-prefixes="opentopic" version="2.0">
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xs:preservens="true"

Access XML Details of a Referenced SVG File

You can use XSLT to access XML details of an SVG file referenced in topic and use that information in the PDF Generator output transformation. This procedure can be completed only by users assigned the Administrator role in Heretto CCMS.

This procedure does not explain how to access details of annotated images with XSLT. It explains how to access details of images saved to the .svg format, uploaded to Heretto CCMS, and added to a topic in a figure element (fig) or image element (image).

  1. In the top-left corner, click the Main Menu and go to PDF Generator.
  2. In the PDF Generator scenarios screen, click the publishing scenario you want to edit.
  3. In the XSLT tab, add this code:
    <xsl:if test="contains(@href, '.svg')">
        <xsl:attribute name="width" select="document(@href)//*[local-name()='svg']/@width"/>
    </xsl:if>

    This code is an example of accessing the width attribute of an SVG file.

  4. Modify the code to call the desired SVG detail.
  5. Click Save Scenario and verify your changes by publishing test content with the scenario you modified.

Access XML Details of a Referenced Topic

You can use XSLT to access XML details of a topic that is referenced by a different topic and use that information in the PDF Generator output transformation. This procedure can be completed only by users assigned the Administrator role in Heretto CCMS.

Ensure the cross-reference (xref) that links the topic whose details you want to access has scope="local" set. For example, <xref href="topic.dita" scope="local"></xref>.

  1. In the top-left corner, click the Main Menu and go to PDF Generator.
  2. In the PDF Generator scenarios screen, click the publishing scenario you want to edit.
  3. In the XSLT tab, add this code:
    Important: Before passing that attribute to the document() function, it must be prefixed with no-doctype: to remove the <!DOCTYPE> element from processing.
    <xsl:template match="*[contains(@class, ' topic/xref ')]" name="topic.xref">
            <xsl:choose>
                <xsl:when test="@file-uuid and normalize-space(@file-uuid)">
                    <xsl:variable name="prefixedFileUuid" select="concat('no-doctype:', @file-uuid)"/>
                    <xsl:comment>
                        <xsl:value-of select="$prefixedFileUuid"/>
                    </xsl:comment>
                    <a>
                        <xsl:attribute name="title">
                            <xsl:value-of select="document($prefixedFileUuid)//title"/>
                        </xsl:attribute>
                    </a>
                </xsl:when>
                <xsl:otherwise>
                    <span>
                        Not able to retrieve title from Document 
                    </span>
                </xsl:otherwise>
            </xsl:choose>        
        </xsl:template>

    This code looks for the file-uuid attribute.

  4. Modify the code to call for the desired topic detail.
  5. Click Save Scenario and verify your changes by publishing test content with the scenario you modified.

Include Draft-comment Content in Output

By default, content added within the draft-comment element is excluded from outputs. However, you can use XSLT to ensure that a PDF Generator scenario includes it. This procedure can be completed only by users assigned the Administrator role in Heretto CCMS.

  1. In the top-left corner, click the Main Menu and go to PDF Generator.
  2. In the PDF Generator scenarios screen, click the publishing scenario you want to edit.
  3. In the XSLT tab, add this code:
    <xsl:param name="DRAFT" select="'yes'"/>
  4. Click Save Scenario and verify your changes by publishing test content with the scenario you modified.

Create a Variable Image on the Cover Page

You can use a combination of DITAVAL files and XSLT code to control the images that print on a PDF cover. By doing so, instead of creating unique publishing scenarios for each product, you can use one PDF Generator publishing scenario to print different images on PDF covers.

Portions of this procedure can be completed only by users assigned the Administrator role in Heretto CCMS.

You should have:

  • A working PDF Generator scenario
  • A map that you've created for publishing
  • Images to print on the PDF cover

Create a DITAVAL file that identifies the product category

  1. Create a new DITAVAL file named product_name_1.ditaval, where product_name_1 is the name of one of your products.
    Tip: Create a DITAVAL for each product for which you want a different cover page image.
  2. Set up the DITAVAL to include product_name_1 and exclude all other products.

    An example of a DITAVAL source code that includes product_name_1 and excludes product_name_2:

    <val>
        <prop action="include" att="product" val="product_name_1"/>
        <prop action="exclude" att="product" val="product_name_2"/>
    </val>
    Important: If you copy-paste this example, replace the val attribute values product_name_1 and product_name_2 with the applicable product values.

Add XSLT code to a PDF Generator scenario (Administrators only)

  1. In the top-left corner, click the Main Menu and go to PDF Generator.
  2. In the PDF Generator scenarios screen, click the publishing scenario you want to edit.
  3. In the XSLT tab of your PDF Generator scenario, add this XSLT code.
    <div class="cover-image">
      <img>
        <xsl:attribute name="src" select="/normalized/map/topicmeta/data/image/@href"/>
      </img>
    </div>
  4. Click Save Scenario.

Add image files to your map

  1. Add this topicmeta element to the root element of your DITA map.
    <map id="ditamap-4870">
        <title>Map Title</title>
        <topicmeta>
            <data product="product_name_1"><image href="../_global_shared/media/logos/LOGO1.png"/></data>
            <data product="product_name_2"><image href="../_global_shared/media/logos/LOGO2.png"/></data>
        </topicmeta>
    </map>
  2. Replace the product attribute values product_name_1 and product_name_2 with with the applicable product values.
  3. Modify the image href attributes to link to your variable images in Heretto CCMS.

Publish content

  1. Publish your map with the PDF Generator publishing scenario you modified and a DITAVAL file you created.