You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Anand Krishniyer <ak...@savvion.com> on 2005/06/29 04:06:27 UTC

xmltask question

Hi
I have an xml file that has different paths for each file. Something 
like this
<files>
  <file name="a.jar" type="jar">
      <Location>"c:/1"</Location>
      <Location>"c:/2"</Location>
  </file>
  <file name="b.conf" type="conf">
      <Location>"e:/1"</Location>
      <Location>"e:/2"</Location>
      <Location>"e:/3"</Location>
  </file>  
</files>

I use XmlTask to iteratively get each location for each file (I use 
"call" to call another target for each location for each file). The 
problem is I get the location as a string, I need it as a path to 
process further.
For e.g I need to copy a.jar to both c:\1 and c:\2 locations. But when I 
use

<xmltask>
    <call path="files/file[@name='${jarfilename}']/Location" 
target="DiffTarget">
        <param name="filename" path="../@name"/>
        <param name="val" path="text()"/>
      </call>   
    </xmltask>

I get the "val" as string, how do I get it as path?

Thanks in advance.

Regards
Anand

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: xmltask question failWithMatch?

Posted by Anand Krishniyer <ak...@savvion.com>.
Hi
how to fail  a build if a particular node(or attribute of a node) is 
present/matches in the xml. For e,g

       <xmltask source="${sbm.patches.conf.dir}/sbm-patches.xml">
        <call path="sbm-patches/sbm-patch[@id='${patch.id}']" 
target="PatchExistsError" inheritAll="true" inheritRefs="true">
            <param name="patchid" path="@id"/>
        </call>
        </xmltask>

In PatchExistsError I want to print an error message and fail.
<target name="PatchExistsError">
        <echo message="Patch ${patchid} is already applied. pl remove 
the patch and then reapply."/>
       <!-- NEED TO FAIL HERE-->
    </target>
If I make it fail here the Xmltask throws an exception which I don't 
want the user to see. I am not able to suppress this exception with 
trycatch task either.

Basically I want to make the build fail if there is a match in the xml 
(opposite of failWithoutMatch attribute in the Xmltask).

Thanks
Anand


Brian Agnew wrote:

> Cool. Thx for the update.
>
> Anand Krishniyer wrote:
>
>> Hi Brian
>> Found the problem I was having. The locations in the XML had quotes 
>> in them, thats why I was getting the as string. Removed the quotes 
>> and it works fine.
>>
>> Thanks a lot anyways.
>>
>> Regards
>>
>> Anand
>>
>>
>> Brian Agnew wrote:
>>
>>> So you end up copying to ${val} ? Can you send me your complete 
>>> build.xml (or at least the relevant bits)
>>>
>>> Anand Krishniyer wrote:
>>>
>>>> What I meant was I can't copy the file to the location using 'val'
>>>>
>>>> <copy todir="${val} file="${filename}"/>
>>>>
>>>> Brian Agnew wrote:
>>>>
>>>>> Sorry. Not sure I understand this. You get val as "e:/3", say ?
>>>>>
>>>>> Anand Krishniyer wrote:
>>>>>
>>>>>> Hi
>>>>>> I have an xml file that has different paths for each file. 
>>>>>> Something like this
>>>>>> <files>
>>>>>>  <file name="a.jar" type="jar">
>>>>>>      <Location>"c:/1"</Location>
>>>>>>      <Location>"c:/2"</Location>
>>>>>>  </file>
>>>>>>  <file name="b.conf" type="conf">
>>>>>>      <Location>"e:/1"</Location>
>>>>>>      <Location>"e:/2"</Location>
>>>>>>      <Location>"e:/3"</Location>
>>>>>>  </file>  </files>
>>>>>>
>>>>>> I use XmlTask to iteratively get each location for each file (I 
>>>>>> use "call" to call another target for each location for each 
>>>>>> file). The problem is I get the location as a string, I need it 
>>>>>> as a path to process further.
>>>>>> For e.g I need to copy a.jar to both c:\1 and c:\2 locations. But 
>>>>>> when I use
>>>>>>
>>>>>> <xmltask>
>>>>>>    <call path="files/file[@name='${jarfilename}']/Location" 
>>>>>> target="DiffTarget">
>>>>>>        <param name="filename" path="../@name"/>
>>>>>>        <param name="val" path="text()"/>
>>>>>>      </call>      </xmltask>
>>>>>>
>>>>>> I get the "val" as string, how do I get it as path?
>>>>>>
>>>>>> Thanks in advance.
>>>>>>
>>>>>> Regards
>>>>>> Anand
>>>>>>
>>>>>
>>>>
>>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org