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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:37:32+00:00 2026-06-13T13:37:32+00:00

Following up on my xslt question from yesterday, link found below. first last element

  • 0

Following up on my xslt question from yesterday, link found below.

first last element 2nd variation

I have to output the the first and last page number of each section into a table.

I’m puzzled on where to start. The XSLT 1.0 Solution and XSLT 2.0 Solution would be much appreciated. I would really appreciate any given help.

Regards JJ.

INPUT:

<root>
  <page number="1" section="Arsenal">Arsenal</page> 
  <page number="2" section="Arsenal">Arsenal</page> 
  <page number="3" section="Arsenal">Arsenal</page> 
  <page number="4" section="Arsenal">Arsenal</page> 
  <page number="5" section="Arsenal">Arsenal</page> 
  <page number="6" section="Arsenal">Arsenal</page> 
  <page number="7" section="Chelsea">Chelsea</page> 
  <page number="8" section="Chelsea">Chelsea</page> 
  <page number="9" section="Chelsea">Chelsea</page> 
  <page number="10" section="Chelsea">Chelsea</page> 
  <page number="11" section="Chelsea">Chelsea</page> 
  <page number="12" section="Chelsea">Chelsea</page> 
  <page number="13" section="ManUnited">ManUnited</page> 
  <page number="14" section="ManUnited">ManUnited</page> 
  <page number="15" section="ManUnited">ManUnited</page> 
  <page number="16" section="ManUnited">ManUnited</page> 
  <page number="17" section="ManUnited">ManUnited</page> 
  <page number="18" section="ManUnited">ManUnited</page> 
  <page number="19" section="ManCity">ManCity</page> 
  <page number="20" section="ManCity">ManCity</page> 
  <page number="21" section="ManCity">ManCity</page> 
  <page number="22" section="ManCity">ManCity</page> 
  <page number="23" section="ManCity">ManCity</page> 
  <page number="24" section="ManCity">ManCity</page> 
 </root>

OUTPUT:

<tr><td>1</td><td>Arsenal</td><td>6</td></tr>
<tr><td>7</td><td>Chelsea</td><td>12</td></tr>
<tr><td>13</td><td>ManU</td><td>18</td></tr>
<tr><td>19</td><td>Mancity</td><td>24</td></tr>
  • 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-13T13:37:33+00:00Added an answer on June 13, 2026 at 1:37 pm

    Use:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
    
      <xsl:key name="k" match="page" use="@section"/>
    
      <xsl:template match="/root">
        <table>
          <xsl:apply-templates select="page[generate-id() = generate-id(key('k', @section))]"/>
        </table>
      </xsl:template>
    
      <xsl:template match="page">
        <tr>
          <td>
            <xsl:value-of select="@number"/>
          </td>
          <td>
            <xsl:value-of select="."/>
          </td>
          <td>
            <xsl:value-of select="key('k', @section)[last()]/@number"/>
          </td>
        </tr>
      </xsl:template>
    </xsl:stylesheet>
    

    Output:

    <table>
      <tr>
        <td>1</td>
        <td>Arsenal</td>
        <td>6</td>
      </tr>
      <tr>
        <td>7</td>
        <td>Chelsea</td>
        <td>12</td>
      </tr>
      <tr>
        <td>13</td>
        <td>ManUnited</td>
        <td>18</td>
      </tr>
      <tr>
        <td>19</td>
        <td>ManCity</td>
        <td>24</td>
      </tr>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a following xslt: <span><xsl:text disable-output-escaping=yes><![CDATA[&nbsp;Some text]]></xsl:text></span> After transformation I get: <span>&amp;nbsp;Some text</span>
I have the following situation: There is a tool that gets an XSLT from
I have the following XSLT question: Suppose I have this XML <items> <item> <type>dog</type>
Question summary: What changes do I have to make to make the following xslt
I have the following xml <AAA> <BBB>Total</BBB> </AAA> Transforming it with the following xslt
Lets say I have a xslt stylesheet like the following: <?xml version=1.0 encoding=utf-8?> <xsl:stylesheet
I'm trying to figure out how XSLT process namespace prefixes and have following example:
I have the following: <Data xmlns:x=Namespace.com> <Node></Node> <Node2></Node2> <Node3></Node3> </Data> How using XSLT can
I am trying to remove the attribute xmlns=http://webdev2003.test.com from the following xml using xsl/xslt,
If I run the following XSLT code: <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform> <xsl:output method=text/> <xsl:key name=kValueByVal

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.