One such endeavour led me to this solution. This solution allows you to convert a whole xml message into a string and feed it into one string node which can then be used in another map which (for whatever reason) may require a string message version of your original xml message. This could be done in an expression shape and message assignment shape in an orchestration, but as I said above, if you can avoid the load, why not?
- Create a schema with a root node and a child field element node of string Data Type
- Create a map which references your schema(s)
- Add the xml schema to be converted as the source schema of your map
- Add the new schema as the destination schema
- Add a scripting functoid to the map
- Connect the Root node of the source schema and the string data type (not the root) node of the source schema
- Configure the scripting functoid (right-click, configure functoid script, Script functoid configuraiton) and choose Inline XSLT Call Ttemplate
- Add the following script to the functoid: <xsl:template name="xml-to-string-called-template">
<xsl:param name="param1" />
<xsl:element name="ns0:NameofNodetoHoldString">
<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
<xsl:call-template name="identity" />
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</xsl:element>
</xsl:template>
<xsl:template name="identity" match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template> - Test the map, and your whole source xml would have been nicely converted into a string and added into the string node within the CDATA! section (which tells the processing receiver that everything within those should be treated as strings)
Hi Stephen, any idea how I can escape the entire output of the source xml? The disable-output-escaping="no" only applies to xsl:text and not to the xsl:call-template? I want to map the source xml without the CDATA wrapping and escape < and > from the source message into my string field of my destination schema. I know its been a while since you did this but any help appreciated. Thanks in advance, Dino.
ReplyDelete