<table>
<tgroup>
<thead>Drug Interaction Table 1</thead>
<tbody>
<row><entry><drugname>Warfarin</drugname></entry>
<entry><drugname>Aspirin</drugname></entry></row>
</tbody>
</table>
All of the drug interactions tables consist of two columns (two entries in each row), with the object drug listed first, the precipitant drug listed second. You can match on the entry tags with the position () function like so:
<xsl:template match="row/entry[position() = 1]/drugname">
<br/>
<xsl:text>Object: </xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="row/entry[position() = 2]/drugname">
<br/>
<xsl:text>Precipitant: </xsl:text>
<xsl:apply-templates/>
</xsl:template>
The resulting output would look like this (assuming other templates for the rest of the data):
Object: Warfarin
Precipitant: Aspirin
You can also abbreviate your position() function like so:
<xsl:template match="row/entry[1]/drugname">
The number in the square brackets indicates the position without having to write out position() =.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.