This works. Thanks for the help.
Without trying it (and I can do that later), your <copy> below
would be correct with append set to 'true', so you'd get a chain of
<context-param> elements. Your insert should be something
like:
<insert path="/web-app/display-name" position="after"
buffer="buf">
I believe that if you're copying from one doc and
pasting into another you should use something like:
<xmltask
source="src.xml"> <copy.... into
buffer> </xmltask> <xmltask source="dst.xml"
dest="dst.xml"> <insert
...> </xmltask>
Xmltask will copy from the source, modify and
insert into the dest document. Hence the first xmltask would simply copy into a
buffer, and the second loads the dest document, inserts into it and writes it
out.
Hopefully that's what you want. Please let me know if you're not
having any further joy and I can take a closer look.
Brian
Bruce
Thompson wrote:
How would I add
all the elements from the following web.xml file (source) into
an existing web.xml file (dest). The
existing (dest) has all the same element types as
the (source) web.xml file. Since it's a web.xml file and order of the elements
matters I simply cannot append one file to the other. I need to insert, for
example, all the <context-param> elements where the dest
<context-param> elements are.
For example I've
tried to insert the context-param elements but the dest file is
overwritten by the entire source file with only one context-param element (the
last context-param element in the source) appended at the end of the
file (but before the closing </web-app> tag). If I change append to
"true" then it fails on well formed xml document.
<xmltask source="${source}/wwwroot/WEB-INF/web.xml"
dest="${dest}/wwwroot/WEB-INF/web.xml"
report="true" > <copy path="//*[name()='context-param']" buffer="buf"
append="false" /> <insert path="/web-app" buffer="buf"
/> </xmltask>
<?xml version="1.0" encoding="UTF-8"?> <web-app>
<display-name>Application</display-name>
<context-param> <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> <param-value>com.ApplicationResources</param-value> </context-param>
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param>
<context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/log4j.properties</param-value> </context-param>
<filter> <filter-name>hibernateFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter>
<filter-mapping> <filter-name>hibernateFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <filter-mapping> <filter-name>hibernateFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping>
<listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
<servlet> <servlet-name>action</servlet-name> <servlet-class>com.sourcebeat.strutslive.common.SLActionServlet</servlet-class> <init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param>
<param-name>config/admin</param-name>
<param-value>/WEB-INF/struts-admin-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>
<!-- Action Servlet
Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping>
<!-- Struts Tag
Library Descriptors --> <taglib> <taglib-uri>/WEB-INF/tlds/struts-bean.tld</taglib-uri> <taglib-location>/WEB-INF/tlds/struts-bean.tld</taglib-location> </taglib>
<taglib> <taglib-uri>/WEB-INF/tlds/struts-html.tld</taglib-uri> <taglib-location>/WEB-INF/tlds/struts-html.tld</taglib-location> </taglib>
<taglib> <taglib-uri>/WEB-INF/tlds/struts-logic.tld</taglib-uri> <taglib-location>/WEB-INF/tlds/struts-logic.tld</taglib-location> </taglib>
</web-app>
--
Brian Agnew http://www.oopsconsultancy.com
OOPS Consultancy Ltd brian @ oopsconsultancy.com
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012
|