docbook-apps

  • 1.  [XSLT] Determining the entry column

    Posted 08-31-2010 20:18
    Hello Everyone,

    I am investigating possibilities of the DB tables export into the given
    proprietary format. Now I am stuck with the demand to specify the location
    for every table entry in the form column:row.

    My test data follows:



    <tgroup cols="3">
    <colspec colname="c1" colnum="1"/>
    <colspec colname="c2" colnum="2"/>
    <colspec colname="c3" colnum="3"/>

    <row>
    <entry>0:0</entry>
    <entry>1:0</entry>
    <entry morerows="1">2:0</entry>
    </row>
    <row>
    <entry namest="c1" nameend="c2">0:1</entry>
    </row>
    <row>
    <entry>0:2</entry>
    <entry>1:2</entry>
    <entry>2:2</entry>
    </row>

    </tgroup>


    This location should match the info in the content of every entry. While the
    row number is quite easy to get, retrieving the column number has turned out
    to be quite tricky.

    I am using the following code with some external calls
    (../common/tables.xsl):

    <xsl:template match="entry">
    <xsl:variable name="location">

    <xsl:call-template name="entry.colnum"/>
    <xsl:text>:</xsl:text>

    <xsl:value-of select="count(../preceding-sibling::row)"/>
    </xsl:variable>
    </xsl:template>

    The problem is, that entry.colnum template returns the correct values only
    when there are sufficient data in the original table (namest and colname
    attributes).
    With morerows (aka rowspan) it is quite tricky to calculate the given column
    number and that task seems to be too complex. Isn't there any overlooked
    template in the DB distribution which can handle this and to return the
    correct number? ;-)

    Is there better place where to discuss these low-level things?

    Thanks in advance for any hints.

    Regards,
    Jan





  • 2.  RE: [docbook-apps] [XSLT] Determining the entry column

    Posted 09-04-2010 09:27
    Hello Everyone,

    it has been invented... with the great help of the Andrew Welch table
    normalization code found at Dawe's site:
    http://www.dpawson.co.uk/xsl/sect2/N7450.html#d10392e763
    Thanks for sharing.

    My slighty enhanced code takes the raw table and adds the colname attribute
    if necessary to all the entries. The result is then processed as ussual. As
    there is always required info for the entry.colnum template, I can get what
    I want. I don't think my xslt code is something amazing and ready for
    production use, but it is sufficient for this particular case. If anybody
    interested, I can share it somehow.

    Regards,
    Jan

    >