The USXSL Apply Method

Previous Next

See Also

The USXSL apply method applies an XSL transformation to an XML document.

This method can for example be used in a corrective constraint, to fill or update a database column with the result of the transformation.


SELECT USXSL.apply(<xml document>, <xsl transformation>

       [,<param1>, <value1>][,<param2>, <value2>, ...])

Where <xml document> and <xsl document> can be:

· Literal strings (XML or XSL documents).


· File names.


· URL's.


· Aliases previously added by the setxml and setxsl methods.

Optionally, you can pass parameter/value pairs <param1>, <value1>, ...

The parameter value can be a literal string or an XML document. To make a distinction between strings and XML parameters, the parameter name contains 'string:' or 'document:' in front of the actual name of the parameter, for example:

SELECT USXSL.apply('C:\Myxml.xml','C:\Myxsl.xsl',

           'string:MyId', 1)

SELECT USXSL.apply('C:\Myxml.xml','C:\Myxsl.xsl',

           'document:MyId', '')

SELECT USXSL.apply('C:\Myxml.xml','C:\Myxsl.xsl',

           'document:MyId', MyAlias)

The 'document:' prefix only works on a Windows platform.

If the parameter is a document, the parameter value must be an XML string, URL, a file name or an alias previously added by the SetXml method.

If the parameter name does not contain 'string:' or 'document:', and the parameter value starts with '<?xml' or 'file:' then the parameter value is a document, otherwise the parameter value is a string.

The USXSL apply method returns the result of the transformation as a string, or results in an error message. The xml, xsl and xsl parameters are removed from memory at the end of the processing. The second time when the same values are used they will be parsed again. For performance reasons it is better to parse the XML document and xsl document once, using the SetXml and SetXsl methods, and use an alias to refer to them.