1
我使用Ant 1.8.4和xmltask 1.16。我試圖修改Maven pom.xml文件來檢查是否有/ project/properties元素,如果沒有(創建一個)以便我可以添加一個子元素。 xmltask documentation表示我必須使用副本任務來檢查,然後使用如果屬性上的插入任務。但是,當有一個現有的/項目/屬性節點xmltask測試是否存在沒有文本或屬性的節點
Can only copy/cut text() nodes and attribute values to properties (found com.sun.org.apache.xerces.internal.dom.DeferredElementNSImpl)
,並將其插入第二個屬性點使用此代碼
<xmltask source="${pomdir}/pom.xml" dest=""${pomdir}/pom.xml">
<copy path="/:project/:properties" property="hasProperties"/>
<insert path="/:project/:packaging" position="after" if="hasProperties"
xml="<properties>"/>
</xmltask>
生成此警告。在複製任務中將「/ text()」添加到xpath的末尾可以擺脫警告,但不會修復輸出中的重複屬性節點。