WSC Metadata File Creation and Clean Formatting

2018-04-08 04:15:05

We are using Force WSC library in Java to create Metadata xml files.

Functionality it is working as expected but the files it generates when serialized to file is not clean formatted (with lots of redundant xml namespace definitions with each tag, with different local names).

Here is the Java code we are using to generate the xml:

public static File writeMetadataFile(File file, XMLizable metadata) {

file.getParentFile()

.mkdirs();

try (FileOutputStream so = new FileOutputStream(file)) {

XmlOutputStream out = new XmlOutputStream(so, true);

metadata.write(new QName(metadata.getClass()

.getSimpleName()), out, new TypeMapper());

out.flush();

return file;

} catch (IOException e) {

throw new RuntimeException("Exception while writing to file " + file, e);

}

}

Here is the generated Xml for a CustomObject:

xmlns:n1="http://www.w3.org/2001/XMLSch