ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicola Ken Barozzi <nicola...@apache.org>
Subject Re: ReferenceHelper - interceptor
Date Thu, 23 Jan 2003 13:17:42 GMT


Stefan Bodewig wrote:
> On Thu, 23 Jan 2003, Nicola Ken Barozzi <nicolaken@apache.org> wrote:
> 
>>Stefan Bodewig wrote:
>>
>>>On Wed, 22 Jan 2003, Dominique Devienne <DDevienne@lgc.com> wrote:
>>>
>>
>>>>Didn't understand a thing ;-)
>>>
>>>Me neither 8-)
>>
>>
>>:-))
>>
>>Good, it means that I was right in my supposition.
> 
> 
> Not necessarily.  I'm focussing on bug fixing and getting 1.5.2 out of
> the door before I really dive into the stuff originating from the
> embed proposal.
> 
> Let's say, I don't understand property-interceptors and why they are
> needed either 8-)

Simple, make it possible to add property resolution systems.

A property is now a simple value, but it's very convenient that it can 
be the result of an expression.

When I started using it in Centipede some time back, I created this 
document. Maybe it can be reused in Ant.
http://krysalis.org/cgi-bin/krywiki.pl?AntJXPath

A concrete example, that is also explained in the document, is about 
getting values from xml.

"
  I have written a <xmldom> typedef that reads an xml file and puts it 
in the references. So, let's say I want to load the build.xml file as a 
DOM, and echo the project name:

   <!-- The DOM of file test.xml is referenced via the id-->
   <xmldom id="build.xml" file="build.xml"/>
   <echo message="${jxpath:/references/build.xml/root/project/@name}" />

Other examples with xmldom:

  top-level property values (separated by comma):
  ${jxpath:/references/build.xml/root/project/property/@value}

  top-level property values that have name "p":
  ${jxpath:/references/build.xml/root/project/property[@name='p']/@value}

Final functionality: Let's say that I want to get the top-level property 
values that have the name defined in *another* Ant property, called pp:

  ${jxpath:/references/build.xml/root/project/property[@name=$p]/@value}

JXpath expands all $ xpath variables using the Ant properties.
"

>>It's theorically possible to do the same with references, and give
>>the possibility of having an interceptor to give the reference.
> 
> 
> IMHO, references and properties should be as similar as possible -
> note that this broad statement is backed by a total lack of insight
> into the PropertyHelper thing.

Well, they are not really.

    refid="blah"    <--->   ${blahvalue}

There is a level of indirection that makes it possible for me to do the 
following but not the opposite:

    refid="${blahstuff}"

With interception for properties, I can do:

    ${jxpath:/references/properties.xml/get/the/value/for/blah}

As you see, the interceptor can get me a property from a reference too:

  ${jxpath:/references/blah}

IMHO it could be confusing for users to have the possibility of doing:

  ${jxpath:/references/blah}

or

  refid="jxpath:/references/blah"

What the user would ant to intercept with the above is not the reference 
per se, but its name. And its name is a property.

  refid="jxpath:/references/blah"

can also be done by

  refid="${jxpath:/references/blah}"

I guess, no?

-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message