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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:46:25+00:00 2026-06-04T15:46:25+00:00

I have two variables in my xslt 1.0 template, each one holding a node-set

  • 0

I have two variables in my xslt 1.0 template, each one holding a node-set (selected with xpath). I want to determine if the node set in one variable is contained in the node set in the other. For example, suppose I have a chapter with nested sections. I want to see if $b is contained in $a:

<xsl:variable name="a" select="chapter//section" />
<xsl:variable name="b" select="chapter//section" />

I’ve tried to get an intersection of the nodesets to see if $a is the first common element shared by both $a and $b but this is not working:

<xsl:if test="$a/ancestor-or-self::*[count(.|$b) = count($b/ancestor::*)][1] = $a">

Adding some context. I’m creating a tabbed interface for a tree of html pages with this xslt, and the problem I’m trying to solve is to put class=”current” on the proper tab. By testing each section to see if it is a child of the tab section, it gets the class=”current” and so the tab will be styled to look as if it is on top.

  • 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-04T15:46:27+00:00Added an answer on June 4, 2026 at 3:46 pm

    To expand on Michael Kay’s good answer:

    When a node $n belongs to a node-set $ns?

    If a node belongs to a node-set then the union of the node with the node-set doesn’t result in a bigger node-set — so the number of the nodes in the union must not be greater (in fact must be equal to) than the number of nodes in the original nodeset.

    To express this with an XPath expression:

     count($n | $ns) = count($ns)
    

    Now, the same logic tells us that a nodeset $ns1 is a subset of a nodeset $ns2 exactly when the union of the two node-sets doesn’t contain more elements that the bigger node-set:

    count($ns1 | $ns2) = count($ns2)
    

    If we want to test if $ns1 is a true subset of $ns2:

        count($ns1 | $ns2) = count($ns2)
       and
        count($ns2) > count(ns1)  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two variables, one with text, and another with patterns. And I want
I have two XSLT variables as given below: <xsl:variable name=staticBaseUrl select='https://www.hello.com/htapi/PrintApp.asmx/getGames?contentId=id_sudoku&uniqueId=123456&pageformat=a4' /> <xsl:variable name=dynamicUrl
I have two variables, key and value , and I want to add them
I have two variables: char charTime[] = TIME; char buf[] = SOMETHINGELSE; I want
Let's say I have two char variables, and later on I want to concatenate
I have two variables in type of DateTime, and I want to sum them,
In java i have two variables String string; int integerValue; I want to convert
I want to save Json into two variables so that I can manipulate one,
I have two variables, 'a' and 'b' in my JavaScript, and i want to
I have two variables, one is called PaidThisMonth , and the other is called

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.