Query with subelements inside words

D

dizzyhaze

Here is a sample of the kind of XML I'm working with:

<root>
<elemt>Something is ro<lig>tt</lig>en in the state of
<emph>Den</emph>mark</elemt>
</root>

I would like to be able to extract the contents of <elemt> as a string
without the subelements and with the integrity of the words
unaffected...for example:

<result>
Something is rotten in the state of Denmark
</result>

I have tried various approaches with XQuery along the lines of...

for $TheResult in (/root/elemt) return normalize-space($TheResult)

....but the best I've been able to do is this:

<result>
Something is ro tt en in the state of Den mark
</result>

As you can see, spaces are being inserted in undesirable locations.

Any ideas as to how I can make this work in XQuery?

thanks
Diz.
 
D

dizzyhaze

Problem solved.

My XQuery implementation was/is buggy. Saxon returns the correct result
if fed

fn:string(/root/elemt)

regards,
Diz.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,247
Members
46,844
Latest member
JudyGvh32

Latest Threads

Top