Hi, I just start to use castor in one of my projects. I am using castor and apache Axis in creating a web service.The SourceGenerator worked fine with complexTypes and elements. I wanted to use castor to validate a xml  string field with max length defined in a simpleType (“String200” as below). According to the instruction the SourceGenerator did not create any class on the simpleType “String200”. The “String200” class was created using apache Axis tools instead. The problem happened when the web service was launched. It failed at marshalling between XML and Castor Objects:

 

“org.xml.sax.SAXException: Unable to marshall between XML and Castor Objects :Illegal Text data found as child of: location  value:”

 

What is the correct way to use Castor to limit an xml field to a certain length?

 

All suggestions are appreciated. Thanks.

 

Scott Liu

 

P.S. The relevant schema:

 

       <xsd:simpleType name="String200">

             <xsd:si

             <xsd:restriction base="xsd:token">

                    <xsd:maxLength value="200"/>

             </xsd:restriction>

       </xsd:simpleType>

       <xsd:element name="Event">

             <xsd:complexType>

                    <xsd:sequence>

                           <xsd:element name="location" minOccurs="0" maxOccurs="1" nullalbe="true" type="String200"/>

                    </xsd:sequence>

             </xsd:complexType>

       </xsd:element>

 

and error stack trace:

 

org.xml.sax.SAXException: Unable to marshall between XML and Castor Objects :Illegal Text data found as child of: location  value: &quot;123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678&quot;</faultstring>  

            <detail>   

               <ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/">org.xml.sax.SAXException: Unable to marshall between XML and Castor Objects :Illegal Text data found as child of: location  value: &quot;123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678&quot;&#xd;           at org.apache.axis.encoding.ser.castor.CastorDeserializer.onEndElement(CastorDeserializer.java:108)&#xd;            at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:534)&#xd;       at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015)&#xd;          at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:204)&#xd;   at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:722)&#xd;      at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)&#xd;     at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)&#xd;    at

 

Reply via email to