PDF格式的XSL

时间:2013-07-19 05:35:11

标签: php xsl-fo

<fo:block>

It has been recommended that _______________<fo:inline text-decoration="underline"><xsl:value-of select="/root/demo/student_name"/></fo:inline> will receive the following services/placement:      

</fo:block>

嘿伙计们..我正在研究一个项目并遇到这个小问题..每当&#34; student_name&#34; in&#34;&#34;有一个值,它显示:

  

输出:建议 _ __ _John DOE将收到   以下服务/安置。

我怎样才能找到一个解决方案,每当&#34; student_name&#34;不是 设置,它只会显示&#34;建议 _ ___ 将获得以下服务/安置。&#34;?帮助我。

2 个答案:

答案 0 :(得分:2)

查看xsl choose

<fo:block>
<xsl:choose>
  <xsl:when test="/root/demo/student_name != ''">
     <xsl:value-of select="/root/demo/student_name"/>
  </xsl:when>
  <xsl:otherwise>
    <fo:inline text-decoration="underline">   </fo:inline> 
  </xsl:otherwise>
</xsl:choose>
will receive the following services/placement: 
</fo:block>

这不是一个有效的例子,但我希望它可以让你知道在哪里看。

最重要的是,看一下文档,它不会超过15-20分钟才能阅读全部内容 W3Schools XSLT

答案 1 :(得分:0)

您可以简单地使用xsl:if语句,它允许您测试节点是否与使用xsl:choose时的情况非常相似,但是您可以在这样的一行中实现您想要的结果...

<fo:block>

It has been recommended that _______________<xsl:if test="/root/demo/student_name"><fo:inline text-decoration="underline"><xsl:value-of select="/root/demo/student_name"/></fo:inline></xsl:if> will receive the following services/placement:      

</fo:block>

这将检查student_name节点是否为THERE,如果要检查它是否为空,可以使用!=比较器,但在这种情况下似乎没有必要,因为它是空白的如果你没有以任何主要方式改变间距或位置,它不应该伤害任何东西。