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/08/18 22:25:15 UTC
how to resolve a path from a XML file (XMLTask)
Hi
I am trying to read a path from an XML file.
For e.g here is an XML
<a>
<b src="${myapp1.dir}/common/jsp" target="${myapp2.dir}/common/jsp"/ >
<b src="${myapp3.dir}/common/jsp" target="${myapp4.dir}/common/jsp"/ >
</a>
And the section of the ant build file looks like this
<loadproperties srcFile="c:/myappdir/conf/sbm.conf"/>
<xmltask source="myXMLFile.xml">
<call path="a/b" target="package-Resources"
inheritAll="true" inheritRefs="true">
<param name="src" path="@src"/>
</call>
</xmltask>
The values of the variables myapp1.dir, myapp2.dir, myapp3.dir,
myapp4.dir are available in the sbm.conf file and are loaded correctly.
When I read the src from the xml file, the full patch for ${src}doesn't
get resolved. The ${src} remains as ${myapp1.dir}/common/jsp. How to
resolve this a correct path?
Any help would be greatly appreciated.
Regards
Anand
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: how to resolve a path from a XML file (XMLTask)
Posted by Anand Krishniyer <ak...@savvion.com>.
Thanks Brian
In my case i don't know the number elements <b> in the XML (it can vary)
for. e.g
I can have
<a>
<b src="${myapp1.dir}/common/jsp" target="${myapp2.dir}/common/jsp"/ >
<b src="${myapp1.dir}/common/jsp" target="${myapp4.dir}/common/jsp"/ >
<b src="${myapp2.dir}/common/jsp" target="${myapp5.dir}/common/jsp"/ >
<b src="${myapp2.dir}/common/jsp" target="${myapp5.dir}/common/jsp"/ >
</a>
or just
<a>
<b src="${myapp1.dir}/common/jsp" target="${myapp2.dir}/common/jsp"/ >
</a>
Brian Agnew wrote:
> This isn't really an xmltask issue (in which case
> xmltask-users@lists.sourceforge.net is the list to point to). xmltask
> will just read your XML file 'as is'. However you can solve the below
> using xmltask using something like (and I haven't tested this but it
> should give you an idea):
>
> <xmltask source="myXMLFile.xml" ..... >
> <attr path="/a/b[1]" attr="src" value="${myapp1}/common.jsp"/>
> <attr path="/a/b[2]" attr="src" value="${myapp3}/common.jsp"/>
>
> and so on, prior to using the <call> instruction.
>
> Anand Krishniyer wrote:
>
>> Hi
>> I am trying to read a path from an XML file.
>> For e.g here is an XML
>>
>> <a>
>> <b src="${myapp1.dir}/common/jsp"
>> target="${myapp2.dir}/common/jsp"/ >
>> <b src="${myapp3.dir}/common/jsp"
>> target="${myapp4.dir}/common/jsp"/ >
>> </a>
>>
>> And the section of the ant build file looks like this
>>
>> <loadproperties srcFile="c:/myappdir/conf/sbm.conf"/>
>>
>> <xmltask source="myXMLFile.xml"> <call
>> path="a/b" target="package-Resources" inheritAll="true"
>> inheritRefs="true">
>> <param name="src" path="@src"/>
>> </call>
>> </xmltask>
>>
>> The values of the variables myapp1.dir, myapp2.dir, myapp3.dir,
>> myapp4.dir are available in the sbm.conf file and are loaded
>> correctly. When I read the src from the xml file, the full patch for
>> ${src}doesn't get resolved. The ${src} remains as
>> ${myapp1.dir}/common/jsp. How to resolve this a correct path?
>>
>> Any help would be greatly appreciated.
>>
>> Regards
>> Anand
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: how to resolve a path from a XML file (XMLTask)
Posted by Brian Agnew <br...@oopsconsultancy.com>.
This isn't really an xmltask issue (in which case
xmltask-users@lists.sourceforge.net is the list to point to). xmltask
will just read your XML file 'as is'. However you can solve the below
using xmltask using something like (and I haven't tested this but it
should give you an idea):
<xmltask source="myXMLFile.xml" ..... >
<attr path="/a/b[1]" attr="src" value="${myapp1}/common.jsp"/>
<attr path="/a/b[2]" attr="src" value="${myapp3}/common.jsp"/>
and so on, prior to using the <call> instruction.
Anand Krishniyer wrote:
> Hi
> I am trying to read a path from an XML file.
> For e.g here is an XML
>
> <a>
> <b src="${myapp1.dir}/common/jsp" target="${myapp2.dir}/common/jsp"/ >
> <b src="${myapp3.dir}/common/jsp" target="${myapp4.dir}/common/jsp"/ >
> </a>
>
> And the section of the ant build file looks like this
>
> <loadproperties srcFile="c:/myappdir/conf/sbm.conf"/>
>
> <xmltask source="myXMLFile.xml"> <call
> path="a/b" target="package-Resources" inheritAll="true"
> inheritRefs="true">
> <param name="src" path="@src"/>
> </call>
> </xmltask>
>
> The values of the variables myapp1.dir, myapp2.dir, myapp3.dir,
> myapp4.dir are available in the sbm.conf file and are loaded
> correctly. When I read the src from the xml file, the full patch for
> ${src}doesn't get resolved. The ${src} remains as
> ${myapp1.dir}/common/jsp. How to resolve this a correct path?
>
> Any help would be greatly appreciated.
>
> Regards
> Anand
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
--
Brian Agnew http://www.oopsconsultancy.com
OOPS Consultancy Ltd brian @ oopsconsultancy.com
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: how to resolve a path from a XML file (XMLTask)
Posted by Anand Krishniyer <ak...@savvion.com>.
Okay let me explain a bit more.
I have to read a path from an XML. The XML is constructed by somebody
else and he/she knows the path relative to a root dir only.
So the path in the XML can be ${myapp1.dir}/common/jsp.
The build script that reads this XML can resolve this myapp1.dir dir.
So is it possible to use a variable in the XML and resolve the entire
path after getting the path from the XML.
Any pointers would be helpful.
Anand
Anand Krishniyer wrote:
> Hi
> I am trying to read a path from an XML file.
> For e.g here is an XML
>
> <a>
> <b src="${myapp1.dir}/common/jsp" target="${myapp2.dir}/common/jsp"/ >
> <b src="${myapp3.dir}/common/jsp" target="${myapp4.dir}/common/jsp"/ >
> </a>
>
> And the section of the ant build file looks like this
>
> <loadproperties srcFile="c:/myappdir/conf/sbm.conf"/>
>
> <xmltask source="myXMLFile.xml"> <call
> path="a/b" target="package-Resources" inheritAll="true"
> inheritRefs="true">
> <param name="src" path="@src"/>
> </call>
> </xmltask>
>
> The values of the variables myapp1.dir, myapp2.dir, myapp3.dir,
> myapp4.dir are available in the sbm.conf file and are loaded
> correctly. When I read the src from the xml file, the full patch for
> ${src}doesn't get resolved. The ${src} remains as
> ${myapp1.dir}/common/jsp. How to resolve this a correct path?
>
> Any help would be greatly appreciated.
>
> Regards
> Anand
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org