on 04-14-2010 2:29 PM
Hi Experts, attn: Stefan.
I have a requirement to convert a string XML to XML using XSLT. With the inputs from Stefan I have got my XSLT mapping working fine and tested it in XMLSpy. It works fine.
The problem is, when I test my Interface mapping in PI and input test XML in a string Field, PI on its own, wraps data into CDATA tag as.
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_SourceString xmlns:ns0="http://abc.com">
<Str><![CDATA[<catalog>
<cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year></cd>
<cd> <title>Empire Burlesque2</title> <artist>Bob Dylan2</artist> <country>USA</country> <company>Columbia2</company> <price>10.90</price> <year>1985</year> </cd>
<cd> <title>Empire Burlesque3</title> <artist>Bob Dylan3</artist> <country>USA</country> <company>Columbia3</company> <price>10.90</price> <year>1985</year> </cd>
</catalog>
]]>
Now XSLT ignores all the data in CDATA and i get nothing in output.
<?xml version="1.0" encoding="UTF-8"?><ns0:MT_TargetCatalog xmlns:a="http://www.sdn.com/xslt" xmlns:ns0="http://abc.com"/>
XSLT Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://www.sdn.com/xslt">
<xsl:output method="xml" omit-xml-declaration="no"/>
<xsl:template match="/">
<ns0:MT_TargetCatalog xmlns:ns0="http://abc.com">
<xsl:for-each select="//cd">
<xsl:copy-of select="." />
</xsl:for-each>
</ns0:MT_TargetCatalog>
</xsl:template>
</xsl:stylesheet>
Please sugest how can I read the data from CDATA tag of XML?
Kind Regards,
Abhi.
> The problem is, when I test my Interface mapping in PI and input test XML in a string Field, PI on its own, wraps data into CDATA tag as.
Now I see the point. You cannot test like this.
in the test tab click on "source test view"
provide the whole XML here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The first code snippet in my post is a code from : "source text view " .
The Test XML entered by me was
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Empire Burlesque2</title>
<artist>Bob Dylan2</artist>
<country>USA</country>
<company>Columbia2</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Empire Burlesque3</title>
<artist>Bob Dylan3</artist>
<country>USA</country>
<company>Columbia3</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
Do you wanna point out that the PI will not add CDATA in real scenario??
I have not configured complete scenario as sender system is not yet ready to send data.
Ok, I will try with End to End scenario.
But as i have mentioned before it will not be a xml message, the input will be a XML passed as a string in a RFC parameter of type string. I hope it doesnt make any difference and PI will pass on the XML string as it is i.e. w/o wrapping it in CDATA.
Thanks Stefan.
> Now XSLT ignores all the data in CDATA and i get nothing in output.
This is correct behaviour:
http://www.w3.org/TR/2008/REC-xml-20081126/#sec-cdata-sect
there is nothing that you can do here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.