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) {



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

XmlOutputStream out = new XmlOutputStream(so, true);

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

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


return file;

} catch (IOException e) {

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



Here is the generated Xml for a CustomObject: