Jan 29, 2012

Special Character Handling in XSL (&) Ampersand


This special character handling is specifically for Oracle SOA 10g. When a XML payload comes in string format, with all characters escaped and the data contains special character like '&', this trick will be helpful in handling this payload.


Follow below steps to be parse XML string containing special character in XSL file-

1. Add following namespace in the xsl file
            xmlns:str=http://www.oracle.com/XSL/Transform/java/java.lang.String
2. Declare a variable to hold escaped format of input
            <xsl:variable name="EscapedEBM" select="....."/>
3. Add an ampersand variable
            <xsl:variable name="fixedAmpersand">&amp;amp;amp;</xsl:variable>
4. Call the replace all method and hold the output to EBM variable-
            <xsl:variable name="EBM">
                <xsl:value-of select="str:replaceAll($EscapedEBM,'\u0026(amp;)*+',$fixedAmpersand)"/>
            </xsl:variable>
5. Now use the orcl:parsedEscapedXML($EBM) to get XML representation of string.

No comments:

Post a Comment