There have been a number of questions here and on the web about getting
namespaces to work correctly during something like an <insert>
task. I, too, was experiencing this problem and finally came up with a
work-around.
The scenario is that I want to set up the jndi for Spring using xmltask.
First, I define the jndi and use a keyword of REPLACE at the beginning of the
property
<var name="jndi.merge.data"
value="<REPLACE
id="application.datasource"
jndi-name="${database.jndi}" />" />
Then, I use xmltask to do the insert. I put this into its own file ending with
'_modified'. Notice the /:beans
<xml
dest="${target.web.content.dir}/WEB-INF/spring/applicationContext-dataSource_modified.xml"
outputter="default"
source="${target.web.content.dir}/WEB-INF/spring/applicationContext-dataSource.xml">
<insert path="/:beans"
xml="${jndi.merge.data}" />
</xml>
This results in output like this in the file:
<REPLACE id="application.datasource" jndi-name="jdbc/ptt_jndi" xmlns=""/>
Finally, I use copy and filterset to replace some of the unwanted pieces left
over (REPLACE and xmnls="")
<copy
file="${target.web.content.dir}/WEB-INF/spring/applicationContext-dataSource_modified.xml"
tofile="${target.web.content.dir}/WEB-INF/spring/applicationContext-dataSource.xml"
overwrite="true">
<filterset begintoken="<" endtoken=" ">
<filter token="REPLACE" value="<jee:jndi-lookup " />
</filterset>
<filterset begintoken=" " endtoken="/">
<filter token="xmlns=""" value=" /" />
</filterset>
</copy>
Resulting in output like this in the file:
<jee:jndi-lookup id="application.datasource" jndi-name="jdbc/ptt_jndi" />
I hope this helps others who might be experiencing the same issues.
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Xmltask-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmltask-users