[xquery-talk] suppressing emission of elements if no value

Francis Upton francisu at ieee.org
Thu Jun 10 11:33:07 PDT 2004

I have an application where I am generating XQuery and have a requirement 
that if there is no value for an expression, it should not generate an element.

So I would like something like:

   element x { a/b }

to emit nothing, assuming a/b is empty.

This expression emits <x></x> when a/b is empty.

The only way I can think of to do this is to wrap a condition around it like:

   if (a/b) then element x { a/b } else ()

Is there any other way to approach this?  I don't like wrapping an if 
statement around it because the "a/b" can be quite complex and time 
consuming to compute and there could be quite a number of these in the 
types of documents I'm working with.  I realize this may be something that 
some XQuery engines might optimize; if that's the case it's probably fine.

Thanks for your help.


Francis Upton IV
H/W 510 835 3123
C 510 432 1589
F 501 648 1464 (yes, it is 501)
blog: http://www.nogoop.com/mt/ 

More information about the talk mailing list