cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing Error after java mapping

Former Member
0 Kudos

Hi guru,

I did a java mapping to insert in the element tag the "ns1:" (i.e. <ns1:SapUser>MARCO<ns1:/SapUser> instead of <SapUser>MARCO</SapUser>) and now I get this error in the channel monitor:

SOAP: call failed: java.io.IOException: Parsing
Error: org.xml.sax.SAXParseException: Element or attribute do not match QName
production: QName::=(NCName:)?NCName.

anybody can help me?

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

Hi marco,

Have you defined the namespace ns1: in any tag like

<x xmlns:ns1='http://.example.org/schema'>

or

<ns1:x xmlns:ns1='http://.example.org/schema'>

?

Regards

Former Member
0 Kudos

<

ns1:VendorInvoiceSend xmlns:ns1="urn:mt.com:shpt:mm:VendorInvoice_">


<

ns1:SapUser>ALT_MARCO<ns1:/SapUser>


<

ns1:AddressMail>Marco@marco.it<ns1:/AddressMail>

</

ns1:VendorInvoiceSend>

iaki_vila
Active Contributor
0 Kudos

Ok Marco,

Could you share now the Java code where you built that tags to revise it?

Regards.

Former Member
0 Kudos

maybe the problem is here:

   String inData = convertStreamToString(in);

   String outData = inData.replaceAll("<ns1:","<");

       outData = outData.replaceAll("<","<ns1:");

       outData = outData.replaceAll("<ns1:\\?xml","<\\?xml");

       outData = outData.replaceAll("<ns1:/ns1","</ns1");

thanks...

iaki_vila
Active Contributor
0 Kudos

Hi Marco,

The last doubt

In order to understand what do you want to do with ReplaceAll it would be interesting to know how is your source xml that you want to add the ns1 namespace:

<?xml version="1.0" encoding="UTF-8"?>

<VendorInvoiceSend xmlns="urn:mt.com:shpt:mm:VendorInvoice_">

<SapUser>ALT_MARCO</SapUser>

<AddressMail>Marco@marco.it</AddressMail>

</VendorInvoiceSend>

or

<?xml version="1.0" encoding="UTF-8"?>

<ns1:VendorInvoiceSend xmlns:ns1="urn:mt.com:shpt:mm:VendorInvoice_">

<SapUser>ALT_MARCO</SapUser>

<ns1:AddressMail>Marco@marco.it<ns1:/AddressMail>

</ns1:VendorInvoiceSend>

or

<?xml version="1.0" encoding="UTF-8"?>

<VendorInvoiceSend>

<SapUser>ALT_MARCO</SapUser>

<AddressMail>Marco@marco.it</AddressMail>

</VendorInvoiceSend>

Regards.

iaki_vila
Active Contributor
0 Kudos

Hi Marco,

If your source XML is without namespaces you could make this xsl transformation:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="urn:mt.com:shpt:mm:VendorInvoice_" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <xsl:template match="/VendorInvoiceSend">

        <ns1:VendorInvoiceSend xmlns:ns1="urn:mt.com:shpt:mm:VendorInvoice_">

            <ns1:SapUser>

                        <xsl:value-of select="./SapUser"/>

            </ns1:SapUser>

                    <ns1:AddressMail>

                        <xsl:value-of select="./AddressMail"/>

                    </ns1:AddressMail>

        </ns1:VendorInvoiceSend>

    </xsl:template>

</xsl:stylesheet>

Regards

Former Member
0 Kudos

This is the start xml:

<?xml version="1.0" encoding="UTF-8"?>

<ns1:VendorInvoiceSend xmlns:ns1="urn:mt.com:sharepoint:mm:VendorInvoice_">

<SapUser>ALT_MARCO</SapUser>

</ns1:VendorInvoiceSend>

This should be at the end:

<?xml version="1.0" encoding="UTF-8" ?>

<ns1:VendorInvoiceSend xmlns:ns1="urn:mt.com:sharepoint:mm:VendorInvoice_">

<ns1:SapUser>ALT_MARCO</ns1:SapUser>

</ns1:VendorInvoiceSend>

iaki_vila
Active Contributor
0 Kudos

Hi Marco,

With XSL:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="urn:mt.com:shpt:mm:VendorInvoice_" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <xsl:template match="/ns1:VendorInvoiceSend">

        <ns1:VendorInvoiceSend xmlns:ns1="urn:mt.com:shpt:mm:VendorInvoice_">

            <ns1:SapUser>

                        <xsl:value-of select="./SapUser"/>

            </ns1:SapUser>

        </ns1:VendorInvoiceSend>

    </xsl:template>

</xsl:stylesheet>

With JAVA and with your code (i'd rather XSL )

  String inData = convertStreamToString(in);

   String outData = inData.replaceAll("<ns1:","<");

       outData = outData.replaceAll("<","<ns1:");

       outData = outData.replaceAll("<ns1:\\?xml","<\\?xml");

       outData = outData.replaceAll("<ns1:/ns1","</ns1");

// you forgot <ns1:/SapUser>

outData = outData.replaceAll("<ns1:/","</ns1:");

Regards.

Answers (0)