2013-07-09 54 views
0

我有一個xsl代碼,我需要像在Java中一樣實現replaceAll功能。我試過 trasnlate函數,但它不起作用。我不確定在下面的代碼中哪裏以及如何使用這個函數,你請幫忙。xsl - 字符串在我的代碼中翻譯 - 需要幫助

<xsl:template match="warning"> 
    <xsl:param name="drugsSub" select="'false'"/> 
    <tr> 
     <td class="dataRowBorderBottom rowColor" style="width: 35%; padding-right: 5px; font-size:.85em;"> 
     **<xsl:apply-templates select="translate(warningId,'/','/ ')">** This is not working. I want translate function to work both warningId. A value comes for this variable from some other file. 
      <xsl:with-param name="drugsSub" select="$drugsSub"/> 
     </xsl:apply-templates> 
     </td> 
     <td class="dataRowBorderBottom rowColor leftPadding" style="width: auto; padding-bottom: 15px; font-size:.85em;"> 
     <xsl:apply-templates select="severity"/> 
     </td> 
     <td class="dataRowBorderBottom rowColor leftPadding" style="width: 13%;font-size:.85em;"> 
     <xsl:apply-templates select="documentationRating"/> 
     </td> 
     <td class="dataRowBorderBottom rowColor leftPadding" style="width: 35%; padding-top: 3px; font-size:.85em;"> 
     <xsl:value-of select="warningText"/> 
     </td> 
    </tr> 
    </xsl:template> 
+0

請指定你想要發生的事情。示例輸入和輸出會很好。 'translate()'可能不會做你認爲它做的事。也許你想用字符串'/'替換每個'/'字符?如果是這樣,最好的答案取決於您是否可以使用XSLT 2.0,或者堅持使用1.0。 – LarsH

+0

這個問題是重複的:http://stackoverflow.com/questions/5280079/xsl-multiple-search-and-replace-function – LarsH

回答

0

我可以告訴你爲什麼代碼不工作:翻譯()產生一個字符串,而不能應用模板(僅一個節點集)的字符串。

但我不能告訴你如何解決它,因爲我不知道你想達到什麼。