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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:42:50+00:00 2026-05-19T17:42:50+00:00

I am using xquery over BaseX XML Database. Say, I have the following documents

  • 0

I am using xquery over BaseX XML Database. Say, I have the following documents stored in my database: doc1, doc2, doc3.

What Xquery do I use to check the existence of a given document. I tried the following:

declare variable $doc_name as xs:string external;

return boolean($doc_name)

I expected it to work as follows:
if doc_name = doc1 return true
if doc_name = nodoc return false

But, I see an exception:

java.io.IOException: Stopped at line 3, column 7:
[XPST0003] Unexpected end of query: ‘boolean(“doc1”)’.

I also tried return

  • return fn:exists($doc_name) and

  • return fn:doc-available(doc_uri)

These do not work either. I see the same end of query exception. What is the correct way of checking a document’s existence?

Thanks,
Sony

  • 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-05-19T17:42:51+00:00Added an answer on May 19, 2026 at 5:42 pm

    Use the standard XPath/XQuery function doc-available() .

    From the Spec:

    fn:doc-available($uri as xs:string?) as xs:boolean

    Summary: The function returns true if and only if the function call fn:doc($uri) would return a document node.

    If $uri is an empty sequence, this function returns false.

    If a call on fn:doc($uri) would return a document node, this function returns true.

    If $uri is not a valid URI according to the rules applied by the implementation of fn:doc, an error is raised [err:FODC0005].

    Otherwise, this function returns false.

    If this function returns true, then calling fn:doc($uri) within the same ·execution scope· must return a document node. However, if non-stable processing has been selected for the fn:doc function, this guarantee is lost.

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

Sidebar

Related Questions

How do I select the inner text of an XML node using XQuery? Microsoft
I am trying to match against ids stored as list element using XQuery. For
I am reading XML files of Office 2007 document using xquery. In these files
Following on from one of the answers in this thread; Using XQuery in Linq
I get one array, when i am parsing a xml file using xpath xquery.The
Let say I have the following desire, to simplify the IConvertible's to allow me
Say I have a Java String which has xml data like so: String content
I try to return a set of result from an xml document using xquery
I have a data stored in a xml column and need a comma-separated list
Using online interfaces to a version control system is a nice way to have

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.