use of lux.xml.tinybin.TinyBinary in project ddf by codice.
the class DynamicSchemaResolver method createTinyBinary.
private byte[] createTinyBinary(String xml) throws XMLStreamException, SaxonApiException {
SaxonDocBuilder builder = new SaxonDocBuilder(processor);
XmlReader xmlReader = new XmlReader();
xmlReader.addHandler(builder);
xmlReader.setStripNamespaces(true);
xmlReader.read(IOUtils.toInputStream(xml));
XdmNode node = builder.getDocument();
TinyTree tinyTree = ((TinyDocumentImpl) node.getUnderlyingNode()).getTree();
TinyBinary tinyBinary = new TinyBinary(tinyTree, StandardCharsets.UTF_8);
return tinyBinary.getBytes();
}
use of lux.xml.tinybin.TinyBinary in project ddf by codice.
the class XpathFilterCollector method collect.
@Override
public void collect(int docId) throws IOException {
Document doc = this.context.reader().document(docId);
BytesRef binaryValue = doc.getBinaryValue(LUX_XML_FIELD_NAME);
if (binaryValue != null) {
byte[] bytes = binaryValue.bytes;
// Lux update chain
if (bytes.length > 4 && bytes[0] == 'T' && bytes[1] == 'I' && bytes[2] == 'N') {
TinyBinary tb = new TinyBinary(bytes, TinyBinaryField.UTF8);
XdmNode node = new XdmNode(tb.getTinyDocument(config));
try {
selector.setContextItem(node);
XdmItem result = selector.evaluateSingle();
if (result != null && result.size() > 0 && !(result.isAtomicValue() && !((XdmAtomicValue) result).getBooleanValue())) {
super.collect(docId);
}
} catch (SaxonApiException e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to evaluate xpath: " + xpath, e);
}
}
}
}
Aggregations