[英]Passing a parameter to an XSL file with jcabi
我正在嘗試使用jcabi-xml
將參數傳遞給 XSL 文件。 代碼很簡單,我可以確認它執行:
final XSL xsl = new XSLDocument(Main.class.getResourceAsStream("test.xsl"));
xsl.with("test", "TestValue");
XSL 文件:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="test" select="''"/>
<xsl:template match="/">
...
<p><xsl:value-of select="$test"/></p>
...
</xsl:template>
</xsl:stylesheet>
但是,輸出為空白。 我調用了錯誤的函數嗎? 還有什么我應該做的嗎?
xsl.with
不會將參數存儲在同一個xsl
變量中,而是返回一個新的XSL
對象。 所以你需要寫
xsl = xsl.with("test", "TestValue");
然后運行轉換。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.