You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Suu Quan <sq...@wwc.com> on 2001/05/21 22:21:55 UTC

regexp mapper problem

Same old newbie speaking

I tried this simple mapper that is the equivalent of 'copy all files,
prepending 'TUTU' in front of the filename
<target name='regexp'> <!-- there is a syntax error somewhere -->
      <copy todir="./mapper/regexp">
      <mapper type="regexp" from="^(.*)$$" to="TUTU\1"/>
      <fileset dir="/stp/stpd">
      </fileset>
      </copy>
</target>

What I get is
BUILD FAILED

C:\comrec\Ant\mapper.xml:41: No supported regular expression matcher found

property information
ant.java.version (JVM version used by Ant) = 1.3
os.name         = Windows 2000
java.vm.version = 1.3.0_02

thanks in advance


Re: regexp mapper problem

Posted by Stefan Bodewig <bo...@apache.org>.
Suu Quan <sq...@wwc.com> wrote:

> But I have ant.jar in my classpath, and "jar tf ant.jar" gives me
>     org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.class
>     org/apache/tools/ant/util/regexp/RegexpMatcher.class
>     org/apache/tools/ant/util/regexp/RegexpMatcherFactory.class
>     org/apache/tools/ant/util/RegexpPatternMapper.class
> 
> which is what the docs says.
> 
> "The regexp mapper needs a supporting library and an implementation
> of org.apache.tools.ant.util.regexp.RegexpMatcher

Right, please see the *and* in the sentence above.

You have "an implementation of
org.apache.tools.ant.util.regexp.RegexpMatcher" (two, one for
Jakarata-ORO and one for Jakarta-Regexp) - but you don't have a
"supporting library" which would be ORO or Regexp itself.

Stefan

Re: regexp mapper problem

Posted by Mikko Kurki-Suonio <ma...@neuslab.fi>.
On Tue, 22 May 2001, Suu Quan wrote:

> By the way, between the jakarta regexp and ORO's regexp, would someone
> recommend one of them and why?
> I chose jakarta's regexp because its jar file is 30k, half of ORO's 78K.

The ORO set is more complete and flexible (no, can't recall specifics off
the top of my head). If the smaller jakarta set does all you need, use it.

//Mikko



Re: regexp mapper problem

Posted by Suu Quan <sq...@wwc.com>.
----- Original Message -----
From: "Diane Holt" <ho...@yahoo.com>
To: <an...@jakarta.apache.org>
Sent: Monday, May 21, 2001 4:53 PM
Subject: Re: regexp mapper problem


> To use <mapper> with type="regexp", you need to have one of the jar-files
> that contains the classes it works with (eg., jakarta-oro-2.0.2.jar).
> That's why jakarta-regexp and jakarta-ORO are links in the doc (but I
> guess the doc could be a bit more clear).

Got it to work (again, old news Diane. Thanks)
But I have to disagree with you: Docs are supposed to confuse you, so you
make the wrong turns, end up in the ditch, then the hospital, then you learn
something.
That's why I read the docs at 100mph, and most people don't even bother.
We're rational people, and that is our rationale.

By the way, between the jakarta regexp and ORO's regexp, would someone
recommend one of them and why?
I chose jakarta's regexp because its jar file is 30k, half of ORO's 78K.

tia


Re: regexp mapper problem

Posted by Diane Holt <ho...@yahoo.com>.
To use <mapper> with type="regexp", you need to have one of the jar-files
that contains the classes it works with (eg., jakarta-oro-2.0.2.jar).
That's why jakarta-regexp and jakarta-ORO are links in the doc (but I
guess the doc could be a bit more clear).

Diane

