I need to determine whether the cursor is within XML range.
I’ve set start and end text nodes for Range.
I suppose that compareBoundaryPoints method does not work properly for this case. Surely, I can be wrong.
In Java I use com.arbortext.epic.ADocument, org.w3c.dom.ranges.Range imports.
holeRange_ is a org.w3c.dom.ranges.Range object.
holeRange_ = ((DocumentRange) txtProcessor_.GetDocument()).createRange();
holeRange_.setStart(startNode, 0); //text node
holeRange_.setEndAfter(endNode); //text node
Here is the body of click event handler:
Range caretRange = ((ADocument) txtProcessor_.GetDocument()).getInsertionPoint();
if (caretRange != null) {
DebugMode.println(caretRange.getStartContainer().getNodeValue());
DebugMode.println("END_TO_START = " +
textNodeRange_.compareBoundaryPoints(Range.END_TO_START, caretRange));
DebugMode.println("START_TO_END = " +
holeRange_.compareBoundaryPoints(Range.START_TO_END, caretRange));
}
The output gives END_TO_START = -1 and START_TO_END = -1 when the cursor is inside the range.
According to Check if specified element is inside selection the values should be: END_TO_START = -1 and START_TO_END = 1.
Is the problem linked with it:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=148126
tired bro!
I’ve made a tiny port of a triple of methods (
compareBoundaryPoints,isAncestorOf,indexOf) for Range object from xerces c++ XML library to Java. I’ve forgotten about Xerces2 Java.Well, I’ve made a set of experiments which showed that the xerces
compareBoundaryPointsimplementation is more adequate.