1) that insert will run multiple times because you're (I suspect) loading up as the source the same file that is your destination. I would maintain a file as your initial source and always write to a different destination file. That way <xmltask> will always do the same thing.

e.g. <xmltask source="a.xml" dest="a-out.xml"/>

and you'd then use a-out.xml further on.

2) If you use

<remove path="/log4j:configuration/category"/>

then that will identify *all* category subnodes in your XML and remove all of these.

Hope that helps!

Brian

Adithya V.S.S wrote:
Thank you Brian, Your inputs are really helpful.
I have some queries, please help me understand to solve them - 1) When I run the build.xml file multiple times Insert writes into file that many times, Can we control in writing the same data again and again into the destination file on multiple runs. In specific, I use insert task to write the data into the destination file (workshopLogCfg.xml). When I run the build.xml again it again writes the same entries into the destination file. I tried using the property - <insert if="true" path="/root" position="after" file="build-configuration.xml"/> Still it wrote the data into the file. can we control this ..? 2) I am using the remove task to remove an category tag in the workshopLogCfg.xml, Usually i write the syntax as follows., <remove path="/log4j:configuration/catego...@name='Category2']"/> -- to remove category 2 in workshopLogcfg.xml I have many categories to remove and for each remove i write this syntax in build.xml <remove path="/log4j:configuration/catego...@name='Category1']"/>
<remove path="/log4j:configuration/catego...@name='Category2']"/>
<remove path="/log4j:configuration/catego...@name='Category3']"/>
Can the 'CategoryX' be populated dynamically by reading the source instead i hardcode the value? if my source has a tags like - <delete>
<categoryname>Category1</categoryname>
<categoryname>Category2</categoryname>
<categoryname>Category3</categoryname>
<appender>DEV</appender>
</delete>
Thanks for all the inputs , regards.
adithya
On Tue, Mar 24, 2009 at 11:34 AM, Brian Agnew <br...@oopsconsultancy.com <mailto:br...@oopsconsultancy.com>> wrote:

    I think you need something like:

                        <call path="/buildset/builds/" target="roottest">
                            <param name="name" path="testname/text()" />
                             <param name="appender1"
    path="build[1]/text()" />
                             <param name="appender2"
    path="build[2]/text()" />
                             <param name="appender3"
    path="build[3]/text()" />
                          </call>

    2 things. 1) the parameter XPaths are relative to the node
    identified by <call>. 2) you can't easily pass a list as a
    parameter, hence the multiple further parameters.

    Brian


    On 23/3/09 22:04, Adithya V.S.S wrote:

I'm a newbie to the XML Tasks and I appreciate the help that I am
    getting from Brain, Thank you for the answers.
I am doing some example , Stuck at only one point . Request you
    to help me out.. .
My build-configuration
    ===================
    <buildset>
    <builds testname="testing">
      <testname>Category1</testname>
      <build>development</build>
      <build>systemtest</build>
      <build>production</build>
</builds> <builds testname="test">
      <testname>Category2</testname>
      <build>DEV</build>
      <build>TEST</build>
      <build>PROD</build>
</builds> </buildset> My build.xml file is like this -
    ---------------------------------------
    <?xml version="1.0"?>
    <project name="java.net <http://java.net/>" default="main"
    basedir=".">
      <taskdef name="xmltask"
    classname="com.oopsconsultancy.xmltask.ant.XmlTask">
     <classpath path="xmltask.classpath" />
    </taskdef>
<target name="main" depends="testprg"/>
        <property name="weblogic.home.cfgfile"
    value="C:/bea/weblogic81/common/lib/workshopLogCfg.xml" />
<target name="testprg">
                     <xmltask source="build-configuration.xml">
                        <call path="/buildset/builds/testname"
    target="roottest">
                         <param name="name" path="text()" />
                             <param name="appenders"
    path="/buildset/builds/build/text()" />
                              </call>
<call path="/buildset/buil...@testname]/build"
    target="compile-and-release">
              <param name="build" path="text()"/>
                   </call>
              </xmltask>
               </target>
<target name="roottest" >
                 <echo>Building Category ${name}</echo>
                 <echo>Category Name ${appenders}</echo>
<echo>Appender ${appenders}</echo>
                <xmltask source="${weblogic.home.cfgfile}"
    dest="${weblogic.home.cfgfile}" failWithoutMatch="true">
<insert path="/log4j:configuration/root"
    position="after">
                <![CDATA[ <category name="${name}">
                <priority value="debug" />
                <appender-ref ref="${appenders}"
    />                                 //  Here I should get multiple
appenders.. for each build in each builds node </category> ]]> for eg: My Category Nodes should contain these appenders.. </insert> Category1 Category2 <appender-ref ref="development"/> <appender-ref ref="DEV"/> </xmltask> <appender-ref ref="systemtest"/> <appender-ref ref="TEST"/> </target> <appender-ref ref="production"/> <appender-ref ref="TEST"/> <target name="compile-and-release">
            <echo>Building ${build}</echo>
               <echo>${weblogic.home.cfgfile}</echo>
<xmltask source="${weblogic.home.cfgfile}"
    dest="${weblogic.home.cfgfile}" 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>
</target> </project> When I run this build.xml it writes the above insert data into
    workshopLogCfg.xml, And when I see the xml file it has only one
    appender <appender-ref ref="PROD"/> ,
    instead of three appenders as mentioned above for a builds node.
    Can we manipulate this in XMLTask, also when I run the build .xml
    it creates duplicate entries.. Is there any way to escape from
    writing the same data into the xml on further runs.
any solution is greatly appreciated. .. -- Adithya V.S.S
    ------------------------------------------------------------------------

    
------------------------------------------------------------------------------
    Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
    powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
    easily build your RIAs with Flex Builder, the Eclipse(TM)based development
    software that enables intelligent coding and step-through debugging.
    Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
    ------------------------------------------------------------------------

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

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



--
Adithya V.S.S
------------------------------------------------------------------------

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

_______________________________________________
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

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

Reply via email to