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

  • SEARCH
  • Home
  • 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 8558343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:47:24+00:00 2026-06-11T15:47:24+00:00

In my most recent attempt to access the XML database from my nightmares, I’ve

  • 0

In my most recent attempt to access the XML database from my nightmares, I’ve come very close. I actually succeeded, using the test database; 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, which is a valid complaint about the XML file:

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/product_info/unit,'9291')
return 
$v/seller_info/seller_company_id

Returns:

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

I can’t say I didn’t expect to encounter a problem like this. Unfortunately, I didn’t format the XML document–someone else did–, and it’s all terribly formatted, as you can see. Part of the reason I’m trying to access it: to restructure it.

Is there a way to run the query I’m trying to run on the document and get results without having this error spit at me? I’m also looking at the error of having Single item expected in my returns, when I try to target sinfo as a return value, right? Is there any way to get, for example, all of the sinfo's? Or how about only the second sinfo for each product_info without having this nasty error spit back at me?

  • 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-11T15:47:25+00:00Added an answer on June 11, 2026 at 3:47 pm

    Your path $v/product_info/unit in the where clause will yield more than one item per call, while the contains() function only accepts single items as arguments. The following query will give you the expected results:

    let $doc := doc('test') 
    for $v in $doc//item
    where some $i in $v/product_info/unit satisfies contains($i,'9291')
    return $v/seller_info/seller_company_id
    

    Another solution (in the predicate [...], each item will be bound to the context item . and processed one by one):

    let $doc := doc('test') 
    for $v in $doc//item
    where $v/product_info/unit[contains(.,'9291')]
    return $v/seller_info/seller_company_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the most recent version of GHC distributed with Ubuntu 11.10 (7.0.3).
I want to grab the most recent entry from a table. If I was
The code below returns the 10 most recent entries to a MySQL database. That's
Traceback (most recent call last): File manage.py, line 10, in <module> execute_from_command_line(sys.argv) File D:\PythonPack\lib\site-packages\django\core\management\__init__.py,
Traceback (most recent call last): File <pyshell#9>, line 1, in <module> ClosestCommonAncestor(A,C,x) File C:\x\x.py,
I've downloaded the most recent Windows.Phone.Controls.Toolkit and in the app.xaml.cs changed RootFrame = new
After Jeph most recent post: http://www.codinghorror.com/blog/archives/001310.html , I thought to myself it would be
I downloaded the most recent version of Android for Linux (android-sdk_r05-linux_86.tgz). I was trying
I am trying implement a most recent widget into my tumblr post. So far,
I am trying to find the most recent record based on a date field.

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.