XML:

<?xml version="1.0" encoding="utf-8"?>
    <NewDataSet>
      <inc_incident>
        <inc_assessmentvitalsigns>
          <DateVitalSignsTaken>2013-10-06T20:23:36</DateVitalSignsTaken>
          <SBP>10</SBP>
          <DBP>20</DBP>
          <inc_cardiacrhythm>
            <CardiacRhythm></CardiacRhythm>
          </inc_cardiacrhythm>
        </inc_assessmentvitalsigns>
        <inc_assessmentvitalsigns>
          <DateVitalSignsTaken>2013-10-06T20:24:36</DateVitalSignsTaken>
          <SBP>0</SBP>
          <DBP>0</DBP>
          <inc_cardiacrhythm>
            <CardiacRhythm>Asystole</CardiacRhythm>
          </inc_cardiacrhythm>
        </inc_assessmentvitalsigns>
        <inc_assessmentvitalsigns>
          <DateVitalSignsTaken>2013-10-06T20:25:36</DateVitalSignsTaken>
          <SBP>0</SBP>
          <DBP>0</DBP>
          <inc_cardiacrhythm>
            <CardiacRhythm>Sinus Tachycardia</CardiacRhythm>
          </inc_cardiacrhythm>
        </inc_assessmentvitalsigns>
      </inc_incident>
    </NewDataSet>

XSL :(仅摘要)
<fo:table-row>
 <fo:block>
  <xsl:for-each select="inc_assessmentvitalsigns">
   <xsl:if test="inc_cardiacrhythm/cardiacRhythm !=''">
    <xsl:for-each select="inc_cardiacrhythm/CardiacRhythm">
       <fo:inline font-family="Verdana, Arial, sans-serif" font-size="9pt">
        <xsl:apply-templates />
       </fo:inline>
  </xsl:for-each>
   </xsl:if>
    </xsl:for-each>
 </fo:block>
</fo:table-row>
   .......
<fo:table-row>
</fo:table-row>

我正在使用APACHE FOP生成带有表和行的PDF文档。

问题是如何仅返回CardiacRhythm的第一个非空元素?如果我用
xsl:value-of
 select

然后表格的下一行将被截断。我不知道这个。谢谢你的帮助。

xsl的结果:


心动过速窦性心动过速

最佳答案

这样可以:

<xsl:for-each select="inc_assessmentvitalsigns[inc_cardiacrhythm/cardiacRhythm !=''][1]">
    <fo:inline font-family="Verdana, Arial, sans-serif" font-size="9pt">
        <xsl:apply-templates select="inc_cardiacrhythm/cardiacRhythm" />
    </fo:inline>
</xsl:for-each>

07-28 06:01