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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:49:14+00:00 2026-06-09T10:49:14+00:00

Pseudocode would be something like: let $myNode as node() := $node for $subpath in

  • 0

Pseudocode would be something like:

 let $myNode as node() := $node 
 for $subpath in tokenize($path,'/')
 $myNode := $myNode/*[name()=$subpath] (: Here is the invalid line :)

I know there is a operator for this in xQuery 3.0, I am asking for xQuery 1.0.

  • 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-09T10:49:16+00:00Added an answer on June 9, 2026 at 10:49 am

    There’s no XQuery 2.0, but what you want to do isn’t possible only with a FLWOR expression regardless of version. The set of current nodes would have to be updated between iterations, which isn’t how FLWOR expressions work.

    That said, what you want to do is easily possible with a recursive function in XQuery 1.0:

    declare function local:path(
      $context as node()*,
      $steps as xs:string*
    ) as node()* {
      if(empty($steps)) then $context
      else local:path(
        $context/*[name() = $steps[1]],
        $steps[position() gt 1]
      )
    };
    

    You can call it with local:path(document{ <x><y>foo</y><z/></x> }, tokenize("x/y", '/')).

    In XQuery 3.0 it’s even easier to do, without a new top-level function:

    fn:fold-left(
      function($context, $step) {
        $context/*[name() eq $step]
      },
      document{ <x><y>foo</y><z/></x> },
      tokenize('x/y', '/')
    )
    

    The function fn:fold-left(..) takes care of the recursion internally and you only have to specify how to modify the context set in each step.

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

Sidebar

Related Questions

I would like to do something like this (mix of sql with pseudocode): let's
Let's say I have some classes like: <div class=something style=display: none>Some text I would
How I'm suppose to implement a macro that would do something like this: //pseudocode
Using a LINQ query (with C#) how would I go about do something like
I have code that I'd like to run that looks something like this pseudocode:
Hi I would like to know how i can separate my MainWindow.xaml into different
Let's say I would like to manage a multidimensional array like (pseudo-code): Array $colors
The following code is an example of what I think would qualify as pseudocode,
This is for a red black tree. For the pseudocode p[z] <-- y, would
I need to be able to store something like this: where the green 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.