|
|
Re: Formatting XML StructuredDocuments [message #681755 is a reply to message #677509] |
Thu, 09 June 2011 19:29 |
Nick Sandonato Messages: 126 Registered: July 2009 |
Senior Member |
|
|
Hi Gerry,
What's happening in doCreateElement()? Is it creating an Element from a different Document than one that's associated with model? My guess is if that were the case, that the Document associated with elem is different than the one associated with model even after the appendChild, which would also cause the structured document for elem to be different (and potentially null). It looks like we're not throwing the correct DOMException.WRONG_DOCUMENT_ERR if that is the case.
[Updated on: Thu, 09 June 2011 19:41] Report message to a moderator
|
|
|
|
Re: Formatting XML StructuredDocuments [message #683484 is a reply to message #681857] |
Mon, 13 June 2011 20:52 |
Nick Sandonato Messages: 126 Registered: July 2009 |
Senior Member |
|
|
Hey Gerry,
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
element.getStructuredDocument().getLineInformationOfOffset(element.getStartOffset());
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.03997 seconds