use of org.brackit.xquery.xdm.DocumentException in project sirix by sirixdb.
the class SubtreeBuilder method startElement.
@Override
public void startElement(final QNm name) throws DocumentException {
try {
processStartTag(name);
if (mFirst) {
mFirst = false;
mStartNodeKey = mWtx.getNodeKey();
}
final DBNode node = new DBNode(mWtx, mCollection);
mParents.push(node);
mSubtreeProcessor.notifyStartElement(node);
} catch (final SirixException e) {
throw new DocumentException(e.getCause());
}
}
use of org.brackit.xquery.xdm.DocumentException in project sirix by sirixdb.
the class SubtreeBuilder method processingInstruction.
@Override
public void processingInstruction(final QNm target, final Atomic content) throws DocumentException {
try {
processPI(content.asStr().stringValue(), target.getLocalName());
mSubtreeProcessor.notifyProcessingInstruction(new DBNode(mWtx, mCollection));
} catch (final SirixException e) {
throw new DocumentException(e.getCause());
}
}
use of org.brackit.xquery.xdm.DocumentException in project sirix by sirixdb.
the class SubtreeBuilder method comment.
@Override
public void comment(final Atomic content) throws DocumentException {
try {
processComment(content.asStr().stringValue());
if (mFirst) {
mFirst = false;
mStartNodeKey = mWtx.getNodeKey();
}
mSubtreeProcessor.notifyComment(new DBNode(mWtx, mCollection));
} catch (final SirixException e) {
throw new DocumentException(e.getCause());
}
}
use of org.brackit.xquery.xdm.DocumentException in project sirix by sirixdb.
the class Load method execute.
@Override
public Sequence execute(final StaticContext sctx, final QueryContext ctx, final Sequence[] args) throws QueryException {
try {
final String collName = FunUtil.getString(args, 0, "collName", "collection", null, true);
final Sequence resources = args[2];
if (resources == null)
throw new QueryException(new QNm("No sequence of resources specified!"));
final boolean createNew = args.length == 4 ? args[3].booleanValue() : true;
final String resName = FunUtil.getString(args, 1, "resName", "resource", null, createNew ? false : true);
final DBStore store = (DBStore) ctx.getStore();
DBCollection coll;
if (createNew) {
coll = (DBCollection) create(store, collName, resName, resources);
} else {
try {
coll = (DBCollection) store.lookup(collName);
add(store, coll, resName, resources);
} catch (DocumentException e) {
// collection does not exist
coll = (DBCollection) create(store, collName, resName, resources);
}
}
return coll;
} catch (final Exception e) {
throw new QueryException(new QNm(e.getMessage()), e);
}
}
use of org.brackit.xquery.xdm.DocumentException in project sirix by sirixdb.
the class Store method execute.
@Override
public Sequence execute(final StaticContext sctx, final QueryContext ctx, final Sequence[] args) throws QueryException {
try {
final String collName = FunUtil.getString(args, 0, "collName", "collection", null, true);
final Sequence nodes = args[2];
if (nodes == null)
throw new QueryException(new QNm("No sequence of nodes specified!"));
final boolean createNew = args.length == 4 ? args[3].booleanValue() : true;
final String resName = FunUtil.getString(args, 1, "resName", "resource", null, createNew ? false : true);
final DBStore store = (DBStore) ctx.getStore();
if (createNew) {
create(store, collName, resName, nodes);
} else {
try {
final DBCollection coll = (DBCollection) store.lookup(collName);
add(store, coll, resName, nodes);
} catch (DocumentException e) {
// collection does not exist
create(store, collName, resName, nodes);
}
}
return null;
} catch (final Exception e) {
throw new QueryException(new QNm(e.getMessage()), e);
}
}
Aggregations