return args[0];
NodeValue nv = (NodeValue) args[0].itemAt(0);
if (!nv.isPersistentSet())
return nv;
NodeProxy node = (NodeProxy) nv;
String matchStr = null;
NodeId nodeId = null;
try {
for (EmbeddedXMLStreamReader reader = context.getBroker().getXMLStreamReader(node, true); reader.hasNext(); ) {
int status = reader.next();
if (status == XMLStreamConstants.CHARACTERS) {
matchStr = reader.getText();
nodeId = (NodeId) reader.getProperty(ExtendedXMLStreamReader.PROPERTY_NODE_ID);
break;
}
}
} catch (IOException e) {
throw new XPathException(this, ErrorCodes.FOER0000, "Exception caught while reading document");
} catch (XMLStreamException e) {
throw new XPathException(this, ErrorCodes.FOER0000, "Exception caught while reading document");
}
if (nodeId != null) {
Match match = new NGramMatch(getContextId(), node.getNodeId(), matchStr);
match.addOffset(0, matchStr.length());
node.addMatch(match);
}
return node;
}