Much more progress with the collation app
Eventually fixed the scrollbar problems by deleting and recreating the controls. Somehow the scrollpanes had become disconnected from the text areas, and there seemed to be no way to re-connect them.
Once that was solved, I was able to get back to working on the XML output. I found that I was able to get the text content of a node using the DOM level 3 getTextContent() method, now available in Java 1.6, which simplified getting the reading and lemma text for display. Popping up dialog boxes for choosing whether a variant was substantive or not proved fairly simple, and it was easy to add/remove/modify the value of the type attribute on the <rdg> tags based on the response.
What proved remarkably difficult was serializing the XML back out as text, to go in the textarea for saving. For the record, here's the code I ended up with:
private String saveDomDocToString(){
try{
javax.xml.transform.TransformerFactory transformerFactory =
javax.xml.transform.TransformerFactory.newInstance();
javax.xml.transform.Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
java.io.StringWriter xmlout = new java.io.StringWriter();
javax.xml.transform.stream.StreamResult result = new
javax.xml.transform.stream.StreamResult(xmlout);
transformer.transform(new javax.xml.transform.dom.DOMSource(doc),result);
return xmlout.toString();
}
catch(Exception e){
JOptionPane.showMessageDialog(this, e.toString(), "Error serializing the XML", JOptionPane.ERROR_MESSAGE);
return "";
}
}
I've tested this fairly thoroughly, even injecting Japanese characters into the input from Collate and seeing them successfully work through to the output, so I think this is robust from the character encoding point of view. Next I need to look at the notes Cara gave me in edited files last week, and see what other concerns remain to be addressed.