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 8426579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:34:03+00:00 2026-06-10T04:34:03+00:00

I am trying to find which price value is the smallest in xquery. I

  • 0

I am trying to find which price value is the smallest in xquery. I have two price values being passed in XML and I can’t seem to get past syntax errors when trying to compare the values.

Example XML:

<purchase>
  ....
  <articlePrice>$20.00</articlePrice>
  <issuePrice>$154.00</issuePrice>
  ....
</purchase>

I have the below to strip out the ‘$’

let $price := fn:substring-after($price, '$')
let $priceIssue := fn:substring-after($priceIssue, '$')

I’ve tried to use the built in fn:min() but gives “XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected QName_”.

fn:min(((xs:decimal($price)), (xs:decimal($priceIssue))))

Ive tried using both ‘gt’ and ‘>’ in an if statement but still get syntax error above.

The only way that I could get around the errors is casting them as strings but the comparison is wrong. Given the data above, as strings the logic returns ‘154.00’ as smaller than ‘20.00’ because the ‘1’ is smaller than the ‘2’.

My exact code:

let $price := if (xs:string($ecommerce/articlePrice)) then fn:substring-after(xs:string($ecommerce/articlePrice), '$') else ""

let $priceIssue := if (xs:string($ecommerce/issuePrice)) then fn:substring-after(xs:string($ecommerce/issuePrice), '$') else ""

let $priceDisplay := fn:min(xs:decimal($price), xs:decimal($priceIssue))

results as XDMP-ARGTYPE: (err:XPTY0004) fn:min(20.0, 154.0) — arg2 is not of type xs:string

  • 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-10T04:34:04+00:00Added an answer on June 10, 2026 at 4:34 am

    I’m not sure how your complete code looks like (it looks a little bit sketchy), but the following query should work:

    let $doc :=
      <purchase>
        <articlePrice>$20.00</articlePrice>
        <issuePrice>$154.00</issuePrice>
      </purchase>
    let $price := fn:substring-after($doc/articlePrice, '$')
    let $priceIssue := fn:substring-after($doc/issuePrice, '$')
    return fn:min((xs:decimal($price), xs:decimal($priceIssue)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been messing around with Leaks trying to find which function is not
Within an asp.net MVC app, I'm trying to find rooms which have a guest/client,
I'm trying to find an implementation of java.io.FileFilter which understands patterns like these: **/*.xml
I am trying to find the tuples which price is closest to a given
I have an XML feed (which I don't control) and I am trying to
I am trying to find out which edges from a graph are bidirectional. Each
I'm trying to find rows which are within ____meters from the given point. THis
I'm trying to find an algorithm which breaks the safe by typing the keys
I am trying to find some code which will help me to find out
I'm trying to find a MySQL query which will obtain the time that is

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.