Yes. 1) Attribute management is a pain, since XPath identifies only the attribute node i.e. the name AND the value. Hence a <replace> on an attribute with a text() node is not going to work.
2) The error message should be much better! 3) I think that the <attr> command needs to handle buffers. I will try and do 2) and 3) for a new release soon. 4) You can get around this by using properties. This is a bit of a pain, since properties are expanded for EACH <xmltask> invocation (actually Ant task invocation). So you have to set the property in one <xmltask> and use it in another :-( Thus: <xmltask source="c.xml"> <copy path="/a/b/text()" property="p"/> </xmltask> <xmltask source="c.xml" dest="d.xml"> <attr path="/a/b" attr="id" value="${p}"/> </xmltask> will do what you want (I think). Sets the property 'p' to your text node. Then the next <xmltask> uses this. Note how the first <xmltask> only reads the document. It doesn't write it. Hope this is of use. Brian On Fri, May 11, 2007 18:03, Youmans, Damon wrote: > I am trying to update an attribute value to append a suffix. I have > found to create the desired text value I had to create a temporary node > and set the desired text value. I have this value set properly (can see > it with the <print> function) however I cannot get the <replace> to work > with my buffer..it keeps giving the error Attempt to insert prior to > root node. Any ideas?? > > <xmltask > source="${jarSourceDirectory}ejbModule/META-INF/ibm-ejb-jar-bnd.xmi" > dest="c:\tmp\ibm-ejb-jar-bnd_TEMP.xmi"> > <!-- First, just get a node added with the context root suffix. > Need to do this to manipulate attributes --> > <insert path="/ejbbnd:EJBJarBinding" xml="<damon/>" > position="under"/> > <copy > path="/ejbbnd:EJBJarBinding/ejbBindings/@listenerInputPortName" > buffer="namedBuffer" attrValue="true"/> > <insert path="/ejbbnd:EJBJarBinding/damon" buffer="namedBuffer" > position="under"/> > <insert path="/ejbbnd:EJBJarBinding/damon" > xml="${contextRootSuffix}" position="under"/> > <copy path="/ejbbnd:EJBJarBinding/damon/text()" buffer="namedBuffer" > append="false"/> > <print buffer="namedBuffer"/> > > <!-- THIS works ok... --> > <replace > path="/ejbbnd:EJBJarBinding/ejbBindings/@listenerInputPortName" > withText="testTextReplace"/> > <print > path="/ejbbnd:EJBJarBinding/ejbBindings/@listenerInputPortName"/> > > <!-- THIS does not work?? --> > <replace > path="/ejbbnd:EJBJarBinding/ejbBindings/@listenerInputPortName" > withBuffer="namedBuffer"/> > > <!-- cleanup of temp node created for attibute mod --> > <remove path="/ejbbnd:EJBJarBinding/damon"/> > </xmltask> > > Here is the output when run through ANT: > [xmltask] { buffer 'namedBuffer' output > [xmltask] ListenerPort_INSURITY_COVERAGE_VERIFYQA > [xmltask] } buffer 'namedBuffer' output > [xmltask] { node output > [xmltask] testTextReplace > [xmltask] } node output > [xmltask] Attempt to insert prior to root node > > > > Starting XML > <?xml version="1.0" encoding="UTF-8"?> > <ejbbnd:EJBJarBinding xmi:version="2.0" > xmlns:xmi="http://www.omg.org/XMI" xmlns:ejbbnd="ejbbnd.xmi" > xmlns:ejb="ejb.xmi" xmi:id="EJBJarBinding_1160662690292"> > <ejbJar href="META-INF/ejb-jar.xml#ejb-jar_ID"/> > <ejbBindings xmi:type="ejbbnd:MessageDrivenBeanBinding" > xmi:id="MessageDrivenBeanBinding_1160662690292" > listenerInputPortName="ListenerPort_INSURITY_COVERAGE_VERIFY"> > <enterpriseBean xmi:type="ejb:MessageDriven" > href="META-INF/ejb-jar.xml#CoverageVerificationMDBBean"/> > <resRefBindings xmi:id="ResourceRefBinding_1160666147208" > jndiName="jms/BigironJmsConnectionFactory"> > <bindingResourceRef > href="META-INF/ejb-jar.xml#ResourceRef_1160666147208"/> > </resRefBindings> > <resRefBindings xmi:id="ResourceRefBinding_1160666147209" > jndiName="jms/Queue_INSURITY_COVERAGE_VERIFY_REPLY"> > <bindingResourceRef > href="META-INF/ejb-jar.xml#ResourceRef_1160666147209"/> > </resRefBindings> > </ejbBindings> > </ejbbnd:EJBJarBinding> > > > <HTML><BODY> > > DISCLAIMER: This message and accompanying documents are covered by the > Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, and contains > information intended for the specified individual(s) only. This > information is confidential. If you are not the intended recipient or an > agent responsible for delivering it to the intended recipient, you are > hereby notified that you have received this document in error and that any > review, dissemination, copying, or the taking of any action based on the > contents of this information is strictly prohibited. If you have received > this communication in error, please notify us immediately by e-mail, and > delete the original message. > </BODY></HTML>------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/_______________________________________________ > 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 ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Xmltask-users mailing list Xmltask-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xmltask-users