개미 스크립트를 사용하여 프로그래밍 방식으로 XML 청크를 제거하고 싶습니다. 멋진 xmltask 작업을 찾았지만 나를 살기 위해 삭제하려는 resource-ref
노드를 찾을 수 없습니다.Ant 스크립트에서 resource-ref XML 태그 찾기
내 XML 문서가 어떻게 생겼는지에 대한 하위 섹션이 있습니다. 나는이 같은 두 번째 resource-ref
덩어리를 제거하기 위해 노력하고있어
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="WebApp_ID"
version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>Foo</display-name>
<resource-ref>
<description>Something Clever</description>
<res-ref-name>jdbc/foo1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Reports Database</description>
<res-ref-name>jdbc/foo2</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
:
<project name="test" basedir="." default="fixxml">
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>
<target name="fixxml" description="er doy">
<xmltask source="web.xml" dest="output.xml">
<remove path="/web-app/resource-ref/description[text()='Reports Database']" />
</xmltask>
</target>
</project>
그러나, 그것은 작동하지 않습니다 그것은 표준 DTD를 사용하는 web.xml
파일입니다. 또한 다음 remove
진술을 시도했습니다.
<remove path="/web-app/resource-ref[2]" />
....
<remove path="//description[text()[normalize-space(.)='Reports Database']]"" />
아무도 작동하지 않았습니다. 아무도 내가 내 쿼리에 잘못을 저지르고있는 것을 볼 수 있습니까?
확인 http://stackoverflow.com/questions/10096332/replacing-an-entire-xml-tag-using-ant – Maverick
제안 해 주셔서 감사합니다.하지만이 옵션도 나에게 적합하지 않습니다. –