I have the following function:
private static void prettyPrint(Document doc, File destFile)
{
TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer serializer;
try
{
if( !destFile.getParentFile().exists() )
{
destFile.getParentFile().mkdirs();
}
serializer = tfactory.newTransformer();
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
try
{
serializer.transform(new DOMSource(doc),
new StreamResult(new FileOutputStream(destFile)));
}
catch( FileNotFoundException e )
{
e.printStackTrace();
}
}
catch (TransformerException e)
{
e.printStackTrace();
}
}
I use it to "pretty print" my XML. However, it prints the attributes' values with double quotes around them, as opposed to single quotes. Now, I realize that XML is agnostic concerning double vs single quotes for values, but the customer I'm providing the XML for requires single quotes.
So, that being said, does anyone know of an output property I could set to tell the transformer to print single quotes instead of double quotes?
Thanks for your help,
B.J.