1) correct
2) looks like you've sorted it. Well done!
3) it's not ideal to run build.xml repeatedly against the same file, modifying it and writing it again. I advise you to have a source template file, and load/modify that and write it to a new file for each run. That way nothing will get duplicated. 4) I've not tried that. It would be interesting to see a *simple* demo of a failure.

Brian

On 13/08/2009 15:32, soumya sree kullu wrote:

Hi,

Thanks Brain, for the reply .. I have some doubts, request you to make me understand some features... A similar post is already posted by my team member couple of times ..excuses for resending it. Very thankful to them who help us in understanding the concepts in a good way ...

1) So for reading every appender , we need to set the appender into a variable as in the solution.

<param name="appender1" path="appender[1]/text()" />

<param name="appender2" path="appender[2]/text()" />


There is no way to get into a single variable ,If I'm wrong here ..please help me understand..

2 ) For replacing the value in a param value in appender node -

<appender class="org.apache.log4j.RollingFileAppender" name="a2">

<param name="File" value="uan.log"/>
<param name="Append" value="true"/>
<param name="MaxFileSize" value="*25000KB*"/>
<param name="MaxBackupIndex" value="5"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p %-15c{1} [%t][%x]: %m%n"/>
</layout>
</appender>

In my build-configuration file - it is like this now  -
----------------------------
<appenderupdates>
<appendername>a2</appendername>
<paramname>MaxFileSize</paramname>
<paramvalue>10000KB</paramvalue >
</appenderupdates>
------------------------------------

In my ant build file the following xml task is used for reading the values from build -configuration

<call path="/categoryset/appenderupdates" target="replacetask">
<param name="appendername" path="appendername/text()"/>
<param name="paramname" path="paramname/text()"/>
<param name="paramvalue" path="paramvalue/text()"/>
</call>

Replace task is -

<replace path="/log4j:configuration/append...@name='${testname}']/par...@name='${paramname}']...@value" withText="${paramvalue}"/>

The problem with the replace is , it is unable to find the correct match -
: <xmltask> subtasks failed to find matches was the error.

 I understand that xpath usage is wrong here ... how can i parse this ?

*The above question is solved using the attr xmltask - *
*<attr path="/log4j:configuration/append...@name='${appendername}']/par...@name='${paramname}']" attr="value" value='${paramvalue}'/>*

3) And when i run my ant build.xml repeatedly then it creates the same set of appenders and categories again and again , is there a way that we can stop the same appenders and categories writing again and again into myweb.xml file.

4) Can we call xml task inside another call xml task . I tried this feature for a scenario but it failed....

regards,
soumya ..


------------------------------------------------------------------------
*From:* Brian Agnew <br...@oopsconsultancy.com>
*To:* soumya sree kullu <soumyasree...@yahoo.co.in>
*Cc:* xmltask-users@lists.sourceforge.net
*Sent:* Tuesday, 11 August, 2009 3:29:16 PM
*Subject:* Re: XML Task Help

1) why not use something like:

<call path="/categoryset/category/appender/" target="..."/>

to process every appender ? You may have to do this separately from setting the name.

2) Your <replace> doesn't work. Can you post how you're using it (the one-liner <replace>), pls ?

Brian

On 11/08/2009 14:03, soumya sree kullu wrote:
Hi ,

I am using xml task for dynamically adding log4j appenders and categories in my web.xml ,

My solution goes  like this -

 my web.xml is
----------------------------

<?xml version="1.0" encoding="UTF-8"?>
<root>
<priority value="fatal"/>
</root>
</log4j:configuration>
-------------------------------------------

I want to add the appenders and categories to the above xml file. hence I used xml task in my ant build.xml file , by reading the appenders and category names through a configuration file like this -


Build-configuration file

-----------------------------------

<?xml version="1.0"?>

<categoryset>

<category >

<testname>Category1</testname>

<appender>A1</appender>

<appender>B1</appender>

<appender>C1</appender>

</category>

<category >

<testname>Category2</testname>

<appender>a2</appender>

<appender>b2</appender>

<appender>c2</appender>

</category>

<appenderfilesize>

<testname>a2</testname>

<MaxFileSize>10000KB</MaxFileSize >

</appenderfilesize>

</categoryset>

-------------------------------------

In the ant build.xml file I use xml task to add appenders and categories that adds to my web.xml , like this-

In the ant build.xml file

--------------------------------

<target name="main" depends="testprg"/>

<property name="web.xmlfile" value="C:/test/web.xml" />

