xpath - Merge xml file in ant script -
Required:
Insert the following servicelet into web.xml if not already there :
& lt; Servlet & gt; & Lt; Details & gt; My service & lt; / Description & gt; & Lt; Servlet-name & gt; MyServlet & lt; / Servlet-name & gt; & Lt; Servlet category & gt; Com.tom.servlet.MyServlet & lt; / Servlet category & gt; & Lt; Load-On-Startup & gt; 1 & lt; / Load-on-startup & gt; & Lt; / Servlet & gt; & Lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; MyServlet & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / Servlet / myServlet / * & lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt; I am using my ant script
tried the following script, but failed:
& Lt; Insert = "servletfound" path = "/ web-app / servlet [last ()]" after position = "& gt; & Lt ;! [CDATA [& lt; Servlet & gt; & Lt; Details & gt; My service & lt; / Description & gt; & Lt; Servlet-name & gt; MyServlet & lt; / Servlet-name & gt; & Lt; Servlet category & gt; Com.tom.servlet.MyServlet & lt; / Servlet category & gt; & Lt; Load-On-Startup & gt; 1 & lt; / Load-on-startup & gt; & Lt; / Servlet & gt; & Lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; MyServlet & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / Servlet / myServlet / * & lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt; ]] & Gt; & Lt; / Insert & gt; & Lt; / Xmltask & gt; My question is how to find out whether the servlet is there or not, because I should refrain from inserting it twice. My xpath grammar does not seem right please help.
You tried to expose:
/ web-app / servlet [Servlet-name = 'myServlet'] / text () ... text text nodes that are direct label , Which is not present in the XML sample, if you are to return text nodes instead of Direct Child's & lt; Servlet-name & gt; , then XPath should do something like this: / web-app / servlet / servlet-name [ = 'MyServlet'] / text ()
Comments
Post a Comment