2013-07-19 55 views
1
<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> 

嘿傢伙..即時通訊工作的一個項目,並遇到了這個小問題..每當「student_name」中「」有一個值,它會顯示:XSL PDF格式

輸出:它具有被推薦爲_ __ _John DOE將收到 服務/展示位置。

我怎麼能拿出一個解決方案,每當「student_name」不是 集,它只會顯示「已建議_ ___ 將獲得以下服務/位置。」 ?幫我。

回答

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

0

您只需使用一個xsl:if語句,它允許您測試節點是有很多像你這樣在使用XSL:選擇,但你或許可以實現你在這樣一條線所需的結果...

<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節點是存在的,如果你想檢查它是否爲空,你可以使用!=比較器,但這似乎沒有必要在這種情況下,因爲如果你不用任何主要的方式改變間距或位置,它應該不會造成任何傷害。