CDATA in XSLT String Functions Causes Problems
Do not use CDATA in XSLT string functions (value-of
turns
the content into a string).
For example, assume you are using the mapper to hard code a SOAP Adapter
header
attribute. The mapper encodes the data, which causes a
problem for the endpoint service at runtime.
- Mapping:
[Expression for: "header"] "<![CDATA[ <CrosstalkMessage> <CrosstalkHeader> <ProcessCode>1004</ProcessCode> <MessageType>100</MessageType> <ExchangePattern>7</ExchangePattern> <EnterpriseId>ace7d6ae-78a8-f3gh-1d04 -9fe0416d053c</EnterpriseId> <Token>h12749ed-913b-7e3e-2aef -8dd78255cb40</Token> <DestinationId>b3fbf48e-df96-f27d-5fac -38895618064f</DestinationId> <ContentEncoding>utf-8</ContentEncoding> <ContentType>text/xml</ContentType> </CrosstalkHeader> </CrosstalkMessage> ]]>"
- Code:
<tns:header xml:id="id_48"> <xsl:value-of xml:id="id_82" select="'<![CDATA[ <CrosstalkMessage> <CrosstalkHeader> <ProcessCode>1004</ProcessCode> <MessageType>100</MessageType> <ExchangePattern>7</ExchangePattern> <EnterpriseId>ace7d6ae -78a8-f3gh-1d04-9fe0416d053c</EnterpriseId> <Token>h12749ed-913b -7e3e-2aef-8dd78255cb40</Token> <DestinationId>b3fbf48e-df96-f27d -5fac-38895618064f</DestinationId> <ContentEncoding>utf -8</ContentEncoding> <ContentType>text/xml</ContentType> </CrosstalkHeader> </CrosstalkMessage> ]]>'"/> </tns:header>
To achieve this:
- Write the XML structure using a stage file action.
- Read the XML as opaque content.
- Map to the header element by using
decodeBase64
of read content. - Use the
cdata-section-elements
attribute in XSLT referring to the header element.