No, Castor currently does not support XPATH queries or similar. Implementing a custom FieldHandler would be one option, though I would consider this a slight 'misuse'.
Having said that, assuming that you want to 'filter' upon unmarshalling XML adapt into Java objects, you could 'inject' any XPATH/XQuery capable tool before the Unmarshaller, given that it can provide its results in form of SAX events. Werner ________________________________________ Von: Dave_Thomas mailing lists [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 03. April 2007 02:10 An: [email protected] Betreff: [castor-user] How to query XML via generated classes At a client site, I'm using CastorXML 0.9.3. I'm a Castor newb, but I have used other XML bindings like XMLBeans, pyXml, etc. Operating on generated code, what options do I have for querying and/or limiting results? What is the "right" way? For example: <dog breed="Lab"> <id name="John"/> <fur color="Black"/> </dog> <dog breed="Corgi> <id name="Jim"/> <fur color="Tricolor"/> </dog> <dog breed="Lab"> <id name="Tony"/> <fur color="Golden"/> </dog> Let's say I want all of the dogs of breed "Lab". Or all dogs who are black. Or the names of every Corgi. 1. IMHO, the natural thing to do would be to use XPath/XQuery like /[EMAIL PROTECTED]"Lab"]. Is there a way to do this with Castor (and other libraries if necessary)? 2. It looks like I can implement a FieldHandler as a custom getter. Is this commonly done or a best practice? ie Dog getDogByBreed(String breed) {...} 3. If worst comes to worst, I can always brute-force walk the results. for(Dog d: dogs) { if(d.getBreed().equals("Lab")) { list.add(d); } } 4. Or is there a way to do this in a mapping file? Thanks! --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email

