Package org.exist.xmldb

Examples of org.exist.xmldb.LocalXMLResource$InternalXMLSerializer


  public Resource getResource(Object r) throws XMLDBException {
    LocalCollection collection = null;
    Subject user = null;
   
    LocalXMLResource res = null;
    if (r instanceof NodeProxy) {
      NodeProxy p = (NodeProxy) r;
      res = new LocalXMLResource(user, db, collection, p);
    } else if (r instanceof Node) {
      res = new LocalXMLResource(user, db, collection, XmldbURI.EMPTY_URI);
      res.setContentAsDOM((Node)r);
    } else if (r instanceof AtomicValue) {
      res = new LocalXMLResource(user, db, collection, XmldbURI.EMPTY_URI);
      res.setContent(r);
    } else if (r instanceof LocalXMLResource)
      res = (LocalXMLResource) r;
    else
      throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "unknown object "+r.getClass());
   
    try {
      Field field = res.getClass().getDeclaredField("outputProperties");
      field.setAccessible(true);
      field.set(res, new Properties(defaultProperties));
    } catch (Exception e) {
    }
    return res;
View Full Code Here


     * @return A NodeProxy for accessing the content represented by xres
     * @throws XPathException if an XMLDBException is encountered
     */
    public static final NodeProxy getNode(DBBroker broker, XMLResource xres) throws XPathException {
        if(xres instanceof LocalXMLResource) {
            final LocalXMLResource lres = (LocalXMLResource)xres;
            try {
                return lres.getNode();
            } catch (final XMLDBException xe) {
                throw new XPathException("Failed to convert LocalXMLResource to node: " + xe.getMessage());
            }
        }
       
View Full Code Here

        try {
            String query = "let $value := 'world' return\n" +
                    "\tutil:eval(xs:anyURI('/db/" + INVOKABLE_QUERY_FILENAME + "'), false(), (xs:QName('" + INVOKABLE_QUERY_EXTERNAL_VAR_NAME + "'), $value))";
            result = service.query(query);

            LocalXMLResource res = (LocalXMLResource)result.getResource(0);
            Node n = res.getContentAsDOM();
            assertEquals(n.getLocalName(), "hello");
            assertEquals("world", n.getFirstChild().getNodeValue());
        } catch (XMLDBException e) {
            System.out.println("testEval(): " + e);
            fail(e.getMessage());
View Full Code Here

        ResourceSet result = null;
        try {
            String query = "util:eval(xs:anyURI('/db/test/test.xq'), false(), ())";
            result = service.query(query);

            LocalXMLResource res = (LocalXMLResource)result.getResource(0);
            assertNotNull(res);
            Node n = res.getContentAsDOM();
            assertEquals("y", n.getLocalName());

            query = "util:eval(xs:anyURI('/db/test/test1.xq'), false(), ())";
            result = service.query(query);

            res = (LocalXMLResource)result.getResource(0);
            assertNotNull(res);
            n = res.getContentAsDOM();
            assertEquals("x", n.getLocalName());
        } catch (XMLDBException e) {
            System.out.println("testEval(): " + e);
            fail(e.getMessage());
        }
View Full Code Here

TOP

Related Classes of org.exist.xmldb.LocalXMLResource$InternalXMLSerializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.