Werner Guttmann schrieb:
Martin,
we have recently fixed one or two issues related to the usage of
patterns and regular expressions.
Would it be an option for you to try the recently uploaded 1.2
snapshot release and provide us with feedback ?
Now I tried the castor-codegen-1.2-20080107.221655-1.jar and
castor-1.2-20080108.211656-2.jar
along with velocity-1.5.jar which seems to be required now. I have
rebuild the java classes from the
schema and everything looked fine despite these messages:
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #packageDeclaration( jClass ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #javadoc( comment shift ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #classDefinition( jClass shift ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #enumDefinition( jClass shift ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #superclass( jClass ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #interfacesDefinition( jClass ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #enumConstant( jEnumConstant shift ) : source
= /org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #enumConstantArguments( jEnumConstant ) :
source = /org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #enumConstantMethods( jEnumConstant shift ) :
source = /org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #member( field shift ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #staticInitializationCode( jClass shift ) :
source = /org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #constructor( constructor shift ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #method( method shift ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #returntype( method ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #parameters( method ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #exceptions( method ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
23.01.2008 11:25:49 org.apache.velocity.runtime.log.JdkLogChute log
INFO: Velocimacro : added #annotation( annotation shift ) : source =
/org/exolab/castor/builder/printing/templates/library.vm
I don't know if this is important. Anyway, the error still persits if I
use 0 for fWert:
ValidationException: The following exception occured while validating
field: _fWert of class: de.fiverx.v1_3.StatusInfo: 0does not match the
required regular expression: "-?\d{1,7}\.\d{2}";
- location of error: XPATH: /statusInfo
0does not match the required regular expression: "-?\d{1,7}\.\d{2}"
at
org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:278)
at
org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:1065)
at org.exolab.castor.xml.Validator.validate(Validator.java:135)
at org.exolab.castor.xml.Marshaller.validate(Marshaller.java:2546)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:826)
at org.exolab.castor.xml.Marshaller.staticMarshal(Marshaller.java:798)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:727)
at de.fiverx.v1_3.StatusInfo.marshal(StatusInfo.java:160)
at de.fiverx.test.CastorTest.main(CastorTest.java:28)
Martin Beier wrote:
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