<target name="testprg">

<xmltask source="build-configuration.xml">

<call path="/categoryset/category" target="roottest">

<param name="name" path="testname/text()" />

<param name="appender1" path="appender[1]/text()" />

<param name="appender2" path="appender[2]/text()" />

<param name="appender3" path="appender[3]/text()" />

</call>

<call path="/categoryset/catego...@testname]/appender" target="compile-and-release">

<param name="build" path="text()"/>

</call>


</xmltask>

</target>

<target name="roottest" >

<echo>Building Category ${name}</echo>

<echo>Appender ${appender1}</echo>

<echo>Appender ${appender2}</echo>

<echo>Appender ${appender3}</echo>

<xmltask source="${web.xmlfile}" dest="${web.xmlfile}" failWithoutMatch="true">

<insert path="/log4j:configuration/root" position="after">

<![CDATA[ <category name="${name}">

<priority value="debug" />

<appender-ref ref="${appender1}" />

<appender-ref ref="${appender2}" />

<appender-ref ref="${appender3}" />

</category> ]]>

</insert>

</xmltask>

</target>

<target name="compile-and-release">

<xmltask source="${web.xmlfile}" dest="${web.xmlfile}" failWithoutMatch="true">

<insert path="/log4j:configuration/root" position="after">

<![CDATA[

<appender name="${build}" class="org.apache.log4j.RollingFileAppender">

<param name="File" value="uan.log" />

<param name="Append" value="true" />

<param name="MaxFileSize" value="25000KB" />

<param name="MaxBackupIndex" value="5"/>

<layout class="org.apache.log4j.PatternLayout">

<param name="ConversionPattern" value="%d{DATE} %-5p %-15c{1} [%t][%x]: %m%n"/>

</layout>

</appender>

]]>

</insert>

</xmltask>

-----------------------------------------------------

The above solution works fine until i know the number of appenders, but -

I dont want to mention the array notation of appenders in xml task , ie.

<call path="/categoryset/category" target="roottest">

<param name="name" path="testname/text()" />

<param name="appender1" path="appender[1]/text()" />

<param name="appender2" path="appender[2]/text()" />

<param name="appender3" path="appender[3]/text()" />

</call>



as the appenders are not static , they may increase or decrease under a category. I want to implement some looping kind of mechanism which actually reads the category and then loop through the appenders which creates nodes under category like - and should get the same output into web.xml like what the solution does now...i.e.

<category name="Category2">

<priority value="debug"/>

<appender-ref ref="a2"/>

<appender-ref ref="b2"/>

<appender-ref ref="c2"/>

</category>


Is there a way ?

2 )  I facing some problems in replacign the value in the xml node..

Using build-configuration file . I read the max-file size but it doesnt work
------------------------------------

<appenderfilesize>

<testname>a2</testname>

<MaxFileSize>10000KB</MaxFileSize >

</appenderfilesize>

--------------------------

<appender class="org.apache.log4j.RollingFileAppender" name="a2">

<param name="File" value="uan.log"/>

<param name="Append" value="true"/>

<param name="MaxFileSize" value="*25000KB*"/>

<param name="MaxBackupIndex" value="5"/>

<layout class="org.apache.log4j.PatternLayout">

<param name="ConversionPattern" value="%d{DATE} %-5p %-15c{1} [%t][%x]: %m%n"/>

</layout>

</appender>

The value has to be changed to 10000KB , i was using replace xmltask but didnt succeed..

can anyone please help me out in solving the issues ... ??will be so thankful to them ..

soumya


------------------------------------------------------------------------
Love Cricket? Check out live scores, photos, video highlights and more. Click here <http://in.rd.yahoo.com/tagline_cricket_2/*http://cricket.yahoo.com>.

--
Brian Agnewhttp://www.oopsconsultancy.com
OOPS Consultancy Ltd
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012
------------------------------------------------------------------------
Love Cricket? Check out live scores, photos, video highlights and more. Click here <http://in.rd.yahoo.com/tagline_cricket_2/*http://cricket.yahoo.com>.

------------------------------------------------------------------------
Love Cricket? Check out live scores, photos, video highlights and more. Click here <http://in.rd.yahoo.com/tagline_cricket_2/*http://cricket.yahoo.com>.
------------------------------------------------------------------------

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
------------------------------------------------------------------------

_______________________________________________
Xmltask-users mailing list
Xmltask-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xmltask-users

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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Xmltask-users mailing list
Xmltask-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xmltask-users

Reply via email to