cancel
Showing results for 
Search instead for 
Did you mean: 

Error when mapping an XML coming as in Source Element

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

> 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 "<"

Answers (3)

Answers (3)

Former Member
0 Kudos

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

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>>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"?>

Former Member
0 Kudos

Hi Baskar,

I tried the same but still the same error ?Do you know is there anything wrong with my Input?

Please let me know.

Thanks and Regards,

Rajesh Naidu

former_member472138
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Pothana,

I need to map the xml coming in the element to the target xml .

Thanks

Rajesh