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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:24:25+00:00 2026-05-13T07:24:25+00:00

Problem: I am having trouble generating an xpath expression that selects a node in

  • 0

Problem:

I am having trouble generating an xpath expression that selects a node in a different section of the XML document by position. I am using xsl:variable to create the expression, but when I use a xsl:for-each with the value of the xsl:variable as my select statement I get an error.

<xsl:variable name="input_params_query">
  <xsl:text disable-output-escaping="yes">/example/inputs/dataset[</xsl:text>
  <xsl:number value="position()" format="1" />
  <xsl:text disable-output-escaping="yes">]/parameter</xsl:text>
</xsl:variable>

<xsl:for-each select="$input_params_query">
  <input rdf:resource="#{@name}"/>
</xsl:for-each>

Results in the error:

The 'select' expression does not evaluate to a node set.

When I print out the value of the xsl:variable I am using I get:

/example/inputs/dataset[1]/parameter

which is a valid and correct Xpath expression for the nodes I am trying to select in the for-each call.

Is my usage of the xsl:variable as xsl:for-each select attribute incorrect?

Background and Full Explanation:

I am using XSLT to generate a RDF/XML representation of information available in the following XML structure.

In this case what the XML really means is that a process was run twice; the first time generating output file “a” and the second time generation output file “b”. The parameters “p1” and “p2” were inputs for the execution that generated file “a” and the parameter “p3” was an input to the execution that generated file “b”.

For each output of ‘process’ I am generating a RDF individual and defining the inputs and outputs for that process execution. Basically, I want to define all values from /example/inputs/dataset[n]/parameters as inputs to the process which generates the output /example/process/outputs/file[n].

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 version="1.0">
 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
 <xsl:template match="//process">
  <xsl:for-each select="outputs/*">

  <!-- declare rdf resource of type Process, define Process outputs -->
  <!-- ... this I already have working so I have withheld for brevity -->

  <!-- define input parameters -->

   <xsl:variable name="input_params_query">
    <xsl:text disable-output-escaping="yes">/example/inputs/dataset[</xsl:text>
    <xsl:number value="position()" format="1" />
    <xsl:text disable-output-escaping="yes">]/parameter</xsl:text>
   </xsl:variable>

   <xsl:for-each select="$input_params_query">
    <input rdf:resource="#{@name}"/>
   </xsl:for-each>

  </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>
  • 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-13T07:24:25+00:00Added an answer on May 13, 2026 at 7:24 am

    “Is my usage of the xsl:variable as xsl:for-each select attribute incorrect?”

    yes. the value specified in select attributes must be a valide node-set expression, that is, it must be an Xpath expression that evaluates to a (possibly empty) node set.

    The variable you defined is of a string type. the string happens to be a valid Xpath expression, but it is still ‘just’ a string.

    I think you can achieve your intended result by writing it like this:

    <xsl:template match="//process">
      <xsl:for-each select="outputs/*">
        <!-- declare rdf resource of type Process, define Process outputs -->
        <!-- ... this I already have working so I have withheld for brevity -->
    
        <!-- define input parameters -->
        <xsl:variable name="position" select="position()"/>
    
        <xsl:for-each select="/example/inputs/dataset[$position]">
          <input rdf:resource="#{@name}"/>
        </xsl:for-each>
      </xsl:for-each>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.