on 04-26-2012 10:25 AM
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<
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>
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...
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.
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
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>
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.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
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.