Query with subelements inside words

Discussion in 'XML' started by dizzyhaze@gmail.com, Jun 1, 2005.

  1. Guest

    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.
    , Jun 1, 2005
    #1
    1. Advertising

  2. Guest

    Problem solved.

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

    fn:string(/root/elemt)

    regards,
    Diz.

    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.
    , Jun 1, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nitin Khurana
    Replies:
    2
    Views:
    830
    Jonathan Bromley
    Apr 27, 2004
  2. Daniel Jorge

    SubElements in my WebControl

    Daniel Jorge, Jul 10, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    351
    Daniel Jorge
    Jul 10, 2005
  3. Nicole Szymanski
    Replies:
    3
    Views:
    802
  4. thomas
    Replies:
    2
    Views:
    386
    thomas
    Jan 25, 2004
  5. David Simons

    print all subelements plus content

    David Simons, Feb 23, 2005, in forum: XML
    Replies:
    0
    Views:
    382
    David Simons
    Feb 23, 2005
Loading...

Share This Page