Followers

XSLT - Transformation in Pega

 How to transform XML into XHTML using XSLT in Pega?

       One of the common requirement in a healthcare application is to convert the clinical documents (which is usually stored in an XML format) into a human readable HTML format. We can use XSLT to transform XML documents into other formats (like transforming XML into HTML). XSLT stands for XSL Transformations.XSL is (eXtensible Stylesheet Language)  a styling language for XML.

    Suppose if we want to transform the following XML :view XML

xml


Step 1: Create an XSL Style sheet with a transformation template or if the .xsl file has been provided by the business you can directly use it . View XSL

Sample XSL File

Step 2: Create a binary file rule (Rule-File-Binary) to store the XSL transformation file with .xsl extension.

Binary File to store XSL


Step 3: We can use OOTB function named performXSLT to convert xml to html. for calling the function create a DT and pass the XML Source and relative path to xsl file as input and in output we get the transformed content.

Function rule to convert XML using XSLT

Data transform to call the function

@performXSLT(Param.SourceData,Param.XSLPath,false)

Run the Data transform rule and trace it to find the transformed html:


Tracer results


Transformed HTML Output

Transformed HTML

Based on the style you specify in the XSL the transformed HTML look and feel will vary.



0 comments:

Post a Comment