xmltask remove doesn't work

2.5k views Asked by At

I have this application.xml

<?xml version="1.0" encoding="UTF-8"?>
<application id="Application_1326308152661" version="1.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
   <description>MIC Server Application.</description>
   <module>
      <web> ...         
      </web>
   </module>
   <module>
      <ejb>mic-sqlbridge.jar</ejb>
   </module>
   <security-role> ...
   </security-role>
</application>

In this xml the part 'module' tag containing the tag ejb must be removed. To do this I tried

<xmltask source="application.xml" dest="application_X.xml"> 
   <remove path="/application/module[ejb/text() = 'mic-sqlbridge.jar']"/> 
</xmltask> 

Unfortunately this didn't remove anything - here's the log part:

[xmltask] Reading application.xml
[xmltask] Executing xmltask 1.16
[xmltask] Processing application.xml into application_X.xml
[xmltask] Using predefined xml catalog
[xmltask] Applying RemovalAction() to /application/module[ejb/text() = 'mic-sqlbridge.jar']
[xmltask] Applied RemovalAction() - 0 match(es)
[xmltask] RemovalAction() (/application/module[ejb/text() = 'mic-sqlbridge.jar']) failed to match
[xmltask] Normalizing resultant document

Any idea? Thanks in advance!

Frank

1

There are 1 answers

0
Frank Winkler On

Reading this brought me the solution: "Scoping each XML element name with a preceding ':' is sufficient to tell the XPath mechanism that you're interested in the local name of the element."

So the path statement

path="/application/module[ejb/text() = 'mic-sqlbridge.jar']"

becomes

path="/:application/:module[:ejb/text() = 'mic-sqlbridge.jar']"

what worked perfectly.