use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class NodeWrapper method getParent.
@Override
public NodeInfo getParent() {
try {
NodeInfo parent = null;
final NodeReadTrx rtx = createRtxAndMove();
if (rtx.hasParent()) {
// Parent transaction.
parent = new NodeWrapper(mDocWrapper, rtx.getParentKey());
}
rtx.close();
return parent;
} catch (final SirixException e) {
LOGGER.error(e.getMessage(), e);
return null;
}
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class NodeWrapper method getBaseURI.
@Override
public String getBaseURI() {
String baseURI = null;
NodeInfo node = this;
while (node != null) {
baseURI = node.getAttributeValue(StandardNames.XML_BASE);
if (baseURI == null) {
// Search for baseURI in parent node (xml:base="").
node = node.getParent();
} else {
break;
}
}
if (baseURI == null) {
baseURI = mDocWrapper.getBaseURI();
}
return baseURI;
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class NodeWrapper method getAttributeValue.
@Override
public String getAttributeValue(final int fingerprint) {
String attVal = null;
final NameTest test = new NameTest(Type.ATTRIBUTE, fingerprint, getNamePool());
final AxisIterator iterator = iterateAxis(Axis.ATTRIBUTE, test);
final NodeInfo attribute = (NodeInfo) iterator.next();
if (attribute != null) {
attVal = attribute.getStringValue();
}
return attVal;
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class TestNodeWrapper method testGetBaseURI.
@Test
public void testGetBaseURI() throws Exception {
// Test with xml:base specified.
final File source = new File("src" + File.separator + "test" + File.separator + "resources" + File.separator + "data" + File.separator + "testBaseURI.xml");
final Session session = generateSession();
final NodeWriteTrx wtx = session.beginNodeWriteTrx();
final XMLEventReader reader = XMLShredder.createFileReader(source);
final XMLShredder shredder = new XMLShredder.Builder(wtx, reader, Insert.ASFIRSTCHILD).commitAfterwards().build();
shredder.call();
wtx.close();
final Processor proc = new Processor(false);
final NodeInfo doc = new DocumentWrapper(session, proc.getUnderlyingConfiguration());
doc.getNamePool().allocate("xml", "http://www.w3.org/XML/1998/namespace", "base");
doc.getNamePool().allocate("", "", "baz");
final NameTest test = new NameTest(Type.ELEMENT, "", "baz", doc.getNamePool());
final AxisIterator iterator = doc.iterateAxis(Axis.DESCENDANT, test);
final NodeInfo baz = (NodeInfo) iterator.next();
assertEquals("http://example.org", baz.getBaseURI());
session.close();
mDatabase.close();
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class XPathEvaluator method call.
@Override
public XPathSelector call() throws Exception {
final Processor proc = new Processor(false);
final Configuration config = proc.getUnderlyingConfiguration();
final NodeInfo doc = new DocumentWrapper(mSession, mRevision, config);
final XPathCompiler xpath = proc.newXPathCompiler();
final DocumentBuilder builder = proc.newDocumentBuilder();
final XdmItem item = builder.wrap(doc);
final XPathSelector selector = xpath.compile(mExpression).load();
selector.setContextItem(item);
return selector;
}
Aggregations