Hello All,

I'm using Castor's XML to classes facitily and have been happy with it. The 
only problem is, that you sometimes have to work around unemplemented parts 
of the XML Schema specification. But that's doable.

Now I've however found a bug that hinders my use of Castor a bit.
I'd like to use a pattern to validate a XML argument with xs:string as the 
base:
 <xs:simpleType name="elementRef">
  <xs:annotation>
   <xs:documentation>...</xs:documentation>
  </xs:annotation>
  <xs:restriction base="xs:string">
   <xs:pattern value="(/[\i-[:]][\c-[:]]*)+"/>
  </xs:restriction>
 </xs:simpleType>
The pattern is actually "(/{NCName})*" and the field can contain a reference 
to a unique element definition in an XML Schema, for example 
"/schema/annotation/documentation". It's a subset of XPath.

Generating the code goes well. This is the pattern specific code being 
generated:

        //-- validation code for: _element
        fieldValidator = new org.exolab.castor.xml.FieldValidator();
        fieldValidator.setMinOccurs(1);
        { //-- local scope
            StringValidator typeValidator = new StringValidator();
            typeValidator.setWhiteSpace("preserve");
            typeValidator.setPattern("(/[\\i-[:]][\\c-[:]]*)+");
            fieldValidator.setValidator(typeValidator);
        }

When running the code, this exception is thrown:
vlows.utils.CastorIOException: XML file could not be read into object.
 at vlows.utils.CastorIO.load(CastorIO.java:51)
 at mips.gendbtoxml.Test.main(Test.java:23)
Caused by: java.lang.IllegalArgumentException: RegExp Syntax error: Invalid [] 
range in expression. ; error occured with the following regular expression: 
(/[\i-[:]][\c-[:]]*)+

The expression seems to be indented properly. XMLSpy handles the pattern well 
and detects invalid strings. Xerces seems  to ignore the pattern and just 
accepts all strings.

The pattern is valid, so Castor should either ignore it or use it, but it 
should not give an erroneous error.

Cheers, Jos

-- 
Jos van den Oever
Institute for Bioinformatics
Building 56, Room 161 C
Telephone: +49 89/3187-3677
http://mips.gsf.de



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to