Re: [xsl] XPath to find first cell in first row of table

Subject: Re: [xsl] XPath to find first cell in first row of table
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Sep 2016 01:25:46 -0000
On Thu, Sep 22, 2016 at 01:15:01AM -0000, Mark Giffin m1879@xxxxxxxxxxxxx scripsit:
> I have an XML table like below from which I am constructing a roughly
> matching XSL-FO table, and I need to insert something extra only in the
> first cell of the first row, as indicated:
[snip]
>        <tbody>
>          <row>
>            <entry> <!-- insert something extra here only --> text </entry>
>            <entry> text </entry>
>            <entry> text </entry>
>          </row>
>          <row>
>            <entry> text </entry>
>            <entry> text </entry>
>            <entry> text </entry>
>          </row>
>        </tbody>
>      </tgroup>
>    </table>
> 
> There are templates matching each element: table, tbody, row, entry, etc. In
> the <entry> template, how might I check if the current entry is the first
> one in the first row? Or is there a better way?

Presuming you're using XSLT 2.0 or subsequent -- 

<xsl:template match="tbody/row[1]/entry[1]">
    <fo:block> insert special things </fo:block>
    <xsl:next-match/>
</xsl:template>

-- Graydon

Current Thread