[xquery-talk] XQuery and id()/idref();
Controlling the children of nodes in the result sequence
Florent Georges
lists at fgeorges.org
Wed Apr 23 12:56:52 PDT 2008
Maik Stührenberg wrote:µ
Hi
> - Is there any way to suppress the output of the
> namespaces in each element? Or to be more specific: what
> do I have to change to output all namespaces once (and
> only once) in the resultset element?
You have to add the namespace nodes to the resultset
element. If the above example is a simplification, your
real problem may require more complexity to select the
namespace nodes to add, but from your example, you can
choose to add the namespace nodes from each result/*.
To see how to add a namespace node to an element, you can
have a look at:
http://fgeorges.blogspot.com/2006/08/add-namespace-node-to-element-in.html
You'll be interested too by the functions
in-scope-prefixes() and namespace-uri-for-prefix().
But first, I wonder if it is really worth writing that...
> - The biggest issue is that the b:para element is output
> twice: as child element of the b:text element (which is
> quite fine) and alone. The same problem appears when
> looking at the c:word elements: they should not be
> included as children of the c:sentence element because
> they are related to different spans, but only as children
> of the respective result element.
I am not sure of the question. If you want to "have an
element without its children", you have to understand the
XPath data model: child elements are part of their parent.
If you want a parent that "looks the same" but without the
children, you have to create a new element. For instance,
instead of:
$d/a:collection/a:entry/a:data//*[@a:span = $s/@xml:id]
use rather:
for $e in $d/a:collection/a:entry/a:data
//*[@a:span = $s/@xml:id]
return
element { node-name($e) }{ $e/@* }
> - The third question I'd like to ask concerns the use of
> the fn:idref function in XQuery. My first examples of the
> query used idref() to select all those nodes underneath
> a:data that are related to a certain span -- but I didn't
> manage to get any output although all XSD files are
> available (I use Saxon-SA 9). What has to be changed in
> the XQuery to use the idref function?
Are you sure the document was validated?
Regards,
--drkm
__________________________________________________
Do You Yahoo!?
En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible contre les messages non sollicités
http://mail.yahoo.fr Yahoo! Mail
More information about the talk
mailing list