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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:32:49+00:00 2026-06-05T20:32:49+00:00

I am familiar with using preceding axes in XSLT for finding determining the number

  • 0

I am familiar with using preceding axes in XSLT for finding determining the number of preceding elements given the current context. However, I don’t see a way to do the same given a node that I’ve stored in a variable. For example:

<xsl:variable name="matchedBook" select="book[text()='The Hobbit']"/>
<xsl:variable name="precedingBookCount" select="count(???)"/>

Given the following XML, precedingBookCount should equal 3.

<available>
    <book>Lord of the Rings</book>
    <book>The Hunger Games</book>
</available>
<purchased>
    <book>Ready Player One</book>
    <book>The Hobbit</book>
    <book>Lord of the Flies</book>
</purchased>

I see in XPath 2.0 that there is a NodeComp operator << that I could use, but this does not appear to be present in XPath 1.0.

How can I go about doing this in XPath 1.0 then?

  • 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-05T20:32:50+00:00Added an answer on June 5, 2026 at 8:32 pm

    <xsl:variable name="precedingBookCount" select="count($matchedBook/preceding-sibling::book | $matchedBook/preceding::book)"/> should do.

    Actually it suffices to do <xsl:variable name="precedingBookCount" select="count($matchedBook/preceding::book)"/>.

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

Sidebar

Related Questions

I'm familiar with using xcode to profile memory allocations, however I'm currently working on
I am familiar with using PHP to perform mySQL queries. However, I have been
I am familiar with using the os.system to run from the command line. However,
I'm familiar with using a HttpModule to time requests but those don't really hook
I'm not particular familiar with using jQuery/Javascript so I don't know what the best
I've been given the challenging task to become familiar with using SQLXML data types
I am familiar with using \n in a textview to display on the second
I'm very familiar with using Enums in other languages, but I'm having some difficulty
I'm familiar with using NSLocalizedString() to localize strings, but the problem I have today
I am not familiar with using event handlers, and I was wondering if anyone

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.