While playing with different castor versions (0.9.3/0.9.3.9) I became
aware of this issue:

Using the SourceGenerator I generate the Item.class and the
ItemDescriptor.class with 0.9.3 for the following schema:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  <xsd:element name="item">
    <xsd:complexType>
      <xsd:attribute name="category" type="xsd:NMTOKENS" use="optional"/>
    </xsd:complexType>
   </xsd:element>
</xsd:schema>

The xml marshalling output of an instance (compiled and running with 0.9.3)
is:

<?xml version="1.0"?>
<item category="ab cd de"/>

Doing the same with 0.9.3.9 (srcgen, compiling, running) I got this exception:

ValidationException: "ab cd de" is not a valid NMToken.;
   - location of error: XPATH: item
        at
org.exolab.castor.xml.validators.NameValidator.validate(NameValidator.java:112)
        at
org.exolab.castor.xml.validators.NameValidator.validate(NameValidator.java:136)
        at
org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:249)
        at
org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:748)

        at org.exolab.castor.xml.Validator.validate(Validator.java:118)
        at org.exolab.castor.xml.Marshaller.validate(Marshaller.java:1221)
        at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:536)
        at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:460)
        at item.Item.marshal(Item.java:142)
        at item.Item.main(Item.java:226)

After code digging I found this in the two ItemDescriptor classes:

with 0.9.3:

    ...
    //-- validation code for: _category
    fieldValidator = new FieldValidator();
??? fieldValidator.setMinOccurs(0);
    desc.setValidator(fieldValidator);
    ...

with 0.9.3.9

    ...
    //-- validation code for: _category
    fieldValidator = new FieldValidator();
??? fieldValidator.setValidator(new NameValidator(NameValidator.NMTOKEN));
    desc.setValidator(fieldValidator);
    ...

What's wrong there? Is it a mistake of mine? Useful hints are welcome.

Thomas

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

Reply via email to