If you want xmltask to fail on no xpath match, you can set the 'failWithoutMatch' flag and xmltask will fail the build appropriately.

Cheers,

Brian

Lucian Liviu Furtos wrote:

Thank you very much. It works, the problem was the use of namespace and the xml didn’t throw any error or warning.

If any body is interested on how it should look my xpath query:

 

        <xmltask source="${basedir}/ejb-jar.xml" dest="${basedir}/ejb-jar.xml">

            <replace path="//*[local-name()='env-entry-name' and text()='ConfigurationFolder']/parent::*[1]/*[local-name()='env-entry-value']/text()" withText="WORKS!!"/>

            <replace path="//*[local-name()='env-entry-name' and text()='ScanInterval']/parent::*[1]/*[local-name()='env-entry-value']/text()" withText="777"/>

        </xmltask>

 

 All the best, Lucian!

 


From: Brian Agnew [mailto:brian@oopsconsultancy.com]
Sent: 24 martie 2005 11:17
To: Lucian Liviu Furtos
Cc: xmltask-users@lists.sourceforge.net.
Subject: Re: [Xmltask-users] problem parsing xml with schema

 

Without more detailed info I suspect you have a naming issue (I haven't validated your xpath references below). From the examples page:

Identifying elements with namespaces. This example copies the
node element which is tied to a namespace via an xmlns directive. See this XML.com article for namespace-related issues.

    <xmltask source="input.xml">
      <copy path="//*[local-name()='node']" property="count"/>
        ...
 
 
  

So that may be of relevance. If not, can you forward any exceptions or errors that xmltask is giving you ?

Cheers,

Brian

Lucian Liviu Furtos wrote:

Hello,

 

 I have a problem parsing an ejb-jar.xml with xmltask. It has a long schema definition. If I remove that definition everything is working fine. Can you tell me what is the problem?

 

 This is some part of ejb-jar.xml :

 

 <?xml version="1.0" encoding="UTF-8"?>

 

<ejb-jar 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/ejb-jar_2_1.xsd" version="2.1">

 

   <description><![CDATA[No Description.]]></description>

   <display-name>Generated by XDoclet</display-name>

 

   <enterprise-beans>

 

      <!-- Session Beans -->

      <session>

         <description><![CDATA[Description for AccountingImporter]]></description>

         <display-name>AccountingImporter</display-name>

………………………..

 

 And the script:

 

        <xmltask source="${basedir}/${temp.module.dir}/ejb-jar.xml" dest="${basedir}/${temp.module.dir}/ejb-jar.xml">

            <replace path="//env-entry-name[text()='ConfigurationFolder']/parent::*[1]/env-entry-value/text()" withText="CONFIGDIR"/>

            <replace path="/ejb-jar/enterprise-beans/session/env-entry/env-entry-name[text()='ScanInterval']/parent::*[1]/env-entry-value/text()" withText="SCAN INTERVAL"/>

        </xmltask>



-- 
Brian Agnew                  http://www.oopsconsultancy.com
OOPS Consultancy Ltd         brian @ oopsconsultancy.com
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012

-- 
Brian Agnew                  http://www.oopsconsultancy.com
OOPS Consultancy Ltd         brian @ oopsconsultancy.com
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012