On Fri, March 28, 2008 13:36, Karr, David wrote:
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On
>> Behalf Of Brian Agnew
>> Sent: Friday, March 28, 2008 5:33 AM
>> To: Karr, David
>> Cc: xmltask-users@lists.sourceforge.net
>> Subject: Re: [Xmltask-users] Add text to web-app/description
>> if it's present
>>
>> Hi David -

>
> Acknowledged.  I had experimented with that, but I think I had something
> else wrong at the time.  I'll try that again.
>

Ok.

>> 2) Can you clarify your 'last child' comment below ? <paste>
>> is a synonym for <insert> and does have some positional
>> control (under/before/after).
>> But I'm not sure that's your problem.
>
> I'm not sure what else I can clarify.  The xpath on my paste/insert is
> "/*[local-name()='web-app']/.".  I'm trying to insert the "description"
> element as the first child of "web-app", but it inserts it as the last
> child.
>
> Perhaps if I can change the xpath to refer to the first element child of
> "web-app", and then use 'position="before"' on the paste, but my first
> attempt at this:
>
>       "/*[local-name()='web-app']/child::node()[1]/."
>
> Resulted in an output file that was ONLY the xml directive, and nothing
> else.

I would certainly expect a position="before" to do what you want. I think
the samples in the src download must have some examples/tests around this.

>
>> 3) Can you clarify your 'trim' comment below ? Sounds like a
>> possible feature if I'm interpreting you correctly.
>
> I'm trying to have the result be "<description>text</description>".  In
> order to remove the extraneous newlines, I had to arrange it like this:
>
> <replace if="existingDescription"
> path="/*[local-name()='web-app']/*[local-name()='description']/text()"
>                      expandProperties="true"
>                 ><![CDATA[${existingDescription} - ${label}:
> ${labelDesc}]]></replace>
>
> Notice the ending ">" of the start tag next to the start of the CDATA,
> and the end tag at the end of the line with the CDATA.
>

Yes. The insert/paste command may benefit from a 'trim' type attribute (or
perhaps as default behaviour - although I'm reluctant to remove whitespace
as a default action).

Thx for the feedback.

Brian

>>
>> nb. your XPaths may be simplified by using
>>
>> /:web-app/:description
>>
>> rather than the verbose but correct 'local-name()' syntax
>> (caveat: not tried - just by inspection).
>
> I'll try that.  I think some people had tried that in other contexts and
> it didn't work.
>
>> Hope that's of use. Please let me know how you get on...
>>
>> Brian
>>
>> On Thu, March 27, 2008 23:56, Karr, David wrote:
>> > It's been a while since I've xmltasked.  I'm having some trouble
>> > getting done what I need.
>> >
>> > I have some text in a couple properties (I'm hardcoding the
>> values for
>> > now) that I want to put into the "/web-app/description"
>> element of a
>> > web.xml file.  If the element is already present, I want to add the
>> > new text after " - ".  If the element wasn't present, then
>> create the
>> > element with the new text.
>> >
>> > I have two current problems:
>> >
>> > If the "description" element was present already, it's supposed to
>> > insert a value referencing the property containing the
>> existing value.
>> > Instead of the value of the property, it just inserts
>> > "${existingDescription}".  I tried printing out the property value
>> > after the xmltask tag, and it appears to be fine.
>> >
>> > If the "description" element was NOT present, I insert the new
>> > "description" element (using that weird trick just talked about for
>> > turning off insertion of empty "xmlns" attributes), but it
>> inserts it
>> > as the last child of "web-app", not the first.  I don't see
>> a way to
>> > do this cleanly.
>> >
>> > I also wish there was a cleaner way to "trim" the resulting output
>> > (see what I had to do in the first "replace").
>> >
>> > Here's my current code:
>> > ---------------------
>> > <target name="install-label-info">
>> >         <taskdef name="xmltask"
>> > classname="com.oopsconsultancy.xmltask.ant.XmlTask"
>> >                  classpath="${file.reference.xmltask.jar}"/>
>> >         <property name="label" value="abc"/>
>> >         <property name="labelDesc" value="def"/>
>> >         <xmltask source="${build.web.dir}/WEB-INF/web.xml"
>> > dest="${build.web.dir}/WEB-INF/web.xml" report="true">
>> >                    <copy
>> >
>> path="/*[local-name()='web-app']/*[local-name()='description']/text()"
>> > property="existingDescription"/>
>> >             <replace if="existingDescription"
>> >
>> path="/*[local-name()='web-app']/*[local-name()='description']/text()"
>> >                      expandProperties="true"
>> >                 ><![CDATA[${existingDescription} - ${label}:
>> > ${labelDesc}]]></replace>
>> >             <paste unless="existingDescription"
>> > path="/*[local-name()='web-app']/.">
>> >                 <![CDATA[<description
>> > xmlns="http://java.sun.com/xml/ns/j2ee";>${label}:
>> > ${labelDesc}</description>]]>
>> >             </paste>
>> >                    <copy
>> >
>> path="/*[local-name()='web-app']/*[local-name()='description']/text()"
>> > property="newDescription"/>
>> >         </xmltask>
>> >         <echo
>> message="existingDescription[${existingDescription}]"/>
>> >         <echo message="newDescription[${newDescription}]"/>
>> >     </target>
>> > ---------------------
>> >
>> >
>> >
>> >
>> >
>> ----------------------------------------------------------------------
>> > --- Check out the new SourceForge.net Marketplace.
>> > It's the best place to buy or sell services for just about anything
>> > Open Source.
>> >
>> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marke
>> > tplace _______________________________________________
>> > Xmltask-users mailing list
>> > Xmltask-users@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/xmltask-users
>> >
>>
>>
>> --
>> Brian Agnew                  http://www.oopsconsultancy.com
>> OOPS Consultancy Ltd
>> Tel: +44 (0)7720 397526
>> Fax: +44 (0)20 8682 0012
>>
>>
>> --------------------------------------------------------------
>> -----------
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for just about
>> anything Open Source.
>> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.n
> et/marketplace
>> _______________________________________________
>> Xmltask-users mailing list
>> Xmltask-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/xmltask-users
>>
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Xmltask-users mailing list
> Xmltask-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xmltask-users
>


-- 
Brian Agnew                  http://www.oopsconsultancy.com
OOPS Consultancy Ltd
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Xmltask-users mailing list
Xmltask-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xmltask-users

Reply via email to