|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Better way to structure XQueryChristian Grün christian.gruen at gmail.comWed Jul 8 21:04:08 PDT 2009
> The following code is what I have now, and it works. But something tells > me it can be better. I am using XQuery implementation within the eXist > database if that helps. > > let $mydoc :=doc('http://localhost:8080/exist/rest/db/bio.xml') > let $profileType := 'Standard' > let $paths := ($mydoc/metadata/idinfo/spdom/bounding/boundalt/altmin, > $mydoc/metadata/idinfo/spdom/bounding/boundalt/altmax, path3, path4, ...) > > for $p in $paths > let $profileType := if ($p) then 'Biological' else $profileType Stacy, I don't know if this helps, but you your query could be simplified as follows: let $mydoc := doc('http://localhost:8080/exist/rest/db/bio.xml') let $profileType := if( $mydoc/metadata/idinfo/spdom/bounding/boundalt/altmin, $mydoc/metadata/idinfo/spdom/bounding/boundalt/altmax, path3, path4, ... ) then 'Biological' else 'Standard' return ... If one of the paths exists, $profileType will be set to 'Biological'. - As variables cannot be assigned more than once in XQuery, a second assignment of $profileType will just hide the first one. Best, Christian, http://basex.org
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






