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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:26:05+00:00 2026-05-20T15:26:05+00:00

(XSLT 1.0.) Given a variable called Rows which contains the following (example): Input <AllResults>

  • 0

(XSLT 1.0.)
Given a variable called Rows which contains the following (example):

Input

<AllResults>
    <Result>
      <subject>can be filtered by filter 1</subject>
      <type>can be filtered by filter 2</type>
      <date>can be filtered by filter 3</date>
    </Result>
    <Result> ...
    </Result>
</AllResults>

I have 3 filter variables. For each filter, I’d like to apply the filter to the input shown above if the filter variable is not empty. I’d like to store the filtered result, the items that match the filters, into a new variable. I tried the following, but I got an error message about it (filterResult) being a “result tree instead of a node-set”. The Rows variable is a node-set, as I have determined by using a debugger.

Part of the XSL

<xsl:variable name="filterResult">
    <xsl:choose>
        <xsl:when test="$filter1 != '' and $filter2 != '' and $filter3 != ''">
            <xsl:copy-of select="$Rows[date=$filter1 and type=$filter2 and subject=$filter3]" />
        </xsl:when>
        <xsl:when test="$filter1 != '' and $filter2 != ''">
            <xsl:copy-of select="$Rows[date=$filter1 and type=$filter2]" />
        </xsl:when>
        <xsl:when test="$filter1 != '' and $filter3 != ''">
            <xsl:copy-of select="$Rows[date=$filter1 and subject=$filter3]" />
        </xsl:when>
        <xsl:when test="$filter3 != '' and $filter2 != ''">
            <xsl:copy-of select="$Rows[type=$filter2 and subject=$filter3]" />
        </xsl:when>
        <xsl:when test="$filter1 != ''">
            <xsl:copy-of select="$Rows[date=$filter1]" />
        </xsl:when>
        <xsl:when test="$filter3 != ''">
            <xsl:copy-of select="$Rows[subject=$filter3]" />
        </xsl:when>
        <xsl:when test="$filter2 != ''">
            <xsl:copy-of select="$Rows[type=$filter2]" />
        </xsl:when>
        <xsl:otherwise> 
            <xsl:copy-of select="$Rows" />
        </xsl:otherwise>
    </xsl:choose>
</xsl:variable>

I realize that copy-of produces a result tree and not a node-set, but I am not sure HOW to produce a node set given my 3 filters requirement that I described above.

Additional Info

I do know that I could do something like <xsl:variable name="me" select="/set/node"/> which would create a variable containing a node set but I don’t see how that helps me, since I have a lot of possible conditions (given the three filters).

  • 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-20T15:26:06+00:00Added an answer on May 20, 2026 at 3:26 pm

    It looks like $Rows variable is an instance of type Result Tree Fragment.

    You can’t perform any operation (like the one provided by [] filter expression) on RTF other than string operations: from https://www.w3.org/TR/xslt-10/#section-Result-Tree-Fragments

    An operation is permitted on a result
    tree fragment only if that operation
    would be permitted on a string (the
    operation on the string may involve
    first converting the string to a
    number or boolean). In particular, it
    is not permitted to use the /, //,
    and [] operators on result tree
    fragments.

    Besides that, all the showed code could be simplified if $Rows is an instance of node set data type like this:

    <xsl:variable name="filterResult" 
                  select="$Rows[(date=$filter1 or $filter1='')
                                   and 
                                (type=$filter2 or $filter2='')
                                   and 
                                (subject=$filter3 or $filter3='')]"/>
    

    There are XSLT processor (mostly every one) that provide implementations of node-set() extension function for RTF to node set conversion.

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

Sidebar

Related Questions

My understanding has been that, despite the fact that XSLT's node-sets are called sets,
For a given xml, I need to generate a html table to represent the
I have been given an XML document in a rather strange format and I
Greetings, given a list of numbers, is it possible to find a value closest
Given this XML: <root> <row> <time>08:00</time> <sales>800</sales> </row> <row> <time>08:15</time> <sales>815</sales> </row> <row> <time>08:30</time>
Is there a way to retrieve the results of an SQL query in XML?
Search as I may I have not found a solution to my problem here
The transformation I am writing must compose a comma separated string value from a
I have an Umbraco based blog and I want to display the top 10
Note that I posed a very similar question earlier but the requirements have since

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.