Share this page

# lr.xmlTransform

Applies Extensible Stylesheet Language (XSL) Transformation to XML data.

Example | XML JavaScript Functions (lr.)

## Syntax

    lr.xmlTransform( {object} );

## JavaScript Object

    {
        xml:"<string>",
        stylesheet:"<string>",
        resultParam:"<string>"
    }

Property Name | Description
--- | ---
xml | The XML Input String to query.
stylesheet | The XSL specifications. Has the format of an XSL string.
resultParam | The name of the output parameter containing the XML formatted data after XSL transformation.

The lr.xmlTransform function transforms the XML input string XML using the Extensible Stylesheet Language (XSL) specifications in Stylesheet and saves the resulting formatted data in ResultParam, using the source document encoding. The output preserves the XML Character Encoding of the original document, independent of the input encoding. The input encoding uses the client's local encoding.

## Return Values

All XML functions return the number of matches successfully found or zero on failure.

## Parameterization

Input parameters to XML functions with the following names can be parameterized:

- XML

- Query

- Value

- XmlFragment

## Example

    function Action(){
       var xmlInput =
           "<?xml version=\"1.0\" ?>"+
           "<sales>"+
           "<summary>"+
           "<heading>Acme Organization</heading>"+
           "<subhead>IT Management Report</subhead>"+
           "<description>Report by Department</description>"+
           "</summary>"+
           "</sales>";

           var stylesheet =
           "<?xml version=\"1.0\"?>"+
           "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">"+
           "<xsl:output method=\"html\"/>"+
           "<xsl:template match=\"/\">"+
           "<HTML>"+
           "<HEAD>"+
           "<TITLE><xsl:value-of select=\"//summary/heading\"/></TITLE>"+
           "</HEAD>"+
           "<BODY>"+
           "<h1><xsl:value-of select=\"//summary/heading\"/></h1>"+
           "<h2><xsl:value-of select=\"//summary/subhead\"/></h2>"+
           "<p><xsl:value-of select=\"//summary/description\"/></p>"+
           "</BODY>"+
           "</HTML>"+
           "</xsl:template>"+
           "</xsl:stylesheet>";

            lr.saveString(xmlInput, "XML_Input_Param"); // Save to a parameter
            lr.saveString(stylesheet, "XML_StyleSheet_Param");// Save to a parameter

            lr.xmlTransform({xml:"{XML_Input_Param}", resultParam:"Result",
                stylesheet:"{XML_StyleSheet_Param}"});

            lr.outputMessage(lr.evalString("String after transformation: {Result}"));

    return 0;
    }

Tips to improve your search results... VuGen Function Reference Version 25.1-25.3 Function Reference 25.1-25.3 All View Local Help Center View Online Help Center Version: