Search in sources :

Example 1 with NameTest

use of net.sf.saxon.pattern.NameTest 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;
}
Also used : NameTest(net.sf.saxon.pattern.NameTest) NodeInfo(net.sf.saxon.om.NodeInfo) AxisIterator(net.sf.saxon.tree.iter.AxisIterator)

Example 2 with NameTest

use of net.sf.saxon.pattern.NameTest 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();
}
Also used : NameTest(net.sf.saxon.pattern.NameTest) Processor(net.sf.saxon.s9api.Processor) NodeInfo(net.sf.saxon.om.NodeInfo) NodeWriteTrx(org.sirix.api.NodeWriteTrx) XMLEventReader(javax.xml.stream.XMLEventReader) XMLShredder(org.sirix.service.xml.shredder.XMLShredder) File(java.io.File) AxisIterator(net.sf.saxon.tree.iter.AxisIterator) Session(org.sirix.api.Session) NameTest(net.sf.saxon.pattern.NameTest) Test(org.junit.Test)

Aggregations

NodeInfo (net.sf.saxon.om.NodeInfo)2 NameTest (net.sf.saxon.pattern.NameTest)2 AxisIterator (net.sf.saxon.tree.iter.AxisIterator)2 File (java.io.File)1 XMLEventReader (javax.xml.stream.XMLEventReader)1 Processor (net.sf.saxon.s9api.Processor)1 Test (org.junit.Test)1 NodeWriteTrx (org.sirix.api.NodeWriteTrx)1 Session (org.sirix.api.Session)1 XMLShredder (org.sirix.service.xml.shredder.XMLShredder)1