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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:29:27+00:00 2026-05-22T02:29:27+00:00

Within a foreach loop i want to use preceding-sibling:: <for-each..> <xsl:sort select=type/> <xsl:when test=preceding-sibling::data[1]/type

  • 0

Within a foreach loop i want to use preceding-sibling::

<for-each..>
    <xsl:sort select="type"/>
    <xsl:when test="preceding-sibling::data[1]/type != type

the problem is that “type” within the foreach is compared with a unsorted preceding-sibling
e.g.

data1/type = 1 
data2/type = 2
data3/type = 1

would compare in the second loop silbling=2 (original unsorted) and type=1 (since it is sorted)

is there a way around it?

UPDATE: my intention is the following

before             after
data/type2         type1 value1
data/type1         type1 value2 
data/type1         and speaking in HTML a spacer here (I compare type2:value to preceding-sibling value
data/type2         type2 value1
                   type2 value2

I have an unsorted list of addresses where the type is a town and I need a HTML Table sorted by town and to do some stuff depending on the values and other fields (that part is working, but since the comparison with preceding-sibling is not working in a sorted for-each, I got the problem

  • 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-22T02:29:28+00:00Added an answer on May 22, 2026 at 2:29 am

    Are you trying to group the data elements by type? Let us know what you’re trying to do and we can probably help out (as @Michael Kay said).

    One option (in XSLT 2.0 or with the node-set extension) is to sorted-copy the data elements to a new variable, then run your xsl:for-each on the nodeset in that new variable. Then the preceding-sibling relationship will reflect the sorted order.

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

Sidebar

Related Questions

Within a Foreach loop in SSIS is there a way that if a task
I have a foreach loop that forks within it. After the process forks, it
Within an n-tier app that makes use of a WCF service to interact with
I am trying to dynamically generate content using JSP. I have a <c:forEach> loop
I want to create a new object and assign some properties for each array
Within an application, I've got Secret Keys uses to calculate a hash for an
Within Ruby on Rails applications database.yml is a plain text file that stores database
Within c#, I need to be able to Connect to a remote system, specifying
Within SQL Server Integration Services (SSIS) there is the ability to setup a connection
Within our Active Directory domain, we have a MS SQL 2005 server, and a

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.