You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Jörg Schaible <Jo...@Elsag-Solutions.com> on 2003/11/26 13:49:11 UTC
jelly script woes
Hello,
currently I fight with the Jelly script for a plugin extension and I got stuck. See the following example:
Having following properties:
all=y,x
prop.x=1
prop.y=2
prop.z=0
I would like to iterate over the properties "prop.<key>" defined in "all":
<?xml version="1.0"?>
<project xmlns:j="jelly:core" xmlns:u="jelly:util" xmlns:ant:"jelly:ant">
<u:tokenize var="all.split" delim=",">${all}</u:tokenize>
<j:forEach var="i" items="${all.split}">
<ant:echo>prop.${i}:${prop[i]}</ant:echo>
</j:forEach>
The script should have printed:
prop.x:1
prop.y:2
Unfortunately Jelly seems not to support the [] syntax and the second expression evaluates to null.
This approach is a syntax error:
<ant:echo>prop.${i}:${prop.${i}}</ant:echo>
This one will print also nothing useful:
<ant:echo>prop.${i}:${<j:expr value="prop.${i}"/>}</ant:echo>
So is there any solution to create such assembled variables?
Regards,
Jörg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: jelly script woes
Posted by di...@multitask.com.au.
Jörg Schaible <Jo...@Elsag-Solutions.com> wrote on 26/11/2003
11:49:11 PM:
> Hello,
>
> currently I fight with the Jelly script for a plugin extension and I got
> stuck. See the following example:
>
> Having following properties:
> all=y,x
> prop.x=1
> prop.y=2
> prop.z=0
>
> I would like to iterate over the properties "prop.<key>" defined in
"all":
>
> <?xml version="1.0"?>
> <project xmlns:j="jelly:core" xmlns:u="jelly:util"
xmlns:ant:"jelly:ant">
> <u:tokenize var="all.split" delim=",">${all}</u:tokenize>
> <j:forEach var="i" items="${all.split}">
> <ant:echo>prop.${i}:${prop[i]}</ant:echo>
> </j:forEach>
>
> The script should have printed:
>
> prop.x:1
> prop.y:2
>
> Unfortunately Jelly seems not to support the [] syntax and the second
> expression evaluates to null.
> This approach is a syntax error:
>
> <ant:echo>prop.${i}:${prop.${i}}</ant:echo>
>
> This one will print also nothing useful:
>
> <ant:echo>prop.${i}:${<j:expr value="prop.${i}"/>}</ant:echo>
>
> So is there any solution to create such assembled variables?
Use something like this:
<j:set var="variable">jdbc.database.${jdbc.os}</j:set>
<j:set var="dbdatabase" value=
"${context.findVariable(variable)}" />
This sets dbdatabase to the value of the variable ('jdbc.database.' +
whatever was in the variable 'jdbc.os').
--
dIon Gillard, Multitask Consulting
Blog: http://blogs.codehaus.org/people/dion/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org