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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:54:25+00:00 2026-05-21T06:54:25+00:00

I need to evaluate an xpath expression without knowing its return value in advance.

  • 0

I need to evaluate an xpath expression without knowing its return value in advance. I don’t care about the distinction between a Node and a NodeSet, but I do care about NodeSet versus a String or a number.

For example, an xpath with a sum or concat function can return a number or a string (or boolean). An xpath with a regular xml path returns a nodeset, potentially with only one node.

How can I call the XPathExpression.evaluate() function (javadoc here)? I don’t know what QName to pass to it as the second parameter. The class XPathConstants contains the closed list of constants allowed (these are Node, NodeSet, String, Number and Boolean).

Is it possible to specify an “all” or “don’t care” value and then inspect the returned object for its type?

I thought maybe to use the overloaded version of this function, which always return a String. However, I don’t see how this will work if the xpath expression is meant to return a node set.

  • 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-21T06:54:26+00:00Added an answer on May 21, 2026 at 6:54 am

    Following Alejandro’s hint about DOM Level 3 XPath, I found out that Xalan 2.7.1 already supports it.

    I used the class XPathEvaluatorImpl of Xalan. It works great, and I can specify ANY-TYPE as the return value. The only downside is that this functionality is not exposed in the standard javax api, at least not in Java 6.

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

Sidebar

Related Questions

I need to evaluate a mathmatical expression that is presented to me as a
I have a need to evaluate user-defined logical expressions of arbitrary complexity on some
I'm building a .NET 3.5 application and have the need to evaluate JS code
For learning and demonstrating, I need a macro which prints its parameter and evaluates
Need to an expression that returns only things with an I followed by either
need ask you about some help. I have web app running in Net 2.0.
I'm trying to evaluate an XPath varable I'm building dynamically based on the position
In several places I have to retrieve some value from a dict, but need
I need some help with my xpath query. I can get this code to
I need to evaluate user-entered arithmetic expressions like 2 * (3 + 4) in

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.