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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:51:03+00:00 2026-05-27T22:51:03+00:00

Hello I’m trying to create grouping in the pdf file and I have to

  • 0

Hello I’m trying to create grouping in the pdf file
and I have to use grouping inside another grouping. f.e. group by date, then group by name, then by city…

xml:
<record>
<name>Palace1</name>
  <info>
     <date>2012-01-01</date> 
     <city>Random1</city> 
  </info>
  <info>
     <date>2012-01-01</date> 
     <city>SuperRandom</city> 
  </info>
  <info>
     <date>2012-01-02</date>
     <city>Random22</city>       
  </info>
   ...
</record>
<record>
<name>Palace2</name>
  <info>
    <date>2012-01-01</date>  
     <city>Random99</city>     
  </info>
  <info>
    <date>2012-01-02</date> 
     <city>Random1</city>     
  </info>
   ...
</record>
...

So lets say we need to group our records by date from 2012-01-01 to 2012-01-01 and the group them by name

Date 2012-01-01

Place1

Random1

SuperRandom

Palace2

Random99

Date 2012-01-02

Palace1

Random22

Palace2

Random1

SO I was using

<xsl:for-each-group select="dt:record" group-by="dt:info/dt:date">
<xsl:sort select="dt:date" order="ascending"/>

<fo:block font-weight="bold"> Date: <xsl:value-of select="format-dateTime(dt:date,'[Y0001].[M01].[D01]','en',(),'lt')"/></fo:block>

 <xsl:for-each select="current-group()"> //here im guessing we should put another for- each-group



 <xsl:for-each-group select="parent::dt:info/dt:record" group-by="dt:name">
 <fo:block>Place1 <xsl:value-of select="dt:name"><fo:block>
 <xsl:for-each select="current-group()">

 <fo:block> <xsl:value-of select="dt:info/dt:city"></fo:block>

 </xsl:for-each>
 </xsl:for-each-group>


</xsl:for-each>                 

</xsl:for-each-group>

but this doesn’t work… for some reason I get way more record names then I should

  • 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-27T22:51:04+00:00Added an answer on May 27, 2026 at 10:51 pm

    Here is how to do such groupings:

    <xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="/*">
         <xsl:for-each-group select="*/info" group-by="date">
            <xsl:sort select="date"/>
    Date: <xsl:value-of select="date"/>
    
              <xsl:for-each-group select="current-group()" group-by="../name">
                <xsl:value-of select="concat('&#xA;  ',../name)"/>
    
                <xsl:for-each-group select="current-group()" group-by="city">
                  <xsl:value-of select="concat('&#xA;    ', city)"/>
                </xsl:for-each-group>
              </xsl:for-each-group>
         </xsl:for-each-group>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on the well-formed XML document derived from the non-wellformed provided XML:

    <t>
        <record>
            <name>Palace1</name>
            <info>
                <date>2012-01-01</date>
                <city>Random1</city>
            </info>
            <info>
                <date>2012-01-01</date>
                <city>SuperRandom</city>
            </info>
            <info>
                <date>2012-01-02</date>
                <city>Random22</city>
            </info>    ... 
        </record>
        <record>
            <name>Palace2</name>
            <info>
                <date>2012-01-01</date>
                <city>Random99</city>
            </info>
            <info>
                <date>2012-01-02</date>
                <city>Random1</city>
            </info>    ... 
        </record>
    </t>
    

    the wanted, correctly-grouped result is produced:

    Date: 2012-01-01
      Palace1
        Random1
        SuperRandom
      Palace2
        Random99
    Date: 2012-01-02
      Palace1
        Random22
      Palace2
        Random1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I want to convert a PDF file to text file. I am converting
Hello I am trying to create a stacked barplot using the following code: test
Hello I'm trying to create text boxes dynamically using for loop and want to
Hello ! I need to create a report like the attachment shows with Jasper
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
hello all i am working on a project in which i have a webpage
Hello i'm doing a application in php, and i have a list of items
Hello everyone i am trying to format the input number range with php number_format
hello friends i am trying to get a list of user id and want
Hello Guys I am trying to figure out why i am gettings this error

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.