Advertisement

10.31.2007 at 12:46PM PDT, ID: 22930830
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

How to XML + XSLT => XSL-FO and display a table

Asked by vferreira71 in Extensible Markup Language (XML), Extensible Stylesheet Language Transformation (XSLT)

Tags: , , ,

Ok I am trying to create an XSL-FO out of an XML and an XSLT. And I also want to display a table of the data. The main goal is to output the XSL-FO to a PDF file in java. I already figured out how to do that step. I just need to get the XSL-FO file. Here is my xml file:

[code]
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>

<sectorList>
    <sector>
        <name>Technology</name>
        <percentOfTotal>
            <b>0.16</b>
            <s>9.12</s>
            <ss>0.80</ss>
            <sse>0.00</sse>
        </percentOfTotal>
        <numberOfShares>
            <b>250000</b>
            <s>6052</s>
            <ss>10100</ss>
            <sse>0</sse>
        </numberOfShares>
    </sector>
    <sector>
        <name>Consumer Discretionary</name>
        <percentOfTotal>
            <b>250000</b>
            <s>6052</s>
            <ss>10100</ss>
            <sse>0</sse>
        </percentOfTotal>
        <numberOfShares>
            <b>250000</b>
            <s>6052</s>
            <ss>10100</ss>
            <sse>0</sse>
        </numberOfShares>
    </sector>
</sectorList>
[/code]

Here is my XSLT file:
[code]
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format"
                              xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>

<xsl:template match="/">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <fo:layout-master-set>
            <fo:simple-page-master master-name ="simple" page-height ="29.7cm" page-width  ="21cm" margin-left ="2.5cm" margin-right="2.5cm">
                <fo:region-body margin-top="3cm"/>
            </fo:simple-page-master>
        </fo:layout-master-set>
        <fo:page-sequence master-reference="simple">
            <fo:flow flow-name="xsl-region-body">
                <xsl:apply-templates/>
            </fo:flow>
        </fo:page-sequence>
    </fo:root>
</xsl:template>

<xsl:template match="sectorList">
    <fo:table-and-caption>
        <fo:table>
            <fo:table-column column-width="25mm"/>
            <fo:table-column column-width="25mm"/>
            <fo:table-column column-width="25mm"/>
            <fo:table-column column-width="25mm"/>
            <fo:table-header>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block font-weight="bold">Sector</fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block font-weight="bold">Side</fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block font-weight="bold">% of Total</fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block font-weight="bold">Total Shares</fo:block>
                    </fo:table-cell>
                </fo:table-row>
            </fo:table-header>
            <fo:table-body>

                <xsl:for-each select="sector">
                <fo:table-row>
                    <fo:table-cell number-rows-spanned="4">
                        <fo:block font-weight="bold"><xsl:value-of select="name"/></fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block font-weight="bold">B</fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block font-weight="bold"><xsl:value-of select="percentOfTotal/b"/></fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block font-weight="bold"><xsl:value-of select="numberOfShares/b"/></fo:block>
                    </fo:table-cell>
                </fo:table-row>

                    <fo:table-row>
                        <fo:table-cell>
                            <fo:block font-weight="bold">S</fo:block>
                        </fo:table-cell>
                        <fo:table-cell>
                            <fo:block font-weight="bold"><xsl:value-of select="percentOfTotal/s"/></fo:block>
                        </fo:table-cell>
                        <fo:table-cell>
                            <fo:block font-weight="bold"><xsl:value-of select="numberOfShares/s"/></fo:block>
                        </fo:table-cell>
                    </fo:table-row>

                    <fo:table-row>
                        <fo:table-cell>
                            <fo:block font-weight="bold">SS</fo:block>
                        </fo:table-cell>
                        <fo:table-cell>
                            <fo:block font-weight="bold"><xsl:value-of select="percentOfTotal/ss"/></fo:block>
                        </fo:table-cell>
                        <fo:table-cell>
                            <fo:block font-weight="bold"><xsl:value-of select="numberOfShares/ss"/></fo:block>
                        </fo:table-cell>
                    </fo:table-row>

                    <fo:table-row>
                        <fo:table-cell>
                            <fo:block font-weight="bold">SSE</fo:block>
                        </fo:table-cell>
                        <fo:table-cell>
                            <fo:block font-weight="bold"><xsl:value-of select="percentOfTotal/sse"/></fo:block>
                        </fo:table-cell>
                        <fo:table-cell>
                            <fo:block font-weight="bold"><xsl:value-of select="numberOfShares/sse"/></fo:block>
                        </fo:table-cell>
                    </fo:table-row>

                    <fo:table-row>
                        <fo:table-cell number-columns-spanned="4">
                            <fo:block font-weight="bold">------------------------</fo:block>
                        </fo:table-cell>                        
                    </fo:table-row>                    
                <!--</fo:table-row>-->
                </xsl:for-each>

            </fo:table-body>
        </fo:table>
    </fo:table-and-caption>
</xsl:template>
</xsl:stylesheet>
[/code]

I want the table to look like this...

Sector | Side | % of Total | Total Shares
-----------------------------------------------
            |   B   |   0.23        |    100000
Tech    |   S   |   0.12        |    5000
            |  SS |   12.3        |        1000
            | SSE|    0.90       |       200
---------------------------------------------------------------------------------------------
            |   B   |   0.23        |    100000
Cons    |   S   |   0.12        |    5000
            |  SS |   12.3        |        1000
            | SSE|    0.90       |       200

This data is just sample data but that layout is pretty much what I am looking for. So to summarize, first I need to fix my XML and XSLT files so that I get the correct table output then I need to be able to combine these files and generate a XSL-FO file. Thanks in advanceStart Free Trial
 
Keywords: How to XML + XSLT => XSL-FO an…
 
Loading Advertisement...
 
[+][-]11.01.2007 at 11:27AM PDT, ID: 20195275

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Extensible Markup Language (XML), Extensible Stylesheet Language Transformation (XSLT)
Tags: table, xsl, xslt, display
Sign Up Now!
Solution Provided By: R7AF
Participating Experts: 1
Solution Grade: B
 
 
[+][-]11.01.2007 at 12:29PM PDT, ID: 20195855

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:06PM PDT, ID: 20196236

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:16PM PDT, ID: 20196312

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 02:57PM PDT, ID: 20196994

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628