I would like to create a specific xml document with XML Beans. So I have been reached an acceptable result like this one:
<Req accessId="1234" ver="1.1">
<Loc id="007" maxNr="5">
<Altitude x="123" y="987" type="ABC"/>
</Loc>
</Req>
Now a need the XML Documents´s typical XML Header, but I not found a solution by using XMLBeans. This is that I need as result:
<?xml version="1.0" encoding="UTF-8"?>
<Req accessId="1234" ver="1.1">
<Loc id="007" maxNr="5">
<Altitude x="123" y="987" type="ABC"/>
</Loc>
</Req>
The Java Code, which create the XMl Result on console:
XmlOptions options = new XmlOptions();
Map<String, String> substNameSpaces = new HashMap<String, String>();
substNameSpaces.put("ext", null);
options.setSavePrettyPrint();
options.setLoadSubstituteNamespaces(substNameSpaces);
options.setUseDefaultNamespace();
options.setSaveOuter();
// ReqDocument
ReqDocument doc = ReqDocument.Factory.newInstance(options);
// Req
Req req = doc.addNewReq();
req.setAccessId("1234");
req.setVer("1.1");
// Loc
Loc locValReq = req.addNewLoc();
loc.setId("007");
loc.setMaxNr(5);
// Altitude
Location location = loc.addNewAltitude();
location.setX(123);
location.setY(987);
location.setType("ABC");
// Outline
System.out.println(req.xmlText(options));
Can anybody help me?