| Getting the Node given an ITextRegion [message #214071] |
Tue, 20 May 2008 14:30  |
|
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?
|
|
|