vgritsenko 2004/03/04 05:18:49
Modified: . status.xml java/src/org/apache/xindice/core/query QueryUtil.java XPathQueryResolver.java java/tests/src/org/apache/xindice/core/query XPathQueryResolverTest.java Log: Support boolean, string, and number XPath query results. Support source attributes for those results. Revision Changes Path 1.39 +17 -4 xml-xindice/status.xml Index: status.xml =================================================================== RCS file: /home/cvs/xml-xindice/status.xml,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- status.xml 24 Feb 2004 16:52:55 -0000 1.38 +++ status.xml 4 Mar 2004 13:18:49 -0000 1.39 @@ -46,11 +46,16 @@ XQuery implementation. </action> </actions> + <actions priority="high"> + <action context="code" dev="open"> + <strong>WebAdmin</strong> Integrate new WebDAV capable WebAdmin into + the main codebase. + </action> + </actions> <actions priority="medium"> <action context="code" dev="open"> - <strong>Authentication</strong> Xindice server should support: server - level authentication configured in the web.xml, and collection level - authentication as per XML:DB API getCollection method. + <strong>Authentication</strong> Xindice server should support collection + level authentication as per XML:DB Database.getCollection method. </action> <action context="code" dev="open"> <strong>Authorization</strong> Xindice should support collection level @@ -68,7 +73,15 @@ </todo> <changes> - <release version="1.1b4-dev" date="February 24 2004"> + <release version="1.1b4-dev" date="March 4 2004"> + <action dev="VG" type="fix" fixes-bug="22155"> + Support boolean, string, and number XPath query results. + </action> + <action dev="VG" type="fix" fixes-bug="22070"> + XPath query resulting in text nodes will return text node + wrapped into the <result> element in + http://xml.apache.org/xindice/Query namespace. + </action> <action dev="VG" type="fix" fixes-bug="22156"> XPath query resulting in attribute nodes will return attributes on the <result> element in http://xml.apache.org/xindice/Query 1.7 +2 -14 xml-xindice/java/src/org/apache/xindice/core/query/QueryUtil.java Index: QueryUtil.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/query/QueryUtil.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- QueryUtil.java 26 Feb 2004 13:50:15 -0000 1.6 +++ QueryUtil.java 4 Mar 2004 13:18:49 -0000 1.7 @@ -115,18 +115,6 @@ } root.appendChild(doc.importNode(n, true)); - } else if (element instanceof Boolean || element instanceof Double) { - Element holder = doc.createElementNS(XindiceCollection.QUERY_NS, "xq:result"); - holder.setAttribute(NodeImpl.XMLNS_PREFIX + ":xq", XindiceCollection.QUERY_NS); - holder.appendChild(doc.createTextNode(element.toString())); - // FIXME: Meta Data - root.appendChild(holder); - } else if (element instanceof String) { - Element holder = doc.createElementNS(XindiceCollection.QUERY_NS, "xq:result"); - holder.setAttribute(NodeImpl.XMLNS_PREFIX + ":xq", XindiceCollection.QUERY_NS); - holder.appendChild(doc.createTextNode((String) element)); - // FIXME: Meta Data - root.appendChild(holder); } else { throw new XindiceRuntimeException("Unknown result type (" + element.getClass().getName() + ") in nodeset"); } 1.28 +39 -46 xml-xindice/java/src/org/apache/xindice/core/query/XPathQueryResolver.java Index: XPathQueryResolver.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/query/XPathQueryResolver.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- XPathQueryResolver.java 8 Feb 2004 02:50:37 -0000 1.27 +++ XPathQueryResolver.java 4 Mar 2004 13:18:49 -0000 1.28 @@ -56,6 +56,8 @@ import org.apache.xindice.xml.SymbolTable; import org.apache.xindice.xml.dom.DBDocument; import org.apache.xindice.xml.dom.DocumentImpl; +import org.apache.xindice.xml.dom.TextImpl; +import org.apache.xindice.xml.dom.DBNode; import org.apache.xml.utils.DefaultErrorHandler; import org.apache.xml.utils.PrefixResolver; import org.apache.xml.utils.PrefixResolverDefault; @@ -1346,8 +1348,7 @@ * ResultSet */ - private class ResultSet implements NodeSet - { + private class ResultSet implements NodeSet { public Collection context; public String query; public ErrorListener errors; @@ -1359,52 +1360,40 @@ public NodeIterator ni; public Object node; - public ResultSet(Collection context, PrefixResolver pr, Key[] keySet, String query) - { + public ResultSet(Collection context, PrefixResolver pr, Key[] keySet, String query) { this.context = context; this.pr = pr; this.keySet = keySet; this.query = query; - errors = new ErrorListener() - { - public void fatalError(TransformerException te) - { - if (log.isFatalEnabled()) - { + errors = new ErrorListener() { + public void fatalError(TransformerException te) { + if (log.isFatalEnabled()) { log.fatal("No message", te); } } - public void error(TransformerException te) - { - if (log.isErrorEnabled()) - { + public void error(TransformerException te) { + if (log.isErrorEnabled()) { log.error("No message", te); } } - public void warning(TransformerException te) - { - if (log.isWarnEnabled()) - { + public void warning(TransformerException te) { + if (log.isWarnEnabled()) { log.warn("No message", te); } } }; - try - { + try { prepareNextNode(); - } - catch (Exception e) - { + } catch (Exception e) { throw new XindiceRuntimeException(e.getMessage()); } } - private void prepareNextNode() throws XMLDBException, TransformerException, DBException - { + private void prepareNextNode() throws XMLDBException, TransformerException, DBException { node = null; while (keyPos < keySet.length) { @@ -1428,9 +1417,8 @@ } final XObject xobject = xp.execute(xpc, n, pfx); - - switch (xobject.getType()) - { + switch (xobject.getType()) { + // case XObject.CLASS_RTREEEFRAG : default : throw new XMLDBException( ErrorCodes.NOT_IMPLEMENTED, @@ -1443,45 +1431,50 @@ case XObject.CLASS_BOOLEAN : ni = EMPTY_NODE_ITERATOR; - node = new Boolean(xobject.bool()); + + node = new DocumentImpl().createTextNode(Boolean.toString(xobject.bool())); + if (n instanceof DBNode) { + ((TextImpl)node).setSource(((DBNode)n).getSource()); + } break; case XObject.CLASS_STRING : ni = EMPTY_NODE_ITERATOR; - node = xobject.str(); + + node = new DocumentImpl().createTextNode(xobject.str()); + if (n instanceof DBNode) { + ((TextImpl)node).setSource(((DBNode)n).getSource()); + } break; case XObject.CLASS_NUMBER : ni = EMPTY_NODE_ITERATOR; - node = new Double(xobject.num()); + + node = new DocumentImpl().createTextNode(Double.toString(xobject.num())); + if (n instanceof DBNode) { + ((TextImpl)node).setSource(((DBNode)n).getSource()); + } break; } - if (node != null) - { + if (node != null) { break; } } } - public boolean hasMoreNodes() - { + public boolean hasMoreNodes() { return node != null; } - public Object getNextNode() - { + public Object getNextNode() { Object n = node; node = ni.nextNode(); - if (node == null) - { - try - { + if (node == null) { + try { prepareNextNode(); - } - catch (Exception e) - { + } catch (Exception e) { throw new XindiceRuntimeException(e.getMessage()); } } 1.8 +4 -5 xml-xindice/java/tests/src/org/apache/xindice/core/query/XPathQueryResolverTest.java Index: XPathQueryResolverTest.java =================================================================== RCS file: /home/cvs/xml-xindice/java/tests/src/org/apache/xindice/core/query/XPathQueryResolverTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- XPathQueryResolverTest.java 8 Feb 2004 03:56:48 -0000 1.7 +++ XPathQueryResolverTest.java 4 Mar 2004 13:18:49 -0000 1.8 @@ -197,11 +197,10 @@ public void testNumberXPathQuery() throws Exception { for (int i = 0; i < NUMBER_QUERY.length; i++) { NodeSet nodeSet = resolver.query(col, NUMBER_QUERY[i], null, null); - Double element = null; assertTrue("Expected one result", nodeSet.hasMoreNodes()); - element = (Double)nodeSet.getNextNode(); + Text element = (Text)nodeSet.getNextNode(); assertNotNull("NodeSet.getNextNode must be not null", element); - assertEquals("Result value", new Double(NUMBER_VALUE[i]), element); + assertEquals("Result value", new Double(NUMBER_VALUE[i]).toString(), element.getNodeValue()); } }