You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Vogelheim, Daniel" <da...@siemens.com> on 2006/09/14 14:01:02 UTC

Question on Xerves RegEx implementation

Hi all,

I have an XSD schema that I'm trying to validate using Xerces (Java, v
2.8). Xerces complains about errors in the regular expression syntax,
which appears to originate in my use of the '$' character in the regexp.
>From my understanding of the XSD spec the regular expression should be
fine, so I suspect a bug in Xerces. Could someone have a look at it and
determine whether the error is in the schema or the validator?


Please find details at the end. In summary, the issue is this:

Regexp pattern:     <xs:pattern value="$*"/>

This is supposed to match sequences of actual '$' signs, i.e. "$$", but
not ""$a$". The '*' is meant as meta character, the '$' is meant as a
regular character. From my reading of XML Schema Part 2, Appendix F (W3C
Rec fom Oct. 28th, 2004) the pattern should be fine. I haven't found
anything in the spec that would treat '$' as a meta character, unlike
most other regex languages. Xerces complains about an unexpected meta
character; apparently about the '$'.



Thanks!

Sincerely,
Daniel Vogelheim

----------------------------------
The program used is the DOMWriter example from the Xerces distribution.

The relevant schema excerpt:
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="$*"/>
      </xs:restriction>
    </xs:simpleType>

The Xerces-J error message:
[Error] ns15.xsd:34:40: InvalidRegex: Pattern value '$*' is not a valid
regular
expression. The reported error was: 'Unexpected meta character.'.

RE: Question on Xerves RegEx implementation

Posted by "Wax, Ed" <Ed...@csgsystems.com>.
Daniel,
 
>From the XML Schema spec (
http://www.w3.org/TR/2006/WD-xmlschema11-2-20060217/datatypes.html#regex
s ):

	In regular expression languages that are not implicitly anchored
at the head and tail, it is customary to write the equivalent regular
expression as: 

	   ^A.*Z$ 

	where "^" anchors the pattern at the head and "$" anchors at the
tail. 

I believe Xerces is complaining because your regular expression is
attempting to specify a pattern after the end of the line, which is not
valid, to my understanding.

Ed

	-----Original Message-----
	From: Vogelheim, Daniel [mailto:daniel.vogelheim@siemens.com] 
	Sent: Thursday, September 14, 2006 6:01 AM
	To: j-users@xerces.apache.org
	Subject: Question on Xerves RegEx implementation
	
	

	Hi all, 

	I have an XSD schema that I'm trying to validate using Xerces
(Java, v 2.8). Xerces complains about errors in the regular expression
syntax, which appears to originate in my use of the '$' character in the
regexp. From my understanding of the XSD spec the regular expression
should be fine, so I suspect a bug in Xerces. Could someone have a look
at it and determine whether the error is in the schema or the validator?


	Please find details at the end. In summary, the issue is this: 

	Regexp pattern:     <xs:pattern value="$*"/> 

	This is supposed to match sequences of actual '$' signs, i.e.
"$$", but not ""$a$". The '*' is meant as meta character, the '$' is
meant as a regular character. From my reading of XML Schema Part 2,
Appendix F (W3C Rec fom Oct. 28th, 2004) the pattern should be fine. I
haven't found anything in the spec that would treat '$' as a meta
character, unlike most other regex languages. Xerces complains about an
unexpected meta character; apparently about the '$'.



	Thanks! 

	Sincerely, 
	Daniel Vogelheim 

	---------------------------------- 
	The program used is the DOMWriter example from the Xerces
distribution. 

	The relevant schema excerpt: 
	    <xs:simpleType> 
	      <xs:restriction base="xs:string"> 
	        <xs:pattern value="$*"/> 
	      </xs:restriction> 
	    </xs:simpleType> 

	The Xerces-J error message: 
	[Error] ns15.xsd:34:40: InvalidRegex: Pattern value '$*' is not
a valid regular 
	expression. The reported error was: 'Unexpected meta
character.'.