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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:57:47+00:00 2026-06-10T20:57:47+00:00

I think I just open a new question and also could help who are

  • 0

I think I just open a new question and also could help who are the same looking for solution. I want to add a class from every 3rd item.

here is my xml code

<groups>
<elements>
<name>//1</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2012-03-04</PostDate>
<trackno></trackno>
</elements>

<elements>
<name>//2</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2011-03-04</PostDate>
<trackno></trackno>
</elements>

<elements>
<name>//3</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2012-07-04</PostDate>
<trackno></trackno>
</elements>


<elements>
<name>//4</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2009-01-04</PostDate>
<trackno></trackno>
</elements>



<elements>
<name>//5</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2009-02-04</PostDate>
<trackno></trackno>
</elements>


<elements>
<name>//6</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2008-06-04</PostDate>
<trackno></trackno>
</elements>

<elements>
<name>//7</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2012-01-04</PostDate>
<trackno></trackno>
</elements>


<elements>
<name>//8</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2012-05-14</PostDate>
<trackno></trackno>
</elements>



<elements>
<name>//9</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2012-05-28</PostDate>
<trackno></trackno>
</elements>



<elements>
<name>//10</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2011-02-25</PostDate>
<trackno></trackno>
</elements>



<elements>
<name>//11</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2011-12-20</PostDate>
<trackno></trackno>
</elements>



<elements>
<name>//12</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2011-11-07</PostDate>
<trackno></trackno>
</elements>




<elements>
<name>//13</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2011-07-09</PostDate>
<trackno></trackno>
</elements>


<elements>
<name>//14</name>
<BOD></BOD>
<description/>
<URL></URL>
<Hobbbies>
<Sport></Sport>
<Music></Music>
</Hobbbies>
<Height></Height>
<PostDate>2005-10-19</PostDate>
<trackno></trackno>
</elements>
</groups>

and this is my XSLT

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">



    <xsl:template match="/">

      <html>
      <body>
        <h2>Try to display only 9 or 12</h2>
          <xsl:for-each select="/groups/elements">
            <xsl:sort select="PostDate" order="descending"/>
            <xsl:if test="not(position() > 10)">
            <b><xsl:value-of select="PostDate" /></b> - 
            <font color='red'><xsl:value-of select="name" /></font>
           <p></p>
           </xsl:if>
          </xsl:for-each>

      </body>
      </html>
    </xsl:template>

    </xsl:stylesheet> 

just want an easy way to insert the class, many thanks

I want to get

        <div clas="item">

        2012-07-04 - //3 

        2012-05-28 - //9 

       <div class="third"> 2012-05-14 - //8 </div>

        2012-03-04 - //1 

        2012-01-04 - //7 

        <div class="third"> 2011-12-20 - //11 </div>

        2011-11-07 - //12 

        2011-07-09 - //13 

        <div class="third">2011-03-04 - //2  </div>

        2011-02-25 - //10 
      </div>
  • 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-10T20:57:48+00:00Added an answer on June 10, 2026 at 8:57 pm

    This transformation:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes"/>
    
        <xsl:template match="/">
          <div class="item">
              <xsl:for-each select="/groups/elements">
                <xsl:sort select="PostDate" order="descending"/>
                <xsl:if test="not(position() > 10)">
                    <xsl:choose>
                      <xsl:when test="position() mod 3 = 0">
                      <xsl:text>&#xA;</xsl:text>
                        <div class="third">
                          <xsl:apply-templates select="."/>
                        </div>
                      </xsl:when>
                      <xsl:otherwise>
                      <xsl:text>&#xA;</xsl:text>
                        <xsl:apply-templates select="."/>
                      </xsl:otherwise>
                    </xsl:choose>
              </xsl:if>
             </xsl:for-each>
          </div>
        </xsl:template>
    
        <xsl:template match="elements">
          <xsl:value-of select="PostDate" />
          <xsl:text> - </xsl:text>
          <xsl:value-of select="name" />
        </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <groups>
        <elements>
            <name>//1</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2012-03-04</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//2</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2011-03-04</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//3</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2012-07-04</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//4</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2009-01-04</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//5</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2009-02-04</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//6</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2008-06-04</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//7</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2012-01-04</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//8</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2012-05-14</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//9</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2012-05-28</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//10</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2011-02-25</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//11</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2011-12-20</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//12</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2011-11-07</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//13</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2011-07-09</PostDate>
            <trackno></trackno>
        </elements>
        <elements>
            <name>//14</name>
            <BOD></BOD>
            <description/>
            <URL></URL>
            <Hobbbies>
                <Sport></Sport>
                <Music></Music>
            </Hobbbies>
            <Height></Height>
            <PostDate>2005-10-19</PostDate>
            <trackno></trackno>
        </elements>
    </groups>
    

    produces the wanted, correct result:

    <div class="item">
    2012-07-04 - //3
    2012-05-28 - //9
    <div class="third">2012-05-14 - //8</div>
    2012-03-04 - //1
    2012-01-04 - //7
    <div class="third">2011-12-20 - //11</div>
    2011-11-07 - //12
    2011-07-09 - //13
    <div class="third">2011-03-04 - //2</div>
    2011-02-25 - //10</div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Rookie question, I think. I'm just trying to replicate this: http://rpubs.com/gallery/googleVis Open a new
just think that when I opened my file then when I want to write
I think this is just a Best Practices question, but I was wondering if
[see later answer for more] I think this is just a simple rails question,
Okay, I think I'm just making a stupid mistake here, but I want to
Quick question, I am working on an APNS enabled app and I just want
I'm not very used to programming with flags, but I think I just found
I think I'm just missing something simple here but here is what I am
I have read much information about agile and waterfall and I just cannot think
Just when I think I'm getting an understanding of the syntax of Javascript, I

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.