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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:41:49+00:00 2026-05-27T23:41:49+00:00

Source XML: <Root> <Data> <Code>A</Code> <Value>10</Value> </Data> <Data> <Code>A</Code> <Value>10</Value> </Data> <Data> <Code>B</Code> <Value>10</Value>

  • 0

Source XML:

<Root>
    <Data>
        <Code>A</Code>
        <Value>10</Value>
    </Data>
    <Data>
        <Code>A</Code>
        <Value>10</Value>
    </Data>
    <Data>
        <Code>B</Code>
        <Value>10</Value>
    </Data>
    <Data>
        <Code>A</Code>
        <Value>2</Value>
    </Data>
    <Data>
        <Code>C</Code>
        <Value>10</Value>
    </Data>
    <Data>
        <Code>A</Code>
        <Value>5</Value>
    </Data>
    <Data>
        <Code>B</Code>
        <Value>4</Value>
    </Data>
    <Data>
        <Code>A</Code>
        <Value>10</Value>
    </Data>
    <Data>
        <Code>C</Code>
        <Value>10</Value>
    </Data>
    <Data>
        <Code>B</Code>
        <Value>10</Value>
    </Data>
    <Data>
        <Code>A</Code>
        <Value>10</Value>
    </Data>
    <Data>
        <Code>C</Code>
        <Value>5</Value>
    </Data>
....
</Root>

XSL-FO Code:

My code(XSL-FO) contains 3 columns where each column contains the content of ‘A’, ‘B’, ‘C’

<fo:table-body>
    <xfd:table-row-repeat xpath="Root/Data" font-family="Arial Narrow" font-size="10pt" padding-after="0.55cm">
        <xsl:if test="Code='A'">
        <fo:table-cell>
        <fo:block height="12pt">Value
        </fo:block>
        </fo:table-cell>
        <fo:table-cell>
        <fo:block height="12pt" border="0.1pt solid black" text-align="center">
            <xsl:value-of select="Value" /> 
        </fo:block>
        </fo:table-cell>
        <fo:table-cell>
        <fo:block height="12pt">Points</fo:block> 
        </fo:table-cell>
        </xsl:if>
    </xfd:table-row-repeat>
</fo:table-body>

Same code for each columns to display values of ‘B’ & ‘C’
In Table-footer i’ve to get these subtotal of ‘A’,’B’, ‘C’

<fo:table-body>
    <xfd:table-row-repeat xpath="Root/Data" font-family="Arial Narrow" font-size="10pt" padding-after="0.55cm">
        <xsl:if test="Code='A'">
        <fo:table-cell>
        <fo:block height="12pt">SubTotal
        </fo:block>
        </fo:table-cell>
        <fo:table-cell>
        <fo:block height="12pt" border="0.1pt solid black" text-align="center">
            <--Here Sum of first 15 A's. if the A's or B's or C's exceed by 15, then the table flows to 2nd Page. In that case, 1st Page table-footer shows individual subtotals of first 15 A's, 15 B's and C's. In 2nd Page, the subtotals should contain Subtotal of first 15 A's+ Succeeding A's, in the same way B's and C's --> 
        </fo:block>
        </fo:table-cell>
        <fo:table-cell>
        <fo:block height="12pt">Points</fo:block> 
        </fo:table-cell>
        </xsl:if>
    </xfd:table-row-repeat>
</fo:table-body>

Here the XSL-FO code is shown for only one column(For Root/Data/Code=’A’), the other 2 columns(‘B’ & ‘C’) consists of same code.

Conditions in Detail:

Condition 1): when Root/Data/Code = 'A' or 'B' or 'C'
   i need individual totals of 'A', 'B' and 'C' in Table-Footer individual Column.

Condition 2): inturn if individual count(Root/Data/Code) of 'A', 'B' & 'C' crosses 15.          Then Page flows to 2nd Page then Table-Footer in 2nd Page needs to contains subtotal of first 15 A's + the sum of succeeding A's in the same way for B's And C's

i.e., if 20 A’s, 10 B’s and 25 C’s are present in Source XML.

In 1st Page, Table-Footer

