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/marketplace _______________________________________________ Xmltask-users mailing list Xmltask-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xmltask-users