DataSetContextExtractor { public static Multimap<String, DataSetContext> getCitationReferences(String tei) throws XPathException, IOException { XQueryProcessor xQueryProcessor = new XQueryProcessor(tei); SequenceIterator it = xQueryProcessor.getSequenceIterator(CONTEXT_EXTRACTION_BIB_XQ); Item item; Multimap<String, DataSetContext> contexts = multimap(); while ((item = it.next()) != null) { String val = item.getStringValue(); String citationTeiId = it.next().getStringValue(); String sectionName = it.next().getStringValue(); double pos = Double.parseDouble(it.next().getStringValue()); String coords = it.next().getStringValue(); DataSetContext pcc = new DataSetContext(); String context = cutContextSimple(val); pcc.setContext(extractContextSentence(context)); pcc.setDocumentCoords(coords); pcc.setTeiId(citationTeiId); contexts.put(citationTeiId, pcc); } return contexts; }  static Multimap<String, DataSetContext> getCitationReferences(String tei); static Multimap<String, DataSetContext> getFormulaReferences(String tei); static final Pattern REF_PATTERN; static final int CUT_DEFAULT_LENGTH; }
@Test public void testRefEscapes() throws Exception { InputStream is = this.getClass().getResourceAsStream("/test/tei-escape.xml"); String tei = IOUtils.toString(is, StandardCharsets.UTF_8); is.close(); DataSetContextExtractor.getCitationReferences(tei); }