[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.webtools] Getting the Node given an ITextRegion

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().getExistingModelForRead(documentRegion.getParentDocument());
IDOMDocument documentNode = ((IDOMModel) sModel).getDocument();


return (IDOMNode)documentNode.getModel().getIndexedRegion(documentRegion.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?