Hello Scott,
first of all thank you for your reply. I followed your instructions,
but it seems that stylesheet does not render the param correctly, and
I can't understand where I am doing wrong. Real script following (I've
tried both with and without single ticks around parameter in Ant code,
with the same result):
_____________________________________________
Ant code:
_____________________________________________
...
<property name="newFrwVersion" value="1.2.3"/>
...
<xslt basedir="${workDir}" extension=".xml" destdir="dest/"
style="style/setFrameworkVersion.xsl">
<param name="newFrwVersion" expression="${newFrwVersion}"/>
<include name="**/pom.xml"/>
</xslt>
...
_____________________________________________
Stylesheet:
_____________________________________________
<xsl:param name="newFrwVersion"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="m:version[../m:groupId='it.trend.lit.framework']">
<version>$newFrwVersion</version>
</xsl:template>
_____________________________________________
Resulting POM:
_____________________________________________
...
<dependency>
<groupId>it.trend.lit.framework</groupId>
<artifactId>Base_Platform</artifactId>
<classifier>${appServer}</classifier>
<version>$newFrwVersion</version>
</dependency>
...
As you can see it thinks that "$newFrwVersion" is the value to be
rendered inside the result file.
Where am I doing wrong?
Thanks a lot once again
Jo
On Fri, Dec 17, 2010 at 2:05 PM, Scot P. Floess <[email protected]> wrote:
>
> You are mixing concepts... Although your XSLT is invoked from Ant, you lose
> Ant's properties. Quite honestly, this is no different than kicking off an
> XSLT from a Java app...the XSLT is somewhat insulated :)
>
> You will need to use the param subelement... This should fix your problem
> (although I have not tested):
>
> Ant:
> <property name="floorType" value="wood"/>
>
> <xslt basedir="${workDir}" extension=".xml"
> destdir="out/"style="style/setValues.xsl">
> <include name="**/*.xml"/>
> <param name="floorType" expression="${floorType}"/>
> </xslt>
>
> XSLT:
> <xsl:param name="floorType"/>
>
> <xsl:template match="@*|node()">
> <xsl:copy>
> <xsl:apply-templates select="@*|node()"/>
> </xsl:copy>
> </xsl:template>
>
> <xsl:template match="floor[../tapestry='red']">
> <floor>$floorType</floor>
> </xsl:template>
>
>
> Just put the <xsl:param> line up close to the top of your transform
> (although I don't think it has to exactly be there)...
>
> Note, using $floorType in the XSLT as opposed to ${floorType} - in XSLT you
> don't wrap variables/param within curly braces...
>
> If this is still wrong, within Ant's XSLT param, you may have to do this:
>
> <xslt basedir="${workDir}" extension=".xml"
> destdir="out/"style="style/setValues.xsl">
> <include name="**/*.xml"/>
> <param name="floorType" expression="'${floorType}'"/>
> </xslt>
>
> See the single ticks around ${floorType}?
>
> Honestly, its been a while since I passed in params from an Ant script...one
> of the two should work...
>
>
> HTH,
>
> Flossy
>
>
> On Fri, 17 Dec 2010, Jo Support wrote:
>
>> Hello people,
>>
>> how do I pass a variable to a stylesheet using xslt task?
>>
>> I have this ant script:
>>
>> <property name="floorType" value="wood"/>
>>
>> <xslt basedir="${workDir}" extension=".xml" destdir="out/"
>> style="style/setValues.xsl">
>> <include name="**/*.xml"/>
>> </xslt>
>>
>> and this stylesheet:
>>
>> <xsl:template match="@*|node()">
>> <xsl:copy>
>> <xsl:apply-templates select="@*|node()"/>
>> </xsl:copy>
>> </xsl:template>
>>
>> <xsl:template match="floor[../tapestry='red']">
>> <floor>${floorType}</floor>
>> </xsl:template>
>>
>> but the process writes in the output file exactly
>>
>> <floor>${floorType}</floor>
>>
>> instead of the value of the property.
>>
>> Where am I doing wrong?
>>
>> Thanks a lot
>>
>> Jo
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
> --
> Scot P. Floess
>
>
> RHCT (Certificate Number 605010084735240)
>
> Chief Architect FlossWare http://sourceforge.net/projects/flossware
> http://flossware.sourceforge.net
> https://github.com/organizations/FlossWare
>
> Chief Architect JPlate http://sourceforge.net/projects/jplate
> Chief Architect JavaPIM http://sourceforge.net/projects/javapim
> Chief Architect Keros http://sourceforge.net/projects/keros
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]