2011-10-28 65 views
0

我有一個樣式表這樣XSLT Ant任務沒有參數傳遞到我的樣式表

<?xml version="1.0" encoding="utf-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:param name="testParam"/> 
    <xsl:template match="@*|node()"> 
     <xsl:copy> 
      <xsl:apply-templates select="@*|node()" /> 
     </xsl:copy> 
    </xsl:template> 
    <xsl:template match="resources/integer[@name='LOG_LEVEL']/text()"> 
     <xsl:value-of select="$testParam"/> 
    </xsl:template> 
</xsl:stylesheet> 

而且我有一個輸入XML這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <integer name="LOG_LEVEL">3</integer> 
    <string name="app_name">Test Application</string> 
</resources> 

但是,當我嘗試調用一個XSLT使用這種螞蟻變換:

<xslt in="in.xml" out="out.xml" style="style_above.xsl"> 
    <outputproperty name="method" value="xml"/> 
    <outputproperty name="encoding" value="UTF-8"/> 
    <outputproperty name="indent" value="yes"/> 
    <param name="testParam" expression="test"/> 
</xslt> 

我得到如下:

<?xml version="1.0" encoding="UTF-8"?> 
<resources> 
    <integer name="LOG_LEVEL"/> 
    <string name="app_name">Test Application</string> 
</resources> 

它似乎並沒有被改變我的XSLT參數,我在螞蟻的目標

+0

我使用ANT 1.8.2的方式 – DennisA

+0

它工作得很好。測試它與螞蟻1.8.2 :) – FailedDev

回答

1

沒錯指定的值,我想通了,問題是不同的東西。即將更新這個爲時已晚。我在一個宏中定義了xslt任務,並且有一個名爲param的可選元素,這是罪魁禍首。謝謝