Ecrion Software Inc. Homepage
Forum Home Forum Home > XF Designer > Generic Support
  New Posts New Posts RSS Feed: How to create dynamic table
  FAQ FAQ  Forum Search   Register Register  Login Login

How to create dynamic table

 Post Reply Post Reply
Author
Message / View First Unread Post
hinhnguyen View Drop Down
Newbie
Newbie


Joined: 16 Nov 2010
Posts: 7
Post Options Post Options   Quote hinhnguyen Quote  Post ReplyReply Direct Link To This Post Topic: How to create dynamic table
    Posted: 16 Nov 2010 at 3:58am

I have the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<BLOKK>
    <NAVN>Test kravblokk</NAVN>
    <BESKRIVELSE>Vi tester generering</BESKRIVELSE>
    <RADER>
        <RAD>
            <KRAVTYPE>Standard</KRAVTYPE>
            <KOLONNER>
                <KOLONNE>
                    <NAVN>Krav</NAVN>
                    <VERDI>Forsinkelsesrente, restskatt</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Ã…r/termin</NAVN>
                    <VERDI>2008</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Forfall</NAVN>
                    <VERDI>25.01.2010</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Kravbeløp</NAVN>
                    <VERDI>450</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Betalt</NAVN>
                    <VERDI>0</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Utestående</NAVN>
                    <VERDI>450</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
            </KOLONNER>
            <RADNUMMER>1</RADNUMMER>
        </RAD>
        <RAD>
            <KRAVTYPE>Standard</KRAVTYPE>
            <KOLONNER>
                <KOLONNE>
                    <NAVN>Krav</NAVN>
                    <VERDI>Restskatt</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Ã…r/termin</NAVN>
                    <VERDI>2008/1</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Forfall</NAVN>
                    <VERDI>20.08.2009</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Kravbeløp</NAVN>
                    <VERDI>6 518</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Betalt</NAVN>
                    <VERDI>2000</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Utestående</NAVN>
                    <VERDI>4 518</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
            </KOLONNER>
            <RADNUMMER>2</RADNUMMER>
        </RAD>
        <RAD>
            <KRAVTYPE>Standard</KRAVTYPE>
            <KOLONNER>
                <KOLONNE>
                    <NAVN>Krav</NAVN>
                    <VERDI>Restskatt</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Ã…r/termin</NAVN>
                    <VERDI>2008/2</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Forfall</NAVN>
                    <VERDI>24.09.2009</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Kravbeløp</NAVN>
                    <VERDI>6 518</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Betalt</NAVN>
                    <VERDI>0</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Utestående</NAVN>
                    <VERDI>6 518</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
            </KOLONNER>
            <RADNUMMER>3</RADNUMMER>
        </RAD>
        <RAD>
            <KRAVTYPE>Standard</KRAVTYPE>
            <KOLONNER>
                <KOLONNE>
                    <NAVN>Krav</NAVN>
                    <VERDI>Påløpte forsinkelsesrenter</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Ã…r/termin</NAVN>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Forfall</NAVN>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Kravbeløp</NAVN>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Betalt</NAVN>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN>Utestående</NAVN>
                    <VERDI>100</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
            </KOLONNER>
            <RADNUMMER>4</RADNUMMER>
        </RAD>
        <RAD>
            <KRAVTYPE>Sum</KRAVTYPE>
            <KOLONNER>
                <KOLONNE>
                    <NAVN/>
                    <VERDI>Summering</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN/>
                    <VERDI/>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN/>
                    <VERDI/>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN/>
                    <VERDI>13486</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN/>
                    <VERDI>2000</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
                <KOLONNE>
                    <NAVN/>
                    <VERDI>11586</VERDI>
                    <TYPE>xs:string</TYPE>
                </KOLONNE>
            </KOLONNER>
            <RADNUMMER>5</RADNUMMER>
        </RAD>
    </RADER>
</BLOKK>
 
