Re: [Xmldb-org-xapi] XPathQueryService
Brought to you by:
reinhapa
|
From: Per N. <per...@re...> - 2004-07-18 12:39:12
|
Hi Wolfgang, Thanks for your reply. Please see my answers inline below: tisdagen den 13 juli 2004 15.04 skrev Wolfgang Meier: > Hi Per, > > > does anyone know why XPathQueryService.queryResource(String id, String > > query) is returning a ResourceSet? Would it not make more sense to return > > a XObject (org.xmldb.common.xml.queries.XObject) instead? > > > > i.e.change > > ResourceSet queryResource( String id, String query ) throws > > XMLDBException; to > > XObject queryResource( String id, String query ) throws XMLDBException; > > > > We are querying a single resource and are not expecting a result from any > > other resource and certainly not a set of resources. > > I agree that returning a ResourceSet is somewhat misleading. The query > result could be anything: a set of atomic values, a node set or a document > fragment. While storing a document fragment back into the database with > Collection.storeResource is possible, storing an integer value doesn't make > much sense. > > However, XObject seems too limited to me. First, because the name makes me > expect a single object, second XObject restricts the possible range of data > types. Why not use a more generic concept compatible with the XPath2/XQuery > semantics? Every query returns a "Sequence" containing zero or more > "Items". An item might be a node or an atomic value. JSR 225 chooses this > path. Yes but returning an array of XObjects is just this: a sequence of items that can contain atomic values, document fragments or nodesets. As you know, an XObject is possible to get content as a int, boolean, double string, NodeList and DocumentFragment. I think this covers all possibilities from an XPath result but we can easily add new ones if needed. > > > Returning an XObject makes it possible to handle xpaths that returns > > numbers such as count() in a cleaner way than wrapping the result in XML > > and turning it into a resource. > > > > Actually why not use the same logic for collection scope queries and > > change it from: > > > > ResourceSet query( String query ) throws XMLDBException; > > to > > XObject[] query( String query ) throws XMLDBException; > > ? > > I don't see why collection scope queries should have a different return > type? query() and queryResource() just pre-set the context of the query, > but this context can be changed at any time within the query expression, > using the standard doc() and collection() functions. It is not possible to > determine the result in advance. I was thinking that if an XObject is a returned from a Resource than returning an array of XObjects from a a collection of Resources (one Xobject for each resource that has a match) would make sense. Best regards, Per > > Regards, > > Wolfgang > > > > ------------------------------------------------------- > This SF.Net email sponsored by Black Hat Briefings & Training. > Attend Black Hat Briefings & Training, Las Vegas July 24-29 - > digital self defense, top technical experts, no vendor pitches, > unmatched networking opportunities. Visit www.blackhat.com > _______________________________________________ > Xmldb-org-xapi mailing list > Xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmldb-org-xapi |