Hi list!
I hate Adobe Indesign generated table xml. I have already a solution
for the grouping of rows. But now the table have rowspan also, and if I
transform the xml the HTML is breaking up. Has anyone a general solution
for this table, or could someone help me, how can I do it. I'm ready to
pay for the solution.
Thank you!
Indesign XML (Table):
<Root>
<Text>
<Table xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"
aid:table="table" aid:trows="7" aid:tcols="3">
<Cell aid:table="cell" aid:crows="1" aid:ccols="3">
<CellHeading>Situação do Beneficiário/Taxas de
Bonificação</CellHeading>
</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="78.09186111410146">
<CellBodyCenter>
<CharBold>Idade</CharBold>
</CellBodyCenter>
</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="2">
<CellBodyCenter>
<CharBold>Carreira Contributiva (em anos)/Mensal</CharBold>
</CellBodyCenter>
</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="78.09186111410146">
<CellBodyCenter>< 65</CellBodyCenter>
</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="78.09186111410146">
<CellBodyCenter>Condições de Acesso à Pensão sem
Penalização</CellBodyCenter>
</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="98.93438079914081">
<CellBodyCenter>0,65%</CellBodyCenter>
</Cell>
<Cell aid:table="cell" aid:crows="3" aid:ccols="1"
aid:ccolwidth="78.09186111410146">
<CellBodyCenter>> 65</CellBodyCenter>
</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="78.09186111410146">
<CellBodyCenter>15 a 24</CellBodyCenter>
</Cell>
<Cell aid:table="cell" aid:crows="4" aid:ccols="1"
aid:ccolwidth="98.93438079914081">
<CellBodyCenter>0.33%
</CellBodyCenter>
<CellBodyCenter>0.5%
</CellBodyCenter>
<CellBodyCenter>0.65%
</CellBodyCenter>
<CellBodyCenter>1.0%</CellBodyCenter>
</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="78.09186111410146">
<CellBodyCenter>25 a 34</CellBodyCenter>
</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="78.09186111410146">
<CellBodyCenter>35 a 39</CellBodyCenter>
</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="78.09186111410146">
<CellBodyCenter>> 65</CellBodyCenter>
</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="78.09186111410146">
<CellBodyCenter>> 40</CellBodyCenter>
</Cell>
</Table>
</Text>
</Root>
The XSL:
<xsl:key name="row" match="Cell"
use=
"
concat
(
generate-id(..),'|',
floor
(
sum(preceding-sibling::Cell/@aid:ccols) div
../@aid:tcols
)
)
"/>
<xsl:template match="Table">
<xsl:element name="table">
<xsl:if test="@aid:table = 'table'">
<xsl:attribute name="border">1</xsl:attribute>
</xsl:if>
<xsl:call-template name="rows">
<xsl:with-param name="start" select="0"/>
<xsl:with-param name="end" select="@aid:trows"/>
</xsl:call-template>
</xsl:element>
</xsl:template>
<xsl:template name="rows">
<xsl:param name="start"/>
<xsl:param name="end"/>
<xsl:choose>
<xsl:when test="$start = $end">
<xsl:element name="tr">
<xsl:apply-templates
select=
"
key('row',concat(generate-id(),'|',$start))
"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="mid"
select="$start + floor(($end - $start) div 2)"/>
<xsl:call-template name="rows">
<xsl:with-param name="start" select="$start"/>
<xsl:with-param name="end" select="$mid"/>
</xsl:call-template>
<xsl:call-template name="rows">
<xsl:with-param name="start" select="$mid + 1"/>
<xsl:with-param name="end" select="$end"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="Cell[CellHeading]">
<xsl:element name="th">
<xsl:apply-templates select="@aid:ccols"/>
<xsl:apply-templates select="@aid:crows"/>
<xsl:apply-templates select="CellHeading/text()"/>
</xsl:element>
</xsl:template>
<xsl:template match="Cell">
<xsl:element name="td">
<xsl:apply-templates select="@aid:ccols"/>
<xsl:apply-templates
select=".//text()[normalize-space() != '']"/>
<xsl:if test="normalize-space(text()) = ''"> </xsl:if>
</xsl:element>
</xsl:template>
<xsl:template match="@aid:ccols[. = 1]"/>
<xsl:template match="@aid:ccols">
<xsl:attribute name="colspan">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<xsl:template match="@aid:crows[. = 1]"/>
<xsl:template match="@aid:crows">
<xsl:attribute name="rowspan">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
--~------------------------------------------------------------------
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>
--~--