To simplify, if I do this:

<xmltask source="a.xml" dest="b.xml" report="true">
        <insert path="/a/child::node()[1]/."
position="before"><![CDATA[<x/>]]></insert>
</xmltask>

to this:

<a>
        <b/>
        <c/>
</a>

I get this:
<a>
<x/>
        <b/>
        <c/>
</a>

which looks to me like what you want ?

Brian



On Fri, March 28, 2008 14:47, Karr, David wrote:
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On
>> Behalf Of Brian Agnew
>> Sent: Friday, March 28, 2008 6:50 AM
>> To: Karr, David
>> Cc: xmltask-users@lists.sourceforge.net
>> Subject: Re: [Xmltask-users] Add text to web-app/description
>> if it's present
>>
>>
>> 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.
>
> I just went through all of the tests.  I don't see anything similar to
> this scenario.
>
> Realize that I'm trying to insert this element as the first child of the
> "web-app" element.  Using the default of "under" results in the element
> being inserted as the last child, not the first child.
>
> The only way I can see this could work is if I somehow found the actual
> current first child of "web-app" (I don't know for sure what it will
> be), and then insert with position="before".  I tried using the
> following, but it didn't work:
>
>       "/*[local-name()='web-app']/child::node()[1]/."
>
>>
>> >> 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/mark
>> >> e
>> >> > 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/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
>>
>


-- 
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