Hi,
I have a requirement to consume a structure which contains a node, which itself contains a string of XML. As advised on another thread I am using a combination of graphical mapping and XSLT to achieve this. However, I am hitting an issue.
The structure being consumed is like:
<WSResponse>
<iData>
<![CDATA[<?xml version="1.0" encoding="ISO-8859-1"?>
<reports><report><fault>pothole</fault><location>here</location><reportedby>me</reportedby></report>
<report><fault>darklamp</fault><location>there</location><reportedby>you</reportedby></report>
</reports>]]>
</iData>
<iDataLength>2232</iDataLength>
<iErrorMessage>None</iErrorMessage>
<iWSCallID>AX121312</iWSCallID>
</WSResponse>
The node <iData> contains an XML string. I therefore set up a double mapping:
Mapping 1 simply removed "<?xml version="1.0" encoding="ISO-8859-1"?>"
When viewed in SXI_Monitor this appears to leave:
<iData>
<reports><report><fault>pothole</fault><location>here</location><reportedby>me</reportedby></report>
<report><fault>darklamp</fault><location>there</location><reportedby>you</reportedby></report>
</reports>>
</iData>
<iDataLength>2232</iDataLength>
<iErrorMessage>None</iErrorMessage>
<iWSCallID>AX121312</iWSCallID>
Mapping 2 was an XSLT mapping which takes in the above and treats it as a standard piece of XML. The relevant bit of the .XSL file is as follows
<ImportedFromMCS>
<Reports>
<xsl:for-each select="./iData/reports/report">
<RemedyReport>
<ns0:IN_Remedy_Fault xmlns:ns0="http://gcc.access.com/testFutureCities">
<xsl:value-of select="./fault"/>
</ns0:IN_Remedy_Fault>
<ns0:IN_Remedy_Location xmlns:ns0="http://gcc.access.com/testFutureCities">
<xsl:value-of select="./location"/>
</ns0:IN_Remedy_Location>
<ns0:IN_Remedy_ReportedBy xmlns:ns0="http://gcc.access.com/testFutureCities">
<xsl:value-of select="./reportedby"/>
</ns0:IN_Remedy_ReportedBy>
</RemedyReport>
</xsl:for-each>
</Reports>
<ns0:IN_Remedy_DataLength xmlns:ns0="http://gcc.access.com/testFutureCities">
<xsl:value-of select="./iDataLength"/>
</ns0:IN_Remedy_DataLength>
<ns0:IN_Remedy_ErrorMessage xmlns:ns0="http://gcc.access.com/testFutureCities">
<xsl:value-of select="./iErrorMessage"/>
</ns0:IN_Remedy_ErrorMessage>
<ns0:IN_Remedy_iWSCallID xmlns:ns0="http://gcc.access.com/testFutureCities">
<xsl:value-of select="./iWSCallID"/>
</ns0:IN_Remedy_iWSCallID>
</ImportedFromMCS>
This produces:
<?xml version="1.0" encoding="UTF-8"?>
<ImportedFromMCS xmlns:ns0="http://gcc.access.com/testFutureCities">
<Reports />
<ns0:IN_Remedy_DataLength>2232</ns0:IN_Remedy_DataLength>
<ns0:IN_Remedy_ErrorMessage>None</ns0:IN_Remedy_ErrorMessage>
<ns0:IN_Remedy_iWSCallID>121312</ns0:IN_Remedy_iWSCallID>
</ImportedFromMCS>
i.e. the <xsl:for-each select="./iData/reports/report"> section returns nothing. My feeling is this is because what is actually being presented to XSLT in mapping 2 is:
<iData>
<![CDATA[<reports><report><fault>pothole</fault><location>here</location><reportedby>me</reportedby></report><report><fault>darklamp</fault><location>there</location><reportedby>you</reportedby></report></reports>]]>
</iData>
<iDataLength>2232</iDataLength>
<iErrorMessage>None</iErrorMessage>
<iWSCallID>121312</iWSCallID>
i.e. the CDATA tag is still there. This means the <xsl:for-each select="./iData/reports/report"> fails because CDATA is in the way.
After all that my Question is simply - How does XSLT handle this? i.e. get access to the XML within <iData> without CDATA appearing to screw up the <xsl:for-each select="./iData/reports/report"> command?
Cheers,
PaulC.