Hello All, I want to generate an Xml which looks like-
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <env:Body> <m:GetCalculation xmlns:m="http://xb2.net/soap"> <UID xsi:type="xs:string">userId</UID> <PWD xsi:type="xs:string">password</PWD> <CLIENT xsi:type="xs:string">client</CLIENT> <VERSION xsi:type="xs:string">version</VERSION> <PARTNER xsi:type="xs:string">partner</PARTNER> <FORMAT xsi:type="xs:string">format</FORMAT> <DATA xsi:type="xs:string">data</DATA> <CALCMODE xsi:type="xs:string"></CALCMODE> </m:GetCalculation> </env:Body> </env:Envelope> but I could not write schema for above given xml using encoding UTF-8. So I wrote a simple xsd for the xml and then trying to add namespaces and prefixes using xmlbeans code. Xmlbeans code fragment is as below - EnvelopeDocument envelopDoc = EnvelopeDocument.Factory.newInstance(); XmlCursor cursor = envelopDoc.newCursor(); cursor.toFirstContentToken(); cursor.insertNamespace("env", "http://www.specsavers.com/liab/schema"); cursor.dispose(); Envelope newEnvelope = envelopDoc.addNewEnvelope(); Body newBody = newEnvelope.addNewBody(); GetCalculation newGetCalculation = newBody.addNewGetCalculation(); XmlCursor newCursor = newGetCalculation.newCursor(); newCursor.toNextToken(); newCursor.insertNamespace("m","http://xb2.net/soap"); newCursor.dispose() newGetCalculation.setCALCMODE("TODO Temporary Value"); .................................... ......................................; return envelopDoc.toString(); which generate xml as - <xml-fragment xmlns:env="http://www.specsavers.com/liab/schema"> <env:Envelope> <env:Body> <env:GetCalculation xmlns:m="http://xb2.net/soap"> <env:CALCMODE>TODO Temporary Value</env:CALCMODE> </env:GetCalculation> </env:Body> </env:Envelope> </xml-fragment> Now, I need to replace <env:GetCalculation xmlns:m="http://xb2.net/soap"> with <m:GetCalculation xmlns:m="http://xb2.net/soap"> and also need to remove <env:> prefix from <env:CALCMODE>TODO Temporary Value</env:CALCMODE> tag. Expected xml is- <xml-fragment xmlns:env="http://www.specsavers.com/liab/schema"> <env:Envelope> <env:Body> <m:GetCalculation xmlns:m="http://xb2.net/soap"> // prefix 'env' replaced by prefix 'm' <CALCMODE>TODO Temporary Value</CALCMODE> // no prefix 'env' here </env:GetCalculation> </env:Body> </env:Envelope> </xml-fragment> Please help me out on this issue. Any of the solution, either creating xsd for the xml using utf-8 encoding or modify/remove prefix using xmlbeans code, will be appreciated. Many thanks in advance. ********************************************************************************************************************** <img src='http://jktech.com//cms/website_files/image001.jpg' /> <p> CONFIDENTIALITY. This e-mail and any attachments are confidential and may also be privileged. If you are not the named recipient, please notify the sender immediately and do not disclose the contents to another person, use it for any purpose, or store or copy the information in any medium. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of JK Technosoft Ltd. If you have received this e-mail in error please immediately notify us at administra...@jktech.com </p> **********************************************************************************************************************