on 08-03-2009 3:55 PM
Hey folks
Am having a XML in a single string in ma request and wanna convert that into a XML. Tried that using XSLT but seems am missing out on some point...It works fine with Stylus but fails within PI
Following code am using :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://www.sdn.com/xslt">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:for-each select="//*:string">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The name of the element in which i get the whole XML is "string".
My request string is something liek this :
<xml version="1.0" encoding="UTF-8"?><ProductDefinition><RefNo>23232323</RefNo><Description>dfdfdfdfdf</Description></ProductDefinition>
Now am trying to generate a XML using the XSL but its failing in PI...
Kindly point out where am i going wrong?
Hi Das,
I hope you would have saved it as .xsl and zipped it and then .zip file you would have uploaded into IR. After doing this if didnot work then you can use this code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:value-of select="//string" disable-output-escaping="yes" />
</xsl:template>
</xsl:stylesheet>
Dont forget to save it as .xsl and zipped before uploading to IR. If this didnot work then can you give your whole sample payload so that somebody can help you. The payload what ever you have given is not the complete one because I dont see the string xml tag. Can you give the whole xml paylaod.
Regards,
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Following is teh payload that comes in source under field "string" :
<string> <![CDATA[<?xml version="1.0" encoding="UTF-8"?><ProductDefinition><RefNo>12345</RefNo><Description>Test</Description></ProductDefinition>]]></string>
Please ignore the http thing in teh payload as it comes automatically when posted here on SDN... it goes like this : <![CDATA[<?xml version="1.0" encoding="UTF-8"?>...
The code that you sent works fine if the payload is without the xml version tag...with this tag the target is produced like this :
<?xml version="1.0" encoding="UTF-8"?><ProductDefinition><RefNo>12345</RefNo><Description>Test</Description></ProductDefinition>
but when tried to see in tree structure it fails with error " Unable to display tree view; Error when parsing an XML document (The processing instruction target matching "[xX][mM][lL]" is not allowed.)"
Is there anyway that we can remove this tag in the code??? Coz its gonna come from source...
Edited by: SoumenDas2009 on Aug 4, 2009 9:38 AM
You can have a Message Mapping before your XSLT mapping.
In the Message Mapping have the replacestring function and remove the the xml tag
OR
In your XSLT mapping itself replace the xml tag by using the replace function mentioned here:
http://www.w3schools.com/Xpath/xpath_functions.asp
Regards,
Abhishek.
Send the complete error, where you are getting error & what is the error description.
Sandeep Kaushik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.