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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:30:56+00:00 2026-06-03T15:30:56+00:00

So ive been given an assignment in my university of fixing XPath and get

  • 0

So ive been given an assignment in my university of “fixing” XPath and get it to return the nodes in the correct order.

Ive been trying to find a way around writing a very long code and breaking each expression into little peaces and putting it back together again.

Ive thought of a few ideas but i need help making them happen 🙂

  1. Find the method in the XPath jar that sorts the nodes and delete it – problem is i dont know if its possible to see the XPath jar code , and didnt find it online.- if you can point me to it , that would be great !

  2. Ive found this option which looks like it should do the trick
    http://cafeconleche.org/books/xmljava/chapters/ch16s06.html
    but it demands dom implementation of XPath 3.0
    and i cant find that dom anywhere – any idea if there is such thing ?

  3. If you have any other idea i would love to hear !

For example : for this xml

 <library> 
 <book name="book1"> 
  hello 
 </book> 
 <book name="book2"> 
  world 
 </book>
 <book name="book3">
  !!! 
 </book>
 </library>

and this expression : /library/book[3]/preceding-sibling::book
Im getting

book1
book2

insted of :

book2
book1

I can use anything as long as i do it in a java program

Thank you for all your help 🙂

  • 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-03T15:30:59+00:00Added an answer on June 3, 2026 at 3:30 pm

    In XPath 1.0, there are no node sequences, only node sets. The XPath 1.0 specification doesn’t define the order of nodes in a node set. Many APIs don’t define it either, but invariably they return the nodes in the node-set in document order – not because XPath requires it, but because XSLT requires it, and XSLT has set the expectations for how XPath engines should behave.

    If you want node sequences with control over the ordering, you will have to move to XPath 2.0 (or XQuery 1.0, which is a superset of XPath 2.0). In XPath 2.0, the following expression returns what you want:

    reverse(/library/book[3]/preceding-sibling::book)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive been trying to get the parent of this WebBrowser control. Somehow i can't
I've been doing a lot of research trying to find the best way to
So I've been given an assignment in my Mobile apps class: make a color
I've been given the assignment to port some library routines to C# so our
I've been given an assignment to create a program that might involve a quiz
I have been trying for 2 days now to get a UIPickerView to show
I am a student studying IT in an University. I've been giving an assignment
Ive been given the task of localising a facebook app that is built in
Ive been given a class file from another group of SFDC developers that work
I've been given an assignment to confiure apache v2.1 (on any platform) as a

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.