Technically, yes.... but.... There is nothing semantically different between single and double quotes.... (the resulting document from JDOM is just as valid).... Is there a really good reason why you need to do this? If there is, I would be interested to know, and perhaps introduce it as a 'native' feature of JDOM....
But, you can change the format of it with (only) a little bit of work - 15 lines of code or so... The JDOM2 API in theory makes this a fair amount easier. You can create your own XMLOutputProcessor, using a subclass of the AbstractXMLOutputProcessor and override the printAttribute() method... for example (getting rid of some code paths that your are not likely to need (like non-escaped output):
private static final XMLOutputProcessor CUSTOMATTRIBUTEQUOTES = new AbstractXMLOutputProcessor() {
@Override
protected void printAttribute(final Writer out, final FormatStack fstack,
final Attribute attribute) throws IOException {
if (!attribute.isSpecified() && fstack.isSpecifiedAttributesOnly()) {
return;
}
write(out, " ");
write(out, attribute.getQualifiedName());
write(out, "=");
write(out, "'"); // Changed from "\""
// JDOM Code used to do this:
// attributeEscapedEntitiesFilter(out, fstack, attribute.getValue());
// Now we instead change to quoting the ' instead of "
String value = Format.escapeAttribute(fstack.getEscapeStrategy(), value);
// undo any " escaping that the Format may have done.
value = value.replaceAll(""", "\"");
// do any ' escaping that needs to be done.
value = value.replaceAll("'", "'");
write(out, value);
write(out, "'"); // Changed from "\""
}
};
Now that you have this cusome outputter, you can use it like:
XMLOutputter xmlOutput = new XMLOutputter(CUSTOMATTRIBUTEQUOTES);
xmlOutput.output(doc, new FileWriter(path));