I have code that generates a * .xsd file from a set of jaxb-annotated classes:
JAXBContext context =
final DOMResult result = new DOMResult();
context.generateSchema(new SchemaOutputResolver() {
@Override
public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
return result;
}
});
Document doc = result.getNode();
OutputFormat format = new OutputFormat(doc);
format.setIndenting(true);
StringWriter writer = new StringWriter();
XMLSerializer serializer = new XMLSerializer(writer, format);
serializer.serialize(doc);
String xsd = writer.toString();
the problem is that it xsdproduces (stored in xsd) in a random order - 2 works with the same input, can generate logically identical xsds, but in different orders of elements, which leads to chaos with diff tools when writing it to a file.
How do I "canonicalize" xml inside xsd?
I saw some other xslt links in related questions, but all I saw required listing the elements in advance. im looking for something that works on any xml input.
radai