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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:57:51+00:00 2026-05-10T20:57:51+00:00

EDIT: I also have access to ESXLT functions. I have two node sets of

  • 0

EDIT: I also have access to ESXLT functions.

I have two node sets of string tokens. One set contains values like these:

/Geography/North America/California/San Francisco /Geography/Asia/Japan/Tokyo/Shinjuku 

The other set contains values like these:

/Geography/North America/ /Geography/Asia/Japan/ 

My goal is to find a ‘match’ between the two. A match is made when any string in set 1 begins with a string in set 2. For example, a match would be made between /Geography/North America/California/San Francisco and /Geography/North America/ because a string from set 1 begins with a string from set 2.

I can compare strings using wildcards by using a third-party extension. I can also use a regular expression all within an Xpath.

My problem is how do I structure the Xpath to select using a function between all nodes of both sets? XSL is also a viable option.

This XPATH:

count($set1[.=$set2]) 

Would yield the count of intersection between set1 and set2, but it’s a 1-to-1 comparison. Is it possible to use some other means of comparing the nodes?

EDIT: I did get this working, but I am cheating by using some of the other third-party extensions to get the same result. I am still interested in other methods to get this done.

  • 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. 2026-05-10T20:57:51+00:00Added an answer on May 10, 2026 at 8:57 pm

    This:

    <xsl:variable name='matches' select='$set1[starts-with(., $set2)]'/> 

    will set $matches to a node-set containing every node in $set1 whose text value starts with the text value of a node in $set2. That’s what you’re looking for, right?

    Edit:

    Well, I’m just wrong about this. Here’s why.

    starts-with expects its two arguments to both be strings. If they’re not, it will convert them to strings before evaluating the function.

    If you give it a node-set as one of its arguments, it uses the string value of the node-set, which is the text value of the first node in the set. So in the above, $set2 never gets searched; only the first node in the list ever gets examined, and so the predicate will only find nodes in $set1 that start with the value of the first node in $set2.

    I was misled because this pattern (which I’ve been using a lot in the last few days) does work:

    <xsl:variable name='hits' select='$set1[. = $set2]'/> 

    But that predicate is using an comparison between node-sets, not between text values.

    The ideal way to do this would be by nesting predicates. That is, ‘I want to find every node in $set1 for which there’s a node in $set2 whose value starts with…’ and here’s where XPath breaks down. Starts with what? What you’d like to write is something like:

    <xsl:variable name='matches' select='$set1[$set2[starts-with(?, .)]]'/> 

    only there’s no expression you can write for the ? that will return the node currently being tested by the outer predicate. (Unless I’m missing something blindingly obvious.)

    To get what you want, you have to test each node individually:

    <xsl:variable name='matches'>   <xsl:for-each select='$set1'>     <xsl:if test='$set2[starts-with(current(), .)]'>       <xsl:copy-of select='.'/>     </xsl:if>   </xsl:for-each> </xsl:variable> 

    That’s not a very satisfying solution because it evaluates to a result tree fragment, not a node-set. You’ll have to use an extension function (like msxsl:node-set) to convert the RTF to a node-set if you want to use the variable in an XPath expression.

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

Sidebar

Ask A Question

Stats

  • Questions 71k
  • Answers 71k
  • 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
  • added an answer As the others have stated, the knapsack (for packing cargo)… May 11, 2026 at 1:27 pm
  • added an answer What adapter are you using? I am assuming the SOAP… May 11, 2026 at 1:27 pm
  • added an answer If you have VFP 8 or greater:TRY USE MyTable IN… May 11, 2026 at 1:27 pm

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.