I am using castor 1.0 and receive an exception marshalling Java objects to XML. I went through lots of documentation, e-mail lists and also tried google, but I still do not get
the clue how to approach the problem.

I used the code generator to create Java classes from an xsd. The relevant part is

 <xs:element name="fWert">
     <xs:simpleType>
         <xs:restriction base="xs:decimal">
             <xs:pattern value="-?\d{1,7}\.\d{2}"/>
         </xs:restriction>
     </xs:simpleType>
 </xs:element>


 <xs:element name="statusInfo">
 ...
    <xs:element ref="ns:fWert" minOccurs="0"/>

castor generated a StatusInfo and a StatusInfoDescriptor class.
The Java type for fWert is java.math.BigDecimal.
When I use the StatusInfo class an try to marshall it, I get an exception:

     StatusInfo statusInfo = new StatusInfo();
     ...
     statusInfo.setFWert(new java.math.BigDecimal(0));
     ...
     java.io.StringWriter sw = new java.io.StringWriter();
     statusInfo.marshal(sw);

ValidationException: The following exception occured while validating field: _fWert of class: StatusInfo: 0does not match the required regular expression: "-?\d{1,7}\.\d{2}";
- location of error: XPATH: /statusInfo

From the documentation, I somehow understood that I eather have to use
a mapping file or to use the descriptor class. But I do not know how and why,
since all necessary information how fWert is to be formatted is provided
by the xsd schema.

Thanks in advance for any hint.
Martin Beier



---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to