Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Query with subelements inside words

Reply
Thread Tools

Query with subelements inside words

 
 
dizzyhaze@gmail.com
Guest
Posts: n/a
 
      06-01-2005
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.

 
Reply With Quote
 
 
 
 
dizzyhaze@gmail.com
Guest
Posts: n/a
 
      06-01-2005
Problem solved.

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

fn:string(/root/elemt)

regards,
Diz.

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SubElements in my WebControl Daniel Jorge ASP .Net 0 07-10-2005 03:57 PM
print all subelements plus content David Simons XML 0 02-23-2005 10:44 PM
Unconnected subelements of Composite Formal Ports Nitin Khurana VHDL 2 04-27-2004 02:26 PM
Selecting subelements from a node-set thomas XML 2 01-25-2004 08:59 PM
Re: novice Q: can an element have text and subelements at the same time? Nicole Szymanski XML 3 07-11-2003 04:28 PM



Advertisments