Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Problems with IDOMDocument
Problems with IDOMDocument [message #155464] Mon, 09 January 2006 16:06
Sandro Schiefner is currently offline Sandro SchiefnerFriend
Messages: 13
Registered: July 2009
Junior Member
Hello,

I am creating a plugin on top of the WTP-Project. It's really amazing
how many features the project have ;-) Thanks to all the developers...

By testing this plugin I realized following curiosity...

If I open a xml file, close the xml file, open the xml file again and
add a node to the IDOMDocument, the underlying document does not include
the added node.

Does I make something wrong, or is this a bug...
I'am using Eclipse 3.2.0 and WTP 1.0...

I tested it with that code:


IEditorPart editor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();

ITextEditor textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);

IDocument document =
textEditor.getDocumentProvider().getDocument(textEditor.getE ditorInput());

//add node
IStructuredModel model =
StructuredModelManager.getModelManager().getExistingModelFor Edit(document);

if (model==null)
model =
StructuredModelManager.getModelManager().getModelForEdit((IS tructuredDocument)document);

IDOMDocument domDocument = ((IDOMModel)model).getDocument();
Node testNode = domDocument.createElement("test");
domDocument.getDocumentElement().appendChild(testNode);
model.releaseFromEdit();

//get offset of node
IDOMElement testNodeElement = (IDOMElement) testNode;
int start = testNodeElement.getStartOffset();
int end = testNodeElement.getEndOffset();

//test if node is in document
assertEquals(testNodeElement.getSource(), document.get(start, end-start));
Previous Topic:WTP 1.0 hanging
Next Topic:Multiple web services running simultaneously
Goto Forum:
  


Current Time: Thu Mar 28 21:12:29 GMT 2024

Powered by FUDForum. Page generated in 0.02772 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top