Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Getting the Node given an ITextRegion
Getting the Node given an ITextRegion [message #214071] Tue, 20 May 2008 14:30 Go to previous message
Eclipse User
Originally posted by: dcarver.starstandard.org

Is there a way to get the DOM node of a StructuredDocument, given a
ITextRegion.

I've tried the following, but I'm not getting the Attribute Node or the
DOM node I would expect:

public static IDOMNode getNode(IStructuredDocumentRegion
documentRegion, ITextRegion textRegion) {
IStructuredModel sModel =
StructuredModelManager.getModelManager().getExistingModelFor Read(documentRegion.getParentDocument());
IDOMDocument documentNode = ((IDOMModel) sModel).getDocument();

return
(IDOMNode)documentNode.getModel().getIndexedRegion(documentR egion.getStartOffset(textRegion));
}

In particular, if I'm in an Attribute Value region, I would like to
return the DOM Node for the attribute, or at least get the TextNode for
the attribute. However, the last is something that I don't think is
implemented right in the WTP DOM implementation, as attributes aren't
returning nodes even though the DOM Level 1 spec says they can have Text
Nodes or Entity Nodes. If it returned the value as a TextNode, then it
would be a matter of just getting the parent Node.

Anyways, what is the correct way to get the information I'm looking for?
 
Read Message
Read Message
Read Message
Previous Topic:Using a JavaScript library in an existing project
Next Topic:"Classpath entry ... will not be exported or published" warnings
Goto Forum:
  


Current Time: Sat May 25 16:44:26 EDT 2013

Powered by FUDForum. Page generated in 0.02144 seconds