You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Ma, Jian" <Ji...@kmv.com> on 2002/01/05 01:42:50 UTC

"Illegal character or entity reference syntax" error

I'm trying to use <exec> task to run windows "net use" command.  It worked
fine when the password I used for net use is something like 'abcdef'.  Once
I have special charactors in it, such as '@', '|', '&', ant throws a
"Illegal character or entity reference syntax" error.  I also got the same
error when I try to assign a string with those special chars to a property
using the <property> task.  I tried to use '\' to escape these special chars
and that didn't help either.  Has anyone encounter the similiar problem?


Jian"Chuck" Ma
KMV LLC
1620 Montgomery St. Suite 140
San Francisco, CA 94111
415-352-1157(w)




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: "Illegal character or entity reference syntax" error

Posted by Peter Donald <pe...@apache.org>.
On Sat, 5 Jan 2002 11:42, Ma, Jian wrote:
> I'm trying to use <exec> task to run windows "net use" command.  It worked
> fine when the password I used for net use is something like 'abcdef'.  Once
> I have special charactors in it, such as '@', '|', '&', ant throws a
> "Illegal character or entity reference syntax" error.  I also got the same
> error when I try to assign a string with those special chars to a property
> using the <property> task.  I tried to use '\' to escape these special
> chars and that didn't help either.  Has anyone encounter the similiar
> problem?

The XML parser treats "&" and "@" characters specially. You need to encode 
them according to their unicode number. I think that means the following 
replacements

& --> &amp;
@ --> &#169;


I think "|" should be fine but if not you will need to escape it using the 
ascii/unicode escape (ie &#numbner;)
-- 
Cheers,

Pete

----------------------------------------------------
"The only way to discover the limits of the possible 
is to go beyond them into the impossible." 
                             -Arthur C. Clarke
----------------------------------------------------

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>