Simon Baker wrote:
> Hi Nicola
>
> Thanks for the patch. Some further questions:
:-) :-)
> 1. Do i need to try it out before it gets into a nightly build?
Ahem... it's a patch, not yet in CVS.
You can try it out before if you need it.
> 2. I've examined the source and was wondering what will happen to the
> following XML:
> <root>
> <a atr="tag1">
> <b> one </b>
> <b> two </b>
> </a>
> <a atr="tag2">
> <b> three </b>
> <b> four </b>
> </a>
> </root>
>
> If I understand the XMLProperty documentation the attribute value does not
> influence the ant property name.
Hmmm...
> Solutions?
> ------------------
> 1. Maybe XMLProperty can have setting where attribute value does influence
> property name. For instance the above example could translate into:
> root.a.atr=tag1,tag2
> root.a.atr_tag1.b=one,two
> root.a.atr_tag2.b=three,four
> root.a.b=?maybe? one,two,three,four
hehehe, very tricky, I didn't think of it ;-D
Currently, without testing, the patch I submitted should give with
collapseAttributes=true:
root.a.atr=tag1,tag2
root.a.b=one,two,three,four
With collapseAttributes=false:
root.a(atr)=tag1,tag2
root.a.b=one,two,three,four
Now, what you want to do is something like
root.a(atr=tag1).b=three,four
Right?
> 2. Maybe a simple XPath like task would be more appropriate.
>
> Any thoughts/advice?
Already done :-)
It's called JXpath and XMLDOM, and you find them in the dir proposal/embed.
Just cd in that dir, run Ant, and it will automatically install the
extension in your Ant (copies simply sax2.jar in you ANT_HOME/lib dir).
Then, to do what you need:
<taskdef classname="org.apache.tools.ant.taskdefs.optional.JXPath"
name="jxpath" />
<!-- Init JxPath. '/' is the project -->
<jxpath/>
<!-- This is XMLDOM.java - a datatype that holds an xml DOM -->
<typedef name="xmldom"
classname="org.apache.tools.ant.types.XMLDOM"/>
<!-- Init XMLDOM.The DOM of the file will be referenced via the id-->
<xmldom id="mypros" file="properties.xml"/>
<echo message="${jxpath:/references/mypros/root/root/a[atr=tag1]/b}" />
For more info:
http://www.krysalis.org/cgi-bin/krywiki.pl?AntJXPath
--
Nicola Ken Barozzi [EMAIL PROTECTED]
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>