Share this page

# lr_xml_transform

XML Functions (lr_xml)

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

    int lr_xml_transform( <List of specifications> ]);

List of specifications | For the following list of required specifications, use the following string format:"Specification=value" 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.
LAST | A marker which indicates the end of the List of specifications

The lr_xml_transform 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

See Return Values

## Parameterization

See Parameterization

## Example

The following example transforms an XML string, xml_input, using the XSL specification, stylesheet, and saves the transformation into the parameter, Result.

Both xml_input and stylesheet are char strings and are converted to parameter format using lr_save_string. After lr_xml_transform is invoked, the output parameter which contains the formatted data, Result, is evaluated using lr_eval_string.

    #include "as_web.h"

    char *xml_input =
    "<?xml version=\"1.0\" ?>"
         "<sales>"
              "<summary>"
                   "<heading>Acme Organization</heading>"
                   "<subhead>IT Management Report</subhead>"
                   "<description>Report by Department</description>"
              "</summary>"
         "</sales>";

    char *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>";

    Action() {

         lr_save_string(xml_input, "XML_Input_Param"); // Save to a parameter
         lr_save_string(stylesheet, "XML_StyleSheet_Param");// Save to a parameter

         lr_xml_transform("XML={XML_Input_Param}", "ResultParam=Result",
              "Stylesheet={XML_StyleSheet_Param}", LAST );

         lr_output_message(lr_eval_string("String after transformation: {Result}"));

         return 0;
    }

Example: Output:
Action.c(39): String after transformation: <HTML>
<HEAD>
<TITLE>Acme Organization</TITLE>
</HEAD>
<BODY>
<h1>Acme Organization</h1>
<h2>IT Management Report</h2>
<p>Report by Department.</p>
</BODY>
</HTML>

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