and want to create a dynamic table by using following XSL transform:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
>
<xsl:output encoding="UTF-8" standalone="yes"/>
<xsl:template match="/">
  <html>
  <body>
  <h2><xsl:value-of select="BLOKK/NAVN"/></h2>
  <p><xsl:value-of select="BLOKK/BESKRIVELSE"/></p>
  <table border="0">
    <tr bgcolor="#9acd32">
    <xsl:for-each select="BLOKK/RADER/RAD[1]/KOLONNER/KOLONNE">
      <th><xsl:value-of select="NAVN"/></th>     
      </xsl:for-each>
    </tr>
    <xsl:for-each select="BLOKK/RADER/RAD">
    <tr>
        <xsl:for-each select="KOLONNER/KOLONNE">
            <td><xsl:value-of select="VERDI"/></td>
        </xsl:for-each>
    </tr>
    </xsl:for-each>      
  </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

How can I create the similar table in XF-Designer?
I have tried different ways in XFD but could not get the desired result.
I can paste the XSLT directly in "Code View" but the "Design View" will then show nothing.
Back to Top
srivatsahg View Drop Down
Newbie
Newbie
Avatar

Joined: 06 Oct 2010
Location: Stuttgart
Posts: 36
Post Options Post Options   Quote srivatsahg Quote  Post ReplyReply Direct Link To This Post Posted: 16 Nov 2010 at 4:29am
Try using the repeating section in XF Designer !!
It works... !!


Back to Top
hinhnguyen View Drop Down
Newbie
Newbie


Joined: 16 Nov 2010
Posts: 7
Post Options Post Options   Quote hinhnguyen Quote  Post ReplyReply Direct Link To This Post Posted: 16 Nov 2010 at 8:38am
Thanks for your reply.
 
I could get it work by using repeating table but I have to define the number of table columns. How to build the number of table columns dynamic?
Back to Top
florinv View Drop Down
Admin Group
Admin Group


Joined: 19 May 2008
Posts: 82
Post Options Post Options   Quote florinv Quote  Post ReplyReply Direct Link To This Post Posted: 16 Nov 2010 at 8:58am
Created repeated columns is not supported visually, but you can do this from XSLT.

Go to Insert/XSLT Code and paste the following:

<fo:table table-layout="fixed" width="100%">
     <xsl:for-each select="BLOKK/RADER/RAD[1]/KOLONNER/KOLONNE">
          <fo:table-column column-width="proportional-column-width(1)"/>
     </xsl:for-each>
     <fo:table-header>
          <fo:table-row background-color="#9acd32">
               <xsl:for-each select="BLOKK/RADER/RAD[1]/KOLONNER/KOLONNE">
                    <fo:table-cell>
                         <fo:block>
                              <xsl:value-of select="NAVN"/>
                         </fo:block>
                    </fo:table-cell>
               </xsl:for-each>
          </fo:table-row>
     </fo:table-header>
     <fo:table-body>
          <xsl:for-each select="BLOKK/RADER/RAD">
          <fo:table-row>
               <xsl:for-each select="KOLONNER/KOLONNE">
                    <fo:table-cell>
                         <fo:block>
                              <xsl:value-of select="VERDI"/>
                         </fo:block>
                    </fo:table-cell>
               </xsl:for-each>
          </fo:table-row>
          </xsl:for-each>            
     </fo:table-body>
</fo:table>
Back to Top
hinhnguyen View Drop Down
Newbie
Newbie


Joined: 16 Nov 2010
Posts: 7
Post Options Post Options   Quote hinhnguyen Quote  Post ReplyReply Direct Link To This Post Posted: 17 Nov 2010 at 3:31am
Thanks florinv, I have learned a new way to include XSLT in XFD but what I need is showing the table in the design view.
 
I have solved the problem by create the number of columns static and then let XFD fill the content into the columns dynamic. By this way the table will be visible in the design view


Edited by hinhnguyen - 17 Nov 2010 at 3:34am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz

This page was generated in 0.484 seconds.