--- Suu Quan <sq...@wwc.com> wrote:
> ----- Original Message -----
> From: "Diane Holt" <ho...@yahoo.com>
> To: <an...@jakarta.apache.org>
> Sent: Monday, May 21, 2001 3:18 PM
> Subject: Re: regexp mapper problem
> 
> 
> > See the "regexp" section in the user manual under "File Mappers" -- it
> > tells you what jars you need.
> 
> But I have ant.jar in my classpath, and "jar tf ant.jar" gives me
>     org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.class
>     org/apache/tools/ant/util/regexp/RegexpMatcher.class
>     org/apache/tools/ant/util/regexp/RegexpMatcherFactory.class
>     org/apache/tools/ant/util/RegexpPatternMapper.class
> 
> which is what the docs says.
> 
> "The regexp mapper needs a supporting library and an implementation of
> org.apache.tools.ant.util.regexp.RegexpMatcher that hides the specifics
> of
> the library. Ant comes with
> implementations for jakarta-regexp and jakarta-ORO. If you compile from
> sources and plan to use one of them, make sure
> the libraries are in your CLASSPATH. For information about using
> gnu.regexp
> or gnu.rex with Ant, see this article.
> 
> Ant will choose the regular-expression library based on the following
> algorithm:
> 
>      If the system property ant.regexp.matcherimpl has been set, it is
> taken
> as the name of the class implementing
>      org.apache.tools.ant.util.regexp.RegexpMatcher that should be used.
>      If it has not been set, first try jakarta-ORO; if that cannot be
> found,
> try jakarta-regexp.
> "
> 
> I even tried to set the property ant.regexp.matcherimpl, but it should
> have
> tried jakarta-regexp,
> which is in ant.jar.
> 
> where is the hole in my logic?
> 


=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Re: regexp mapper problem

Posted by Suu Quan <sq...@wwc.com>.
----- Original Message -----
From: "Diane Holt" <ho...@yahoo.com>
To: <an...@jakarta.apache.org>
Sent: Monday, May 21, 2001 3:18 PM
Subject: Re: regexp mapper problem


> See the "regexp" section in the user manual under "File Mappers" -- it
> tells you what jars you need.

But I have ant.jar in my classpath, and "jar tf ant.jar" gives me
    org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.class
    org/apache/tools/ant/util/regexp/RegexpMatcher.class
    org/apache/tools/ant/util/regexp/RegexpMatcherFactory.class
    org/apache/tools/ant/util/RegexpPatternMapper.class

which is what the docs says.

"The regexp mapper needs a supporting library and an implementation of
org.apache.tools.ant.util.regexp.RegexpMatcher that hides the specifics of
the library. Ant comes with
implementations for jakarta-regexp and jakarta-ORO. If you compile from
sources and plan to use one of them, make sure
the libraries are in your CLASSPATH. For information about using gnu.regexp
or gnu.rex with Ant, see this article.

Ant will choose the regular-expression library based on the following
algorithm:

     If the system property ant.regexp.matcherimpl has been set, it is taken
as the name of the class implementing
     org.apache.tools.ant.util.regexp.RegexpMatcher that should be used.
     If it has not been set, first try jakarta-ORO; if that cannot be found,
try jakarta-regexp.
"

I even tried to set the property ant.regexp.matcherimpl, but it should have
tried jakarta-regexp,
which is in ant.jar.

where is the hole in my logic?


Re: regexp mapper problem

Posted by Diane Holt <ho...@yahoo.com>.
See the "regexp" section in the user manual under "File Mappers" -- it
tells you what jars you need.

Diane

--- Suu Quan <sq...@wwc.com> wrote:
> Same old newbie speaking
> 
> I tried this simple mapper that is the equivalent of 'copy all files,
> prepending 'TUTU' in front of the filename
> <target name='regexp'> <!-- there is a syntax error somewhere -->
>       <copy todir="./mapper/regexp">
>       <mapper type="regexp" from="^(.*)$$" to="TUTU\1"/>
>       <fileset dir="/stp/stpd">
>       </fileset>
>       </copy>
> </target>
> 
> What I get is
> BUILD FAILED
> 
> C:\comrec\Ant\mapper.xml:41: No supported regular expression matcher
> found
> 
> property information
> ant.java.version (JVM version used by Ant) = 1.3
> os.name         = Windows 2000
> java.vm.version = 1.3.0_02
> 
> thanks in advance
> 


=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Re: Ant not recognizing entity

