}
// this creates the new Annotation element as the first child
// of the Node
private synchronized void writeToDOM(Node target, short type) {
Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ?
target.getOwnerDocument() : (Document)target;
DOMParser parser = fGrammar.getDOMParser();
StringReader aReader = new StringReader(fData);
InputSource aSource = new InputSource(aReader);
try {
parser.parse(aSource);
}
catch (SAXException e) {
// this should never happen!
// REVISIT: what to do with this?; should really not
// eat it...
}
catch (IOException i) {
// ditto with above
}
Document aDocument = parser.getDocument();
parser.dropDocumentReferences();
Element annotation = aDocument.getDocumentElement();
Node newElem = null;
if (futureOwner instanceof CoreDocumentImpl) {
newElem = futureOwner.adoptNode(annotation);
// adoptNode will return null when the DOM implementations are not compatible.
if (newElem == null) {