use of org.exist.dom.QName in project exist by eXist-db.
the class ExceptTest method createInMemoryDocument.
private Document createInMemoryDocument() {
final MemTreeBuilder memtree = new MemTreeBuilder();
memtree.startDocument();
memtree.startElement(new QName("m1", XMLConstants.NULL_NS_URI), null);
memtree.startElement(new QName("m2", XMLConstants.NULL_NS_URI), null);
memtree.characters("test data");
memtree.endElement();
memtree.endElement();
memtree.endDocument();
return memtree.getDocument();
}
use of org.exist.dom.QName in project exist by eXist-db.
the class CleanupTest method resetStateofInternalModule.
@Test
public void resetStateofInternalModule() throws XMLDBException, XPathException {
final EXistXQueryService service = (EXistXQueryService) collection.getService("XQueryService", "1.0");
final CompiledExpression compiled = service.compile(INTERNAL_MODULE_TEST);
final Module[] modules = ((PathExpr) compiled).getContext().getModules(MODULE_NS);
assertEquals(1, modules.length);
final Module module = modules[0];
module.declareVariable(new QName("VAR", MODULE_NS, "t"), "TEST");
final InternalFunctionCall root = (InternalFunctionCall) ((PathExpr) compiled).getFirst();
final TestModule.TestFunction func = (TestModule.TestFunction) root.getFunction();
final ResourceSet result = service.execute(compiled);
assertEquals(result.getSize(), 1);
assertEquals(result.getResource(0).getContent(), "TEST");
assertFalse(func.dummyProperty);
}
use of org.exist.dom.QName in project exist by eXist-db.
the class CleanupTest method preserveExternalVariable.
@Test
public void preserveExternalVariable() throws XMLDBException, XPathException {
// see https://github.com/eXist-db/exist/pull/1512 and use of util:eval
final EXistXQueryService service = (EXistXQueryService) collection.getService("XQueryService", "1.0");
final CompiledExpression compiled = service.compile(INTERNAL_MODULE_EVAL_TEST);
final Module[] modules = ((PathExpr) compiled).getContext().getModules(MODULE_NS);
assertEquals(1, modules.length);
final Module module = modules[0];
module.declareVariable(new QName("VAR", MODULE_NS, "t"), "TEST");
final ResourceSet result = service.execute(compiled);
assertEquals(result.getSize(), 2);
assertEquals(result.getResource(1).getContent(), "TEST");
final Variable var = module.resolveVariable(new QName("VAR", MODULE_NS, "t"));
assertNull(var);
}
use of org.exist.dom.QName in project exist by eXist-db.
the class ValueSequenceTest method sortInDocumentOrder.
@Test
public void sortInDocumentOrder() throws EXistException, PermissionDeniedException, AuthenticationException {
final ValueSequence seq = new ValueSequence(true);
seq.keepUnOrdered(true);
// in-memory doc
final MemTreeBuilder memtree = new MemTreeBuilder();
memtree.startDocument();
memtree.startElement(new QName("m1", XMLConstants.NULL_NS_URI), null);
memtree.startElement(new QName("m2", XMLConstants.NULL_NS_URI), null);
memtree.characters("test data");
memtree.endElement();
memtree.endElement();
memtree.endDocument();
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final Subject admin = pool.getSecurityManager().authenticate("admin", "");
try (final DBBroker broker = pool.get(Optional.of(admin))) {
// persistent doc
final Collection sysCollection = broker.getCollection(SecurityManager.SECURITY_COLLECTION_URI);
final DocumentImpl doc = sysCollection.getDocument(broker, XmldbURI.create("config.xml"));
final NodeProxy docProxy = new NodeProxy(doc);
final NodeProxy nodeProxy = new NodeProxy(doc, ((NodeImpl) doc.getFirstChild()).getNodeId());
seq.add(memtree.getDocument());
seq.add(docProxy);
seq.add((org.exist.dom.memtree.NodeImpl) memtree.getDocument().getFirstChild());
seq.add(nodeProxy);
// call sort
seq.sortInDocumentOrder();
}
}
use of org.exist.dom.QName in project exist by eXist-db.
the class EXistTreeBuilder method startElem.
// TODO EXPath Caller should send QName, otherwise we duplicate code and reduce reuse!
@Override
public void startElem(final String localname) throws ToolsException {
final String prefix = HttpConstants.HTTP_CLIENT_NS_PREFIX;
final String uri = HttpConstants.HTTP_CLIENT_NS_URI;
builder.startElement(new QName(localname, uri, prefix), null);
}
Aggregations