• 5 August 2022
  • 0 replies

Userlevel 2
Badge +2

This article is about the xslutil:applyTemplate Blend function.


Applies the identity transformation to some XML input, taking into account a set of extra XSLT templates. The identity transformation causes the input XML to be returned as output XML. The extra templates cause certain nodes of the XML content to be processed in a special way.

Returns XML content.


xslutil:applyTemplate( expression, extra-templates )

extra-templates := <xsl:template match="match-pattern"> content </xsl:template> …

The required expression must be an XPath expression pointing to an XML node set, or a literal XML fragment, or a path leading to an XML file.

The optional extra-templates is an unordered list containing any number of regular XSLT 1.0 templates in the form of <xsl:template> instructions. If you omit extra-templates, the return XML content is identical to the input XML content.

In extra-templates, each match-pattern must be a relative match pattern, that is, a match pattern that does NOT begin with a forward slash ( / ).


In the last line, xslutil:applyTemplate() applies two XSLT templates to an XML document stored in a file.

<authdata xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pc="Processing.Command">
<xsl:template match="T_AUTH_USER[@USERNAME='adminuser']"/>
<xsl:template match="T_AUTH_OC_PARAMS[@OC_ID='LAN' and @SET_TYPE='URE' and @PARAM_NAME='Allow_Disable_Constraint']"/>

usauth_filepath="{path:Combine($workingdir, 'USAUTH.xml')}"/>
usauth_data = "{xslutil:applyTemplate($usauth_filepath, /*/pc:defs/xsl:template)}"/>

The effect of this is equivalent to applying this regular XSLT 1.0 stylesheet:

<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no"/>

<xsl:template match="*|@*|comment()|processing-instruction()|text()">
<xsl:apply-templates select="*|@*|text()|comment()|processing-instruction()"/>

<xsl:template match="T_AUTH_USER[@USERNAME='adminuser']"/>
<xsl:template match="T_AUTH_OC_PARAMS[@OC_ID='LAN' and @SET_TYPE='URE' and @PARAM_NAME='Allow_Disable_Constraint']"/>



0 replies

Be the first to reply!