You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Costello, Robert" <rc...@searshc.com> on 2008/08/08 17:30:43 UTC

using ampersand in schema regex

I have a field in which I want to limit allowed characters to alpha
letters, whitespace, digits, ampersands, and semicolons. 

regex
[A-Za-z0-9\s;&]*

test string
&gt;abc1 23&gt;

When I try the above regular expression online at
http://www.fileformat.info/tool/regex.htm

It shows it to be valid. Arguably, the engine is a Java regex engine,
but I would hope it to be close. 

When I compile my schema with scomp, it fails on the ampersand, seeming
to think it is an escape for following characters. This is the error
message I get:

error: Unexpected character encountered (lex state 12): ']'

I've tried several combinations, and all seem to fail with the same type
of error.  It also fails to validate on the W3c site.  Is there
something I'm missing?

Thanks,

Robert Costello


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: using ampersand in schema regex

Posted by "Costello, Robert" <rc...@searshc.com>.
Thanks Radu,

It worked!  I ended up doing something similar in another restriction:

<xs:pattern value=
"[.:;\)\(A-Z\[\]\{\}&gt;&lt;#/&apos;&quot;\*a-z0-9\s\-]*"
/>

and I threw the kitchen sink at it testing it with this:

<testData>
test&lt;&gt;&apos;&quot;#)(}{/*-/r/n][;/'.:]]]
</testData>

Robert Costello

 

-----Original Message-----
From: Radu Preotiuc [mailto:radu.preotiuc-pietro@oracle.com] 
Sent: Tuesday, August 12, 2008 4:09 PM
To: user@xmlbeans.apache.org
Subject: Re: using ampersand in schema regex

I am assuming that you are using something like the following:

<xs:pattern value="[A-Za-z0-9\s;&amp;]*"></xs:pattern>

It works for me, have you tried exactly this? (Meaning that of course
you have to XML-escape the & sign, but beyond that there is nothing
special in the regexp)

Radu



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: using ampersand in schema regex

Posted by Radu Preotiuc <ra...@oracle.com>.
I am assuming that you are using something like the following:

<xs:pattern value="[A-Za-z0-9\s;&amp;]*"></xs:pattern>

It works for me, have you tried exactly this? (Meaning that of course
you have to XML-escape the & sign, but beyond that there is nothing
special in the regexp)

Radu



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org