Esempio n. 1
0
    private String storeDocument(String uri, String content) //throws XQException
    {
        String query = "declare namespace bgdb=\"http://bagridb.com/bdb\";\n" +
                       "declare variable $uri external;\n" +
                       "declare variable $xml external;\n" +
                       "declare variable $props external;\n" +
                       "let $uri := bgdb:store-document($uri, $xml, $props)\n" +
                       "return $uri\n";

        XQPreparedExpression xqpe = xqConn.prepareExpression(query);

        xqpe.bindString(new QName("uri"), uri, xqConn.createAtomicType(8));      //XQItemType.XQBASETYPE_ANYURI));
        xqpe.bindString(new QName("xml"), content, xqConn.createAtomicType(29)); //XQItemType.XQBASETYPE_STRING));
        List props = new ArrayList(2);

        props.add(Constants.pn_document_data_format + "=xml");
        //
        xqpe.bindSequence(new QName("props"), xqConn.createSequence(props.iterator()));
        XQSequence xqs    = xqpe.executeQuery();
        String     result = null;

        try {
            if (xqs.next())
            {
                result = xqs.getAtomicValue();
            }
        } finally {
            xqpe.close();
            xqs.close();
        }
        return(result);
    }
Esempio n. 2
0
    private void deleteDocument(String uri) //throws XQException
    {
        String query = "declare namespace bgdb=\"http://bagridb.com/bdb\";\n" +
                       "declare variable $uri external;\n" +
                       "let $uri := bgdb:remove-document($uri)\n" +
                       "return $uri\n";

        XQPreparedExpression xqpe = xqConn.prepareExpression(query);

        xqpe.bindString(new QName("uri"), uri, xqConn.createAtomicType(8)); //XQItemType.XQBASETYPE_ANYURI));
        XQSequence xqs    = xqpe.executeQuery();
        String     result = null;

        try {
            if (xqs.next())
            {
                result = xqs.getAtomicValue();
            }
            if (!uri.Equals(result))
            {
                throw new XQException("got no result from bgdb:remove-document function");
            }
        } finally {
            xqpe.close();
            xqs.close();
        }
    }