on 03-22-2011 10:07 AM
Hi,
We have a requirement where the XML is sent in an element as given below :
The Incoming Payload is of the below format :
Source :
<?xml version="1.0" encoding="UTF-8"?>
<ResponsePayload>
<RespString><?xml version="1.0" encoding="UTF-8"?>
<Devices>
<Device>1</Device>
<Name>1</Name>
</Devices></RespString>
</ResponsePayload>
The target XML is below :
Target:
<?xml version="1.0" encoding="UTF-8"?>
<Devices>
<Device/>
<Name/>
</Devices>
I used the below xslt mappings in two steps as suggested by Udo .
XSLT Mapping1 :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:for-each select="//RespString">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
XSLT Mapping 2 :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<ResponsePayload>
<xsl:copy-of select="//Devices"/>
</ResponsePayload>
</xsl:template>
</xsl:stylesheet>
When executing Iam getting the belwo error :
javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The processing instruction target matching "[xX][mM][lL]" is not allowed
cansomeone help me the reason for the error and how I can correct it .
Thanks
Rajesh
> When executing Iam getting the belwo error :
> javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The processing instruction target matching "[xX][mM][lL]" is not allowed
This error occurs when the XML message does not start with a "<" but with a trailing space or any non-printable character.
Remove all characters before the first "<"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rajesh,
i can give you different approach...if the sender side is an File adapter and if ur picking the XML or CSV then write a module in sender file adapter to change the XML file.
Characters like "<" and "&" are illegal in XML elements.
"<" will generate an error because the parser interprets it as the start of a new element.
so u need to add "<![CDATA[" and ends with "]]>"......now the data will come into PI as <![CDATA[<?xml version="1.0" encoding="UTF-8"?>]].
in the target side the data will be passed as <?xml version="1.0" encoding="UTF-8"?>.
Regards,
Phani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>>cansomeone help me the reason for the error and how I can correct it .
Fix is:
This is pretty common problem.
Edit your xml using editor like XMLSPY or any standard tool. The solution is
Below is the first line of xml. See any extra character or spaces before the ' <' (angle bracket). If so delete.
<?xml version="1.0" encoding="UTF-8"?>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rajesh
Export your receiver data type structure as an XSD
Edit the XML as you expected
Import the xml as an External Definition
Regards
Pothana
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 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.