I'm not sure the below is a *small* example :-) (I have to keep
chopping the below to stop Sourceforge mailer's complaining). I would
cut it down and try to determine which particular expression is
causing you grief. I've just extracted your (count) XPath and ran a
quick test and I think that looks good.
Note that if you're using xmltask to simply populate a property, you
can simply specify a source file. You don't need a destination file
(XMLTask will write out the same doc as it loaded in, which is a bit
excessive)
On 14/08/2009 12:07, Adithya V.S.S wrote:
Hi brian,
it fails while parsing the count ...xml task
i am pasting a small example here --
My build.xml file
-------------------------------
<?xml version="1.0"?>
<project name="java.net <http://java.net>" default="main" basedir=".">
<taskdef name="xmltask"
classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>
<taskdef name="if" classname="ise.antelope.tasks.IfTask"/>
<!-- run all examples -->
<target name="main" depends="testprg,repeattask"/>
<property name="weblogic.home.cfgfile" value="C:/test1.xml" />
<!-- a calling example -->
<target name="testprg">
<xmltask source="build-configuration.xml">
<call path="/categoryset/category" target="compile-and-release">
<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>
</xmltask>
</target>
<!-- the build target for ex12 -->
<target name="compile-and-release">
<echo>Building ${name}</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="${appender1}" />
<appender-ref ref="${appender2}" />
<appender-ref ref="${appender3}" />
</category> ]]>
</insert>
</xmltask>
</target>
<target name="repeattask">
<xmltask source="${weblogic.home.cfgfile}"
dest="${weblogic.home.cfgfile}" failWithoutMatch="true">
<copy path="count(/log4j:configuration/category/[...@name='Category3'])"
property="count"/>
</xmltask>
<echo>Building ${count}</echo>
<if name="count" value="0">
<antcall target="doUnitTests"/>
<else>
<echo>this won't happen</echo>
</else>
</if>
</target>
<target name="doUnitTests">
<xmltask source="${weblogic.home.cfgfile}"
dest="${weblogic.home.cfgfile}" failWithoutMatch="true">
<insert path="/log4j:configuration/root" position="after" >
<![CDATA[ <category name="com.bea.wli.event">
<priority value="debug" />
<appender-ref ref="RDBMS_EG_LOGFILE_DEBUG"/>
</category> ]]>
</insert>
</xmltask>
</target>
</project>
------------------------
My build-configuration file
-------------------------
<?xml version="1.0"?>
<categoryset>
<category testname="testing">
<testname>Category1</testname>
<appender>development</appender>
<appender>systemtest</appender>
<appender>production</appender>
</category>
<category testname="test">
<testname>Category2</testname>
<appender>DEV</appender>
<appender>TEST</appender>
<appender>PROD</appender>
</category>
</categoryset>
-------------------------------
my test1.xml
---------------------
<?xml version="1.0" encoding="UTF-8"?>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="null" threshold="null">
<root>
<priority value="fatal"/>
</root>
<category name="com.bea.wli.event">
<priority value="debug"/>
<appender-ref ref="RDBMS_EG_LOGFILE_DEBUG"/>
</category>
<category name="Category3">
<priority value="debug"/>
<appender-ref ref="UAT"/>
<appender-ref ref="${appender2}"/>
<appender-ref ref="${appender3}"/>
</category>
<category name="Category2">
<priority value="debug"/>
<appender-ref ref="DEV"/>
<appender-ref ref="TEST"/>
<appender-ref ref="PROD"/>
</category>
<category name="Category1">
<priority value="debug"/>
<appender-ref ref="development"/>
<appender-ref ref="systemtest"/>
<appender-ref ref="production"/>
</category>
</log4j:configuration>
------------------------------------
Is this syntax wrong ?
<copy path="count(/log4j:configuration/category/[...@name='Category3'])"
property="count"/>
as used above...
error is -
-------------------
repeattask:
*[xmltask] javax.xml.transform.TransformerException: A location step
was expected following the '/' or '//' token.*
[xmltask] at
com.sun.org.apache.xpath.internal.compiler.XPathParser.error(XPathParser.java:602)
[xmltask] at
com.sun.org.apache.xpath.internal.compiler.XPathParser.RelativeLocationPath(XPathParser.java:1579)
Thanks.
adi
--
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