M
Mike
Hello,
I have a newbie-type problem I'm trying to solve.
First, note that I'm relatively new to both XSL and DocBook.
Anyway, I'm trying to transform a portion of an XML document into a
DocBook table, using XSLT.
I thought the following logic might work, but it doesn't seem to (saxon
complains that "row" must be terminated by matching end-tag "</row>").
Note that this is a simplified example from my actual stylesheet:
<xsl:template match="mm:MyContainerElement">
<sect1>
<table>
<title>My Table</title>
<tgroup cols="3">
<tbody>
<xsl:for-each select="mm:MyEntryItem">
<xsl:if test="(position() = 1) or
((position() >= 3) and (position() mod 3 = 0))">
<row>
</xsl:if>
<entry>
<xsl:value-of select="@name"/>
</entry>
<xsl:if test="(position() = last()) or
(((position() + 1) >= 3) and ((position() + 1) mod 3 = 0))">
</row>
</xsl:if>
</xsl:for-each>
</tbody>
</tgroup>
</table>
</sect1>
</xsl:template>
Basically, what I _wanted_ to do was to create a table with 3 columns
and however many rows as needed. The idea above was to start a new
<row> element at the beginning of every 3 columns, and to end each
</row> at the end of every 3 columns. (Note that I didn't get to
actually test my logic above.)
But that doesn't seem to work. From what I've read, I think the problem
is with my thinking (imperative vs declarative programming.)
Any help would be appreciated. I'm sorry if this type of question has
been asked before - I'm sure it has - but I'm having a bit of a problem
making the leap from imperative to declarative-style thinking.
BY THE WAY: Why can't <table> offer (as an option) something like
<simplelist>, where you can just specify the number of columns, and then
you just add <member>'s - no need to specify rows? I would use
<simplelist>, but it doesn't offer all the formatting options that
<table> does.
Thanks,
Mike
I have a newbie-type problem I'm trying to solve.
First, note that I'm relatively new to both XSL and DocBook.
Anyway, I'm trying to transform a portion of an XML document into a
DocBook table, using XSLT.
I thought the following logic might work, but it doesn't seem to (saxon
complains that "row" must be terminated by matching end-tag "</row>").
Note that this is a simplified example from my actual stylesheet:
<xsl:template match="mm:MyContainerElement">
<sect1>
<table>
<title>My Table</title>
<tgroup cols="3">
<tbody>
<xsl:for-each select="mm:MyEntryItem">
<xsl:if test="(position() = 1) or
((position() >= 3) and (position() mod 3 = 0))">
<row>
</xsl:if>
<entry>
<xsl:value-of select="@name"/>
</entry>
<xsl:if test="(position() = last()) or
(((position() + 1) >= 3) and ((position() + 1) mod 3 = 0))">
</row>
</xsl:if>
</xsl:for-each>
</tbody>
</tgroup>
</table>
</sect1>
</xsl:template>
Basically, what I _wanted_ to do was to create a table with 3 columns
and however many rows as needed. The idea above was to start a new
<row> element at the beginning of every 3 columns, and to end each
</row> at the end of every 3 columns. (Note that I didn't get to
actually test my logic above.)
But that doesn't seem to work. From what I've read, I think the problem
is with my thinking (imperative vs declarative programming.)
Any help would be appreciated. I'm sorry if this type of question has
been asked before - I'm sure it has - but I'm having a bit of a problem
making the leap from imperative to declarative-style thinking.
BY THE WAY: Why can't <table> offer (as an option) something like
<simplelist>, where you can just specify the number of columns, and then
you just add <member>'s - no need to specify rows? I would use
<simplelist>, but it doesn't offer all the formatting options that
<table> does.
Thanks,
Mike