0

I have the following xml block (a standard jboss web.xml file) :

<web-app>
  <servlet>
    <init-param>
      <param-name>checkInterval</param-name>
      <param-value>-1</param-value>
    </init-param>
    <init-param>
      <param-name>reloading</param-name>
      <param-value>false</param-value>
    </init-param>
    .
    .
    .
  </servlet>
</web-app>

i want to select <param-value> of <init-param> with <param-name>=checkInterval and copy it. there are multiple (different) <init-params> so i need to choose it dynamically.

I have tried the following:

<target name="default" description="description">       
        <xmltask source="web.xml" dest="web_edited.xml">
            <copy path='/web-app/servlet/init-param[param-name="checkInterval"]/param-value/text()' property='property1' />     
        </xmltask>
        <echo>${property1}</echo>

</target>

expected result is -1, but instead the property is undefined. any idea ?

Michael
  • 22,196
  • 33
  • 132
  • 187
  • apparently the problem was that the document contained multiple XML namespaces. that is in the definition: ` Application Display Name .... ` so ` `becomes ` ` – Michael Jan 09 '12 at 12:43
  • more information on this can be found here : http://today.java.net/pub/a/today/2006/11/01/xml-manipulation-using-xmltask.html – Michael Jan 09 '12 at 12:43

1 Answers1

2

Your XPath works fine for me, so I suspect this is a problem with ant (sorry, don't know much about that).

I have one suggestion, though: Try knocking off the 'text()' bit from the end? It's possible that it's typing -1 as a number.

Tom Hillman
  • 327
  • 1
  • 10
  • you are right, xpath is okay, the problem was with the ant task indeed that did not handle the multiple namespaces. – Michael Jan 09 '12 at 12:45