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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:35:03+00:00 2026-05-11T15:35:03+00:00

I need to use xsl/xpath (version 1.0) to do something special (for simplifying, say

  • 0

I need to use xsl/xpath (version 1.0) to do something special (for simplifying, say insert some dummy text) when the value of SupplierId changes. I need to handle 3 variations;

  1. Do something when on the first Order (the first occurence of SupplierId)
  2. Do somwthing when on OrderId O3 (SupplierId changed from S1 to S2)
  3. Do something when on the last Order (the last occurence of SupplierId)

.

<?xml version='1.0' encoding='utf-8'?> <Orders>     <Order>         <OrderId>O1</OrderId>         <SupplierId>S1</SupplierId>     </Order>     <Order>         <OrderId>O2</OrderId>         <SupplierId>S1</SupplierId>     </Order>     <Order>         <OrderId>O3</OrderId>         <SupplierId>S2</SupplierId>     </Order>     <Order>         <OrderId>O4</OrderId>         <SupplierId>S2</SupplierId>     </Order>     <Order>         <OrderId>O5</OrderId>         <SupplierId>S2</SupplierId>     </Order> </Orders> 

I’ve tried using preceding-sibling, following-sibling, etc, but haven’t found out of it yet. I’d appreciate any help on this newbie question.

Wally

  • 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-11T15:35:03+00:00Added an answer on May 11, 2026 at 3:35 pm

    This is one natural and easy solution:

    <xsl:stylesheet version='1.0'  xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>  <xsl:output method='text'/>      <xsl:template match='Order[1]'>       First OrderId = <xsl:text/>       <xsl:value-of select='OrderId'/>     </xsl:template>      <xsl:template match='Order[last()]'>        Last OrderId = <xsl:text/>       <xsl:value-of select='OrderId'/>     </xsl:template>      <xsl:template match=       'Order[not(position() = 1)]          [not(SupplierId               =               preceding-sibling::Order[1]/SupplierId               )         ]'>        Changes in Order OrderId = <xsl:text/>       <xsl:value-of select='OrderId'/>          SupplierId = <xsl:text/>          <xsl:value-of select='SupplierId'/>       Previous Order OrderId = <xsl:text/>       <xsl:value-of select=         'preceding-sibling::Order[1]/OrderId'/>                  SupplierId = <xsl:text/>          <xsl:value-of select=          'preceding-sibling::Order[1]/SupplierId'/>     </xsl:template>      <xsl:template match='text()'/> </xsl:stylesheet> 

    When this transformation is applied on the provided XML document:

    <Orders>     <Order>         <OrderId>O1</OrderId>         <SupplierId>S1</SupplierId>     </Order>     <Order>         <OrderId>O2</OrderId>         <SupplierId>S1</SupplierId>     </Order>     <Order>         <OrderId>O3</OrderId>         <SupplierId>S2</SupplierId>     </Order>     <Order>         <OrderId>O4</OrderId>         <SupplierId>S2</SupplierId>     </Order>     <Order>         <OrderId>O5</OrderId>         <SupplierId>S2</SupplierId>     </Order> </Orders> 

    the desired result is produced:

      First OrderId = O1    Changes in Order OrderId = O3      SupplierId = S2   Previous Order OrderId = O2              SupplierId = S1    Last OrderId = O5 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 85k
  • Answers 85k
  • 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
  • Editorial Team
    Editorial Team added an answer i'm not sure if i understand you, but to query… May 11, 2026 at 5:06 pm
  • Editorial Team
    Editorial Team added an answer BULK INSERT is run from the DBMS itself, reading files… May 11, 2026 at 5:06 pm
  • Editorial Team
    Editorial Team added an answer It doesn't matter. It may actually be WORSE since you… May 11, 2026 at 5:06 pm

Related Questions

I need to parse Visual Studio automatically generated XML documentation to create a report.
I have several xml files, the names of which are stored in another xml
I have the following xsl template that I'm using to group my xsl. The
I frequently use HTML output in applications, up to now I've used some simple
I am writing a basic word processing application and am trying to settle on

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.