From: Michael B. <mbe...@mb...> - 2005-10-07 23:36:59
|
Sven Wontroba wrote: [...] > > Ok if I use the following with exist //LinkElements//@src > I get the result 4 hits an nothing else. > If I do the same within quip and query my xml file I'll get the Elements > > Well same happens if I use the XQueryExample.java file in the xmldb example dir. > hits: 4 > query time: 2283 > retrieve time: 281 > Are you saying that the count of 4 is incorrect, or that it's the right count, but you were expecting to see the actual results, not just the hit count? If the former, I don't know what the problem is without seeing some sample data, but if the latter, then there's nothing wrong here. You just need to look at the eXist docs and sample code a bit more closely. I don't know what precisely you mean by "use the following with exist //LinkElements//@src", but if you mean you queried using that XPath via the java client in interactive mode, then after getting the initial hit count response, you have to request the members of the actual result set, eg by show 1 to see the first member of the set etc. You can make that client return a serialized result set in a single operation by running it in batch mode. As for XQueryExample.java, if you look at the source you'll see that although it executes the query, it doesn't attempt to return the result nodes to the console. What you are seeing is all the output it attempts to produce, via the lines System.out.println("hits: " + result.getSize() System.out.println("query time: " + qtime); System.out.println("retrieve time: " + rtime); You would need to extend the code to see the result set displayed. > Well I thought this might be an error and changed to the eXist-snapshot- > 20050805.jar version and getting the following Error within cocoon > class "org.xmldb.api.base.CompiledExpression"'s signer information > does not match signer information of other classes in the same package I don't claim to understand these signing issues, but they have been raised and resolved here before, so please take a look in the list archives. > An other question is ? I tried this one with quip an it worked without a problem > > ? cutting namespace def. > > declare function local:subElements($nameOfElement) as element() > { > for $res in document("BMDM.xml")//mpeg21:Description[@id=$nameOfElement]/mpeg21:Statemen t/* > return $res > }; > for $linkElements in document("BMDM.xml")//LinkElements//@src > let $ergebnisse := local:subElements($linkElements) > return $linkElements > > In exist is seems like I can't return al my elements into my variables to collect the result of my function?? > May be someone could help me how to get around this. So what are you actually trying to do here? You declare a local function, then in your FLOWR expression, for each item in the sequence returned by your XPath, you call that function, passing in the item, then you assign the return value of the function to $ergebnisse, which you then seem to throw away. Even if you didn't throw it away, but instead did a return $ergebnisse, this wouldn't let you accumulate the return values of successive invocations of the function in a persistent variable $ergebnisse as you iterate, which is what you seem to be referring to when you talk about using variables to "collect the result". I think this suggests you need to look a bit further into how variables work in XQuery. I'm puzzled to hear that this code as you reproduce it here really does do what you want it to in quip. But in any case, quip is a partial implementation of the XQuery WD of April 2002, which is a VERY long time ago. eXist's XQuery implementation was recently updated in line with the WDs of September 2005. If you want a reference system, you'd be better off using a recent build of Saxon. Michael Beddow |