Match nextMatch = this.match;
while (nextMatch != null) {
if (proxy.getNodeId().isDescendantOf(nextMatch.getNodeId())) {
if (ancestors == null)
{ancestors = new ExtArrayNodeSet();}
ancestors.add(new NodeProxy(proxy.getDocument(), nextMatch.getNodeId()));
}
nextMatch = nextMatch.getNextMatch();
}
if (ancestors != null && !ancestors.isEmpty()) {
for (final Iterator<NodeProxy> i = ancestors.iterator(); i.hasNext();) {
final NodeProxy p = i.next();
int startOffset = 0;
try {
final XMLStreamReader reader = broker.getXMLStreamReader(p, false);
while (reader.hasNext()) {
final int ev = reader.next();
final NodeId nodeId = (NodeId) reader.getProperty(ExtendedXMLStreamReader.PROPERTY_NODE_ID);
if (nodeId.equals(proxy.getNodeId()))
{break;}
if (ev == XMLStreamConstants.CHARACTERS)
{startOffset += reader.getText().length();}
}
} catch (final IOException e) {
LOG.warn("Problem found while serializing XML: " + e.getMessage(), e);
} catch (final XMLStreamException e) {
LOG.warn("Problem found while serializing XML: " + e.getMessage(), e);
}
if (offsetStack == null)
{offsetStack = new Stack<NodeOffset>();}
offsetStack.push(new NodeOffset(p.getNodeId(), startOffset));
}
}
}