Calling USCSXSL from a USoft context to apply a named transformation

Previous Next

You can call the USCSXSL internal component to apply a named XSLT transformation from a USoft context. USoft contexts for USCSXSL include the SQL Command tool, SQL Tasks, Decision SQLs, Constraint SQLs, and SQL statements defined in the Service Framework.

Over and above XSLT 1.0 processing, this technique allows you to access extension functions offered by USCSXSL:

XSLT 2.0-like functions and other convenience functions,

The ability to store values in variables during XSLT processing,

The possibility to add interactive behaviour (dialogs).

Choose this option if you want to apply a specific, non-default transformation. If you want to process a USoft Blend script in the default way, that is, apply to it the default Batch.1.0.xsl transformation, call USCSXSL as a Blend script processor instead.

 

Syntax 1

select uscsxsl.apply( xml, xsl  [ , variable-name, variable-value ... ] )
 
xml  :=  { xml-filepath | xml-document }
xsl  :=  ( xsl-filepath | xsl-document }

 

Syntax 2

select uscsxsl.apply2file( xml, xsl, xml-resultfilepath  [ , variable-name, variable-value ... ] )
 
xml  :=  { xml-filepath | xml-document }
xsl  :=  ( xsl-filepath | xsl-document }

 

All arguments are single-quoted string values. The only difference between Syntax 1 and Syntax 2 is that Syntax 2 writes the result to the file designated by the xml-resultfilepath argument, while Syntax 1 returns the result as standard output.

The required xml must be a valid XML document. This document may contain calls to USCSXSL extension functions, in which case it is called a USoft Blend script. You can submit this XML document either as a file on the file system that you reference by xml-filepath or inline as a literal xml-document string.

The required xsl must be a valid XSLT 1.0 transformation. You can submit this transformation either as a file on the file system that you reference by xsl-filepath or inline as a literal xsl-document string.

Optionally, you can pass any number of Blend input parameters as variable-name=variable-value pairs.

 

Example

select uscsxsl.apply( '<MyClipboardNow/>', 'c:\temp\PrintClipboard.xsl' )

If the file content of the "c:\temp\PrintClipboard.xsl" file is:

<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:clipboard="USoft:ClipBoard"
>
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>
 
<xsl:template match="*|@*|comment()|processing-instruction()|text()">
  <xsl:copy>
    <xsl:apply-templates select="*|@*|text()|comment()|processing-instruction()"/>
  </xsl:copy>
</xsl:template>
 
<xsl:template match="MyClipboardNow">
  <xsl:copy>
    <xsl:value-of select="clipboard:GetText()"/>
  </xsl:copy>
</xsl:template>
 
</xsl:stylesheet>

and your clipboard currently contains "Hello World", then the result of the transformation is:

<MyClipboardNow>Hello World</MyClipboardNow>

 

See also

Calling USCSXSL from a USoft context as a Blend script processor

Calling USCSXSL from the command line as a Blend script processor

Blend input parameters