Posted by Stefan Bodewig <bo...@apache.org>.
Mark Jaffe <mj...@eturn.com> wrote:

> I am creating an HTML page in my build file, and writing a version
> string into it. I got an error when I first executed this code:

>   <echo file="ps/html/version.tmpl" >
> &lt;html&gt;
>...
>&copy;
>...
></echo>

copy is not a known entity for the XML-parser.  I think you'd better
use a CDATA-section:

<echo file="ps/html/version.tmpl" ><![CDATA[
<html>
...
&copy;
...
]]></echo>

or use a template like Diane suggested.

Stefan

Re: Ant not recognizing entity

Posted by Diane Holt <ho...@yahoo.com>.
I don't think including the "&copy;" is going to work the way you want it
to. You want it to go into your HTML file as the literal string, not be
replaced by the symbol. My advice would be to get rid of all the <echo>
stuff and just create and source-control your template file, with tokens
for your version and date/timestamp, then just <copy> with filtering to
version.html (as a side-note: since you were using <replace>, you don't
really need to write to one file, replace your tokens, then move it to the
file you want -- you could've just written to the file you wanted in the
first place).

Diane
 
--- Mark Jaffe <mj...@eturn.com> wrote:
> I am creating an HTML page in my build file, and writing a version
> string
> into it. I got an error when I first executed this code:
> 
>   <target name="base" depends="init">
>   <!-- Create version file HTML template -->
>   <echo file="ps/html/version.tmpl" >
> &lt;html&gt;
> &lt;head&gt;
> &lt;title&gt;Build Version&lt;/title&gt;
> &lt;meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1"&gt;
> &lt;/head&gt;
> 
> &lt;body topmargin="0" marginheight="0" bgcolor="#FFFFFF"
> text="#000000"&gt;
> &lt;center&gt;
> Build @version@
> &lt;hr&gt;
> &lt;font size=-2 face=arial&gt;Copyright &copy; 2001 Eturn
> Communications,
> Inc. &lt;/font&gt;
> &lt;/center&gt;
> &lt;/body&gt;
> &lt;/html&gt;
> </echo>
>   <!-- Insert version info into HTML template -->
>   <replace file="ps/html/version.tmpl" token="@version@" value="${vers}
> &lt;br&gt;built on ${DSTAMP} at ${TSTAMP}"/>
>   <touch file="${vers}" />
>   <move file="ps/html/version.tmpl" tofile="ps/html/version.html" />
> 
> At the line containing "&copy;" Ant complained about an unknown entity.
> Any
> thoughts on this? This should carry over from HTML. It works if I use
> "(c)"
> instead of &copy; but the page won't match everything else that has the
> &copy; thing in it.
> 
> Mark
> 


=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Ant not recognizing entity

Posted by Mark Jaffe <mj...@eturn.com>.
I am creating an HTML page in my build file, and writing a version string
into it. I got an error when I first executed this code:

  <target name="base" depends="init">
  <!-- Create version file HTML template -->
  <echo file="ps/html/version.tmpl" >
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Build Version&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"&gt;
&lt;/head&gt;

&lt;body topmargin="0" marginheight="0" bgcolor="#FFFFFF" text="#000000"&gt;
&lt;center&gt;
Build @version@
&lt;hr&gt;
&lt;font size=-2 face=arial&gt;Copyright &copy; 2001 Eturn Communications,
Inc. &lt;/font&gt;
&lt;/center&gt;
&lt;/body&gt;
&lt;/html&gt;
</echo>
  <!-- Insert version info into HTML template -->
  <replace file="ps/html/version.tmpl" token="@version@" value="${vers}
&lt;br&gt;built on ${DSTAMP} at ${TSTAMP}"/>
  <touch file="${vers}" />
  <move file="ps/html/version.tmpl" tofile="ps/html/version.html" />

At the line containing "&copy;" Ant complained about an unknown entity. Any
thoughts on this? This should carry over from HTML. It works if I use "(c)"
instead of &copy; but the page won't match everything else that has the
&copy; thing in it.

Mark