Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XQuery concatenation on return

Status
Not open for further replies.

evaleah

Programmer
Mar 18, 2003
252
US
I have the following bit of xquery
Code:
for $x in $doc/ClinicalDocument/component/structuredBody/component/section
            where $x/title="Problems"
            return ($x/entry/act/entryRelationship/observation/value/@displayName,"|")
It is returning the following
Code:
AsthmaPneumoniaPneumoniaClinical findingMyocardial infarction |
But what I really want is the bar between each result so I get something like this:
Code:
Asthma|Pneumonia|Pneumonia|Clinical finding|Myocardial infarction|
Does anyone know how to do this?

Thanks!
 
[0] The output you mentioned is out of normal. It should be (runtime) error if you try to serialize a free-standing attribute node (@displayName). If that part is an element (with simple content), that would be fine - but, it would be of the format close to what you would like to have if the application is of output in text mode. In either case, it is at odds with what you said.

[1] In any case try this.
>return ($x/entry/act/entryRelationship/observation/value/@displayName,"|")
[tt]return ([red]string([/red]$x/entry/act/entryRelationship/observation/value/@displayName[red])[/red],"|")[/tt]
 
Thanks tsuji!

I had actually tried something similar to what you recommend here and the result is the same as your recommendation.I get
Code:
Asthma |
It only pulls one of the results then rather than all of the attribute values and then stops.
 
I got it! Wow, that was a bit of learning.
Code:
for $x in $doc/ClinicalDocument/component/structuredBody/component/section
            for $prob in $x/entry/act/entryRelationship/observation/value/@displayName
            where $x/title="Problems"
            return ($prob,"|")
 
[2] Well, I am not convinced. What is the xquery processor you're using? It should still need to explicitly tell the processor, unless the processor takes some implementation shortcut, to get the "value" of the attribute.
[tt] return ([red]string([/red]$prob[red])[/red],"|")[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top