0

I am trying to create xml file using java. where the expected output is given below

EXPECTED OUTPUT

<?xml version="1.0" encoding="utf-8"?>
<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" 
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" 
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID>
<cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>
<cbc:ID>2019-112</cbc:ID>
<cbc:IssueDate>2019-01-21</cbc:IssueDate>
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
</Invoice>      

ACTUAL OUTPUT

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns4:Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:ns3="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:ns4="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</CustomizationID>
<ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</ProfileID>
<InvoiceTypeCode>380</InvoiceTypeCode>
</ns4:Invoice>

For clear understanding, lets take "cbc:CustomizationID" in expected output, but in actual output only "CustomizationID"

S Mugunthan kumar
  • 177
  • 1
  • 2
  • 11
  • you can refer this link - [https://stackoverflow.com/questions/1299926/changing-node-name-of-xml-node-with-java][1] – richa kumari Mar 08 '19 at 12:36

2 Answers2

0

The actual output is the same as the expected. Just changes how the namespaces are applied.

The XML Parser should treat it exactly the same.

Take a look at XML namespaces.

jbonet
  • 76
  • 7
0

I have changed the @XmlElement(name = "cbc:CustomizationID", required = true) after generating java class using xjc command. partially issue is solved but needs to change root element to inserted of

S Mugunthan kumar
  • 177
  • 1
  • 2
  • 11