Search code examples
xsltadobe-indesign

XSLT node-set() function support in InDesign


I have xslt 1.0 module with ext:node-set function (xmlns:ext="http://exslt.org/common") and would like to use it in InDesign's CC (2014) via Import XML... feature.

When I choose File -> Import XML..., select XML, then Apply XSLT -> Browser... and choose xslt, click OK - I get an error Function 'ext:node-set' not supported.

I've tried to replace a namespace to xmlns:xalan="http://xml.apache.org/xalan" and function call xalan:nodeset - the similar error Function 'xalan:nodeset' not supported.

Questions:

  1. Can I use node-set function in InDesign?
  2. Which xslt processor is using in InDesign?

Solution

  • Sablotron processor by Ginger Alliance is using in InDesign. Ginger Alliance site available via Wayback Machine https://web.archive.org/web/20090430034418/http://www.gingerall.org/index.html. Regarding https://www.xml.com/pub/a/2003/07/16/nodeset.html#tab.namespaces, Sablotron Can operate on result tree fragments directly, i.e. no need to use node-set or nodeset functions.

    Example:

    <xsl:variable name="items">
      <item>1</item>
      <item>2</item>
      <item>3</item>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="function-available('ext:node-set')"> <!-- for EXSLT compatible processor -->
        <xsl:for-each select="ext:node-set($items)//item">
          <xsl:value-of select="."/>
        </xsl:for-each>
      </xsl:when>
      <xsl:otherwise> <!-- for InDesign -->
        <xsl:for-each select="$items//item">
          <xsl:value-of select="."/>
        </xsl:for-each>
      </xsl:otherwise>
    </xsl:choose>