Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8541741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:54:00+00:00 2026-06-11T11:54:00+00:00

I’m using the official documentation: http://docs.basex.org/wiki/Commands#String_Syntax , and I haven’t been able to locate

  • 0

I’m using the official documentation: http://docs.basex.org/wiki/Commands#String_Syntax, and I haven’t been able to locate a list of logical operators. I want to be able to query text contains 'A' or 'B'.

Along these same lines, I’m also trying to figure out how to limit the number of results returned, and I’m trying to find a good guide to creating relations tables in BaseX.

Here’s what I am working with…. I’ve figured out how to do ‘or’, but I haven’t figured out how to pass in variables for different targets, yet.

let $items := ('Creditcard', 'Money order')
for $item score $s in doc('xmark')//item
  [payment contains text "$items" using stemming using case sensitive]
order by $s descending
return <item ranking= '{ $s }'>{ $item/payment/text() }</item>

-Edit-

Now looking at this code, which is based off of the existing answer:

let $items := ('Creditcard', 'Money order')
for $item in descendant::*:$item | descendant-or-self::*[text() contains text "$item"] | .//item//payment[descendant-or-self::node()/@*:lang = "bnt"][descendant-or-self::node()/@*:lang = "afr"][descendant-or-self::node()/@*:lang = "eng"][descendant-or-self::node()/@*:lang = "chi"]
return <payment>{ .//item//payment/text() }</payment>
       <buyer_name>{ .//item//buyer/text() }</buyer_name>

-Edit-

Another attempt:

let $list := doc('xmark')
return for $p in $list/payments/item/payment-method[text() = 'Creditcard']
return $p//text()

Returns 0 results. Just trying to get ‘Creditcard’, the value of ‘payment method’, out of the text. Basically, I haven’t been able to find and consistent or successful examples.

-Edit-

The most recent attempt is very close; however, when I apply it to the database I’m actually trying to access, rather than the BaseX sample database, I get a special brand of error:

via http://basex.org/products/live-demo/

doc(‘test’) :=

<item>
<item_number>1171270</item_number>
<seller_info>
<seller_company_id>6356</seller_company_id>
<seller_rating>C31</seller_rating>
<seller_rating>T150 hr.</seller_rating>
</seller_info>
<product_info>
<unit>2022</unit>
<sinfo>55 cases</sinfo>
<sinfo>Yu-gi-oh trading card pack</sinfo>
<sinfo>.45kg per unit</sinfo>
<sinfo>24.7500kg shipment</sinfo>
</product_info>
<product_info>
<unit>9291</unit>
<sinfo>7 units</sinfo>
<sinfo>Naruto, Classic, action figure</sinfo>
<sinfo>1.8kg per unit</sinfo>
<sinfo>12.6kg shipment</sinfo>
</product_info>
</item>

0: write your own query… :=

let $doc := doc('test') 
for $v in $doc//item
where contains($v//seller_rating,'C31')
return $v//product_info/sinfo

Returns:

Error:
Stopped at line 3, column 39: [XPTY0004] Single item expected, (element seller_rating { ... }, element seller_rating { ... }) found.

I can’t say I didn’t expect to encounter a problem like this. Unfortunately, I didn’t format the XML document, and it’s all terribly formatted, like this, which is part of the reason I’m trying to access it (to restructure it). Next question coming up: “how do I target same-node-having values in XQuery“?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:54:01+00:00Added an answer on June 11, 2026 at 11:54 am

    imho this most closely resembles your question:

    let $results := 
    ( (: Prepare a sequence of results for each $keyword in $keywords :)
    let $keywords := ('Money order', 'Creditcard', 'Personal Check')
    for $keyword in $keywords
      (: see http://docs.basex.org/wiki/Full-Text#Scoring for information regarding
      scores :)
      for $item score $s in doc('xmark')//item[
        payment contains text {$keyword} all words using stemming using case sensitive
      ]
      order by $s descending
      return <item ranking= '{ $s }'>{ $item/payment/text() }</item>
    )
    (: now sort and group these results, grouping is done to eliminate duplicate payment
    methods that have been matched by two or more keywords :)
    for $result in $results
      group by $val := $result/text()
      order by $result[1]/@ranking descending
    return $result[1]
    

    Still, I think you might not be interested in the score but in the total number of distinct payment methods that contain your keywords, the following query will provide you with these data:

    let $keywords := ('Cash', 'Personal Check')
    for $keyword in $keywords 
    return <keyword name="{$keyword}">
    {
    for $result in //item/payment
      group by $payment-method := $result/text()
      order by count($result) descending
    return element {"item"} {
        attribute {"count"} {count($result)},
        $payment-method
      }[. contains text {$keyword} phrase]
    }</keyword>
    

    I hope this helps and answers your question, in case it does not feel free to ask for more help 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.