SubtotalI(Value of 15 A's)=
SubtotalII(Value 10 B's)=   
SubtotalIII(Value 15 C's)=

In 2nd Page, Table-Footer

SubtotalI(15 A's+ next 5 A's)=   
SubtotalII(Value 10 B's)= <!--No Change as count of B's is less than 15 -->
SubtotalIII(15 C's + next 10 C's)=

I’m trying this logic using xsl:key by grouping through Code tag for evaluating sum of ‘A’, ‘B’ and ‘C’. As i’m new to XSLT i’m finding it too difficult to solve this logic using xsl:key. Can anyone help in solving this logic?

Thanks in Advance

  • 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-27T23:41:50+00:00Added an answer on May 27, 2026 at 11:41 pm

    There are several difficulties with what you try to achieve. Calculating subtotals at a given point is easiest actually. You just need the preceding axis and a sum to calculate it:

    sum(preceding::Value[../Code = 'A'])
    

    To include the current value as well, use the union operator like this:

    sum(Value[../Code = 'A'] | preceding::Value[../Code = 'A'])
    

    A bigger difficulty is to show a different table ‘footer’ on each page. Headers and footers are repeated on pages automatically, but the contents is the same across all pages which the table spans. The only solution I see is to break the table yourself, adding a different table footer each time.

    By far the easiest way is to just take a fixed number of Data elements at a time, and displaying those in a separate table. You can loop through A, B and C types in one for-each, giving each value a separate row. That way the table always has the same number of rows. You can experiment with the number you can include to determine how many fit on one page.

    The following code returns a table with the first 10 Data values. A, B and C values are positioned straight under each other, but you could position them left, middle, and right respectively if you like. At the bottom of the table three rows are added with subtotals for A, B and C.

    <?xml version="1.0" encoding="utf-8"?> 
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:fo="http://www.w3.org/1999/XSL/Format">
    
        <xsl:template match="/">
            <fo:root>
                <fo:layout-master-set>
                    <fo:simple-page-master master-name="global">
                        <fo:region-body/>
                    </fo:simple-page-master>
                </fo:layout-master-set>
    
                <fo:page-sequence master-reference="global">
                    <fo:flow flow-name="xsl-region-body">
    
                        <fo:block>
                            <fo:table table-layout="fixed" width="150mm" border-style="solid">
                                <fo:table-column column-width="50mm"/>
                                <fo:table-column column-width="50mm"/>
                                <fo:table-column column-width="50mm"/>
    
                                <fo:table-body font-size="7pt">
                                    <xsl:for-each select="/Root/Data[10 >= position()]">
                                        <fo:table-row border-style="solid">
                                            <fo:table-cell> 
                                                <fo:block height="12pt">
                                                    <xsl:value-of select="Code" />
                                                </fo:block> 
                                            </fo:table-cell> 
                                            <fo:table-cell>
                                                <fo:block height="12pt" border="0.1pt solid black" text-align="center"> 
                                                    <xsl:value-of select="Value" />  
                                                </fo:block> 
                                            </fo:table-cell> 
                                            <fo:table-cell> 
                                                <fo:block height="12pt">Points</fo:block>  
                                            </fo:table-cell> 
                                        </fo:table-row>
    
                                        <xsl:if test="position() = last()">
                                            <fo:table-row border-style="solid">
                                                <fo:table-cell> 
                                                    <fo:block height="12pt">Subtotal A</fo:block> 
                                                </fo:table-cell> 
                                                <fo:table-cell>
                                                    <fo:block height="12pt" border="0.1pt solid black" text-align="center"> 
                                                        <xsl:value-of select="sum(preceding::Value[../Code = 'A'] | Value[../Code = 'A'])" />  
                                                    </fo:block> 
                                                </fo:table-cell> 
                                                <fo:table-cell> 
                                                    <fo:block height="12pt">Points</fo:block>  
                                                </fo:table-cell> 
                                            </fo:table-row>
                                            <fo:table-row border-style="solid">
                                                <fo:table-cell> 
                                                    <fo:block height="12pt">Subtotal B</fo:block> 
                                                </fo:table-cell> 
                                                <fo:table-cell>
                                                    <fo:block height="12pt" border="0.1pt solid black" text-align="center"> 
                                                        <xsl:value-of select="sum(preceding::Value[../Code = 'B'] | Value[../Code = 'B'])" />  
                                                    </fo:block> 
                                                </fo:table-cell> 
                                                <fo:table-cell> 
                                                    <fo:block height="12pt">Points</fo:block>  
                                                </fo:table-cell> 
                                            </fo:table-row>
                                            <fo:table-row border-style="solid">
                                                <fo:table-cell> 
                                                    <fo:block height="12pt">Subtotal C</fo:block> 
                                                </fo:table-cell> 
                                                <fo:table-cell>
                                                    <fo:block height="12pt" border="0.1pt solid black" text-align="center"> 
                                                        <xsl:value-of select="sum(preceding::Value[../Code = 'C'] | Value[../Code = 'C'])" />  
                                                    </fo:block> 
                                                </fo:table-cell> 
                                                <fo:table-cell> 
                                                    <fo:block height="12pt">Points</fo:block>  
                                                </fo:table-cell> 
                                            </fo:table-row>
                                        </xsl:if>
                                    </xsl:for-each>
                                </fo:table-body>
                            </fo:table>
                        </fo:block>
    
                    </fo:flow>
                </fo:page-sequence>
    
            </fo:root>
        </xsl:template>
    
    </xsl:stylesheet>
    

    You still need something to determine how many tables of n Data items you would need, and then do some recursive calls to output all of them. Hope this is sufficient for the moment to get you going again!

    PS: I noticed you are using xfd prefix. That looks like you are working with the XF Designer from Ecrion. I am not very familiar with it. The above code is a plain XSLT 1.0 solution. Not sure it works in XF Designer, please let me know..

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

Sidebar

Related Questions

I'm using the XML data source feature in Reporting Services 2005 but having some
From this XML source : <?xml version=1.0 encoding=utf-8 ?> <ROOT> <STRUCT> <COL order=1 nodeName=FOO/BAR
I need some help about xsl. I have a date attribute in source xml
What kind of open-source libraries are available to convert XML into a java value
I have this source XML: <?xml version=1.0?> <root> <item1> <name>test</name> <price>160</price> <stock>4</stock> <country>Belgium</country> </item1>
Have the source XML: <root> <element Key=card1_id>123</element> <element Key=card1_balance>500</element> <element Key=card2_id>456</element> <element Key=card2_balance>800</element> .............................................
I have a source XML file that is used to create C# files that
Have a source xml document that uses namespace containing prefixes and a default namespace.
I want to transform an XML document. The source XML looks like this: <svc:ElementList>
I would like to process a frame element in my source xml file using

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.