Search in sources :

Example 16 with DocumentException

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());
    }
}
Also used : DocumentException(org.brackit.xquery.xdm.DocumentException) SirixException(org.sirix.exception.SirixException)

Example 17 with DocumentException

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());
    }
}
Also used : DocumentException(org.brackit.xquery.xdm.DocumentException) SirixException(org.sirix.exception.SirixException)

Example 18 with DocumentException

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());
    }
}
Also used : DocumentException(org.brackit.xquery.xdm.DocumentException) SirixException(org.sirix.exception.SirixException)

Example 19 with DocumentException

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);
    }
}
Also used : QNm(org.brackit.xquery.atomic.QNm) DBCollection(org.sirix.xquery.node.DBCollection) QueryException(org.brackit.xquery.QueryException) DocumentException(org.brackit.xquery.xdm.DocumentException) Sequence(org.brackit.xquery.xdm.Sequence) DBStore(org.sirix.xquery.node.DBStore) QueryException(org.brackit.xquery.QueryException) DocumentException(org.brackit.xquery.xdm.DocumentException) IOException(java.io.IOException)

Example 20 with DocumentException

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);
    }
}
Also used : QNm(org.brackit.xquery.atomic.QNm) DBCollection(org.sirix.xquery.node.DBCollection) QueryException(org.brackit.xquery.QueryException) DocumentException(org.brackit.xquery.xdm.DocumentException) Sequence(org.brackit.xquery.xdm.Sequence) DBStore(org.sirix.xquery.node.DBStore) QueryException(org.brackit.xquery.QueryException) DocumentException(org.brackit.xquery.xdm.DocumentException) IOException(java.io.IOException)

Aggregations

DocumentException (org.brackit.xquery.xdm.DocumentException)35 SirixException (org.sirix.exception.SirixException)25 SubtreeListener (org.brackit.xquery.node.parser.SubtreeListener)7 AbstractTemporalNode (org.brackit.xquery.xdm.AbstractTemporalNode)7 XdmNodeWriteTrx (org.sirix.api.XdmNodeWriteTrx)7 QNm (org.brackit.xquery.atomic.QNm)5 DatabaseConfiguration (org.sirix.access.conf.DatabaseConfiguration)5 Database (org.sirix.api.Database)5 SirixRuntimeException (org.sirix.exception.SirixRuntimeException)5 ResourceManager (org.sirix.api.ResourceManager)4 IOException (java.io.IOException)3 XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)3 PrintStream (java.io.PrintStream)2 Path (java.nio.file.Path)2 QueryException (org.brackit.xquery.QueryException)2 Sequence (org.brackit.xquery.xdm.Sequence)2 DBCollection (org.sirix.xquery.node.DBCollection)2 DBStore (org.sirix.xquery.node.DBStore)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1