I have an xml file and with Xsl and fop i want to create a pdf-file or a
excel (xml) file. Everything works fine with the stylesheet for the pdf,
but the xsl for Excel is terrible and because of that very slow.
The xml-file exists of three sections : INFO (properties for Excel) LAYOUT
(description and order of Cells) en Data (the real data). In the
layout-section is a entry for each field in the data and looks like this
<layout>
<field>
<vldk>CONPRD</vldk>
<vldidx>2</vldidx>
<vldlbl>conceptperiode</vldlbl>
<hdr1>concept-</hdr1>
<hdr2>periode</hdr2>
<hdr3 />
<dtat>P</dtat>
<vldlng>6</vldlng>
<vlddec>0</vlddec>
</field>
<field>
<vldk>ADM</vldk>
<vldidx>0</vldidx>
<vldlbl>administratie</vldlbl>
<hdr1>administratie</hdr1>
<hdr2 />
<hdr3 />
<dtat>A</dtat>
<vldlng>25</vldlng>
</field>
<field>
<vldk>ADMK</vldk>
<vldidx>1</vldidx>
<vldlbl>admin.</vldlbl>
<hdr1>admin.</hdr1>
<hdr2 />
<hdr3 />
<dtat>A</dtat>
<vldlng>5</vldlng>
</field>
</layout>
Data Sections looks like this:
<data>
<regel>
<conprd>200704</conprd>
<admk>B2000</admk>
<adm>XXXXX</adm>
</regel>
<regel>
<conprd>200705</conprd>
<admk>B2010</admk>
<adm>YYYY</adm>
</regel>
</data>
I want the data in order of vldidx, skipping the zero entries. The result
has to look like this :
B2000 - 200704
B2010 - 200705
Mine solution works fine when there are 2 data fields and a few records ,
but not when there are 200 fields and 1000 records.
Can someone give me a hint how to do this the right way because (as you
see) i am just starting xsl.
The (very slow working) part of my xsl:
<!--
***************************************************************************************************************
-->
<!-- Write a row
-->
<!--
-->
<!--
***************************************************************************************************************
-->
<xsl:template name="WriteData">
<xsl:for-each select="//data/*">
<xsl:variable name="rij" select="position()"/>
<Row>
<xsl:for-each select="//layout/field">
<xsl:sort select="vldidx" order="ascending"
data-type="number"/>
<xsl:if test="vldidx != 0">
<xsl:variable name="col"
select="vldidx"/>
<xsl:variable name="dec" select="vlddec"/>
<xsl:variable name="typ" select="dtat"/>
<xsl:call-template
name="GetFieldByVldidx">
<xsl:with-param name="rij"
select="$rij"/>
<xsl:with-param name="col"
select="$col"/>
<xsl:with-param
name="decimalen" select="$dec"/>
<xsl:with-param name="type"
select="$typ"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</Row>
</xsl:for-each>
</xsl:template>
<!--
***************************************************************************************************************
-->
<!-- CreateCel - MAke a cell for the spreadsheet
-->
<!--
-->
<!--
***************************************************************************************************************
-->
<xsl:template name="CreateCel">
<xsl:param name="decimalen"/>
<xsl:param name="type"/>
<xsl:param name="waarde"/>
<xsl:variable name="strnbr">
<xsl:choose>
<xsl:when test="$type = 'Z' or $type = 'P'">
<xsl:value-of select="'Number'"/>
</xsl:when>
<xsl:when test="$type = 'L'">
<xsl:value-of select="'DateTime'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'String'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<Cell ss:StyleID="style{$type}{$decimalen}">
<xsl:if test="$waarde != ''">
<Data ss:Type="{$strnbr}">
<xsl:value-of select="$waarde"/>
<xsl:if test="$type = 'L'">
<xsl:value-of
select="'T00:00:00.000'"/>
</xsl:if>
</Data>
</xsl:if>
</Cell>
</xsl:template>
<!--
***************************************************************************************************************
-->
<!-- GetFieldByVldidx - Get fiels by order of vld
-->
<!--
-->
<!--
***************************************************************************************************************
-->
<xsl:template name="GetFieldByVldidx">
<xsl:param name="rij"/>
<xsl:param name="col"/>
<xsl:param name="decimalen"/>
<xsl:param name="type"/>
<xsl:variable name="poscol">
<xsl:for-each select="//layout/field">
<xsl:if test="vldidx = $col">
<xsl:value-of select="position()"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="//data/*[position() = $rij]">
<xsl:for-each select="*[position() = $poscol]">
<xsl:variable name="wrd"><xsl:value-of
select="."/></xsl:variable>
<xsl:call-template name="CreateCel">
<xsl:with-param name="decimalen"
select="$decimalen"/>
<xsl:with-param name="type" select="$type"/>
<xsl:with-param name="waarde" select="$wrd"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
Thanks George
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--