|Re: Formatting XML StructuredDocuments [message #683484 is a reply to message #681857]
||Mon, 13 June 2011 20:52
| Nick Sandonato
Registered: July 2009
Glad it's working!
I can't say with certainty what's causing it to be fine with the XML editor open. I've tried with the XML editor open, and I'm seeing a BadLocationException being thrown followed by an NPE in a different spot. Was the element being formatted properly when the editor was open too?
But, the text gets persisted to the structured document because once the element is added as a child, the model updater of the parent--which is different from the new element's model--is notified and knows that it needs to update the structured document's source with the generated source of the new tag. This structured document differs from the structured document associated with the ownerDocument of the new element. It looks like the flatNode associated with the new element is based on the location it is in the parent node's source, but the structured document of the new element is completely different from the parent. So location problems are likely to occur.
For example, if I created an element from an empty, unmanaged model, element.getStructuredDocument() would return an empty string. If I tried to do something like
We'd get a bad location exception since getStartOffset() would be based off the offset of the flatNode in the populated document.
[Updated on: Mon, 13 June 2011 20:56]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.04966 seconds