http://castor.exolab.org/xml-mapping.html#constructor-args

--Keith

David Kocher wrote:
> 
> Thanks for your answer and my apologies for the late response. This has obviously 
> solved my problem; thanks :)
> I still have the problem that my auto-generatied classes from apache axis extend from
> the org.apache.axis.types.* classes which often do not have public constructor with 
> no arguments.
> E.g. I get exceptions such as
>         org.exolab.castor.mapping.MappingException: The Java class 
> org.apache.axis.types.PositiveInteger is
>         not constructable -- it does not contain a default public constructor
> 
> Is it possible to map a constructor?
> Thanks a lot!
> -David
> 
> On Thursday 17 July 2003 22:46, Keith Visco wrote:
> > Hi David,
> >
> > Try changing your mapping to the following:
> >
> >   <class name="ZIPCodeType">
> >           <description>Default mapping for class
> > ZIPCodeType</description>
> >           <map-to xml="ZIP-Code"/>
> >           <field name="Value" type="org.apache.axis.types.NMToken">
> >                   <bind-xml name="Value" node="text"/>
> >           </field>
> >   </class>
> >
> > Otherwise, with your current mapping, Castor will expect an element with
> > the name "Value" as such:
> >
> > <ZIP-Code>
> >    <Value>01234</Value>
> > </ZIP-Code>
> >
> > Because you have specified the field mapping should be an element with
> > name "Value".
> >
> > Changing to text as shown above should work for you.
> >
> > --Keith
> >
> > David Kocher wrote:
> > > Hi,
> > >
> > > I am getting an error like the following for every class mapping with a
> > > field type other than java.lang.String when unmarshalling an xml intance
> > > file.
> > >
> > >      [java] ZIPCodeType
> > >      [java]   value: "3000"
> > >      [java] org.xml.sax.SAXException: Illegal Text data found as child
> > > of: ZIP-Code [java]   value: "3000"
> > >      [java]     at
> > > org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:6
> > >90) [java]     at
> > > org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1392)
> > > [java]     at
> > > org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValida
> > >tor.java:1480) [java]     at
> > > org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch
> > >(XMLDocumentScanner.java:1149) [java]     at
> > > org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScann
> > >er.java:381) [java]     at
> > > org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081) [java]
> > >   at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:555)
> > > [java]     at
> > > ch.itserve.lohnstandard.piv.Client.createSalaryDeclarationsTypeFromXML(Cl
> > >ient.java:185) [java]     at
> > > ch.itserve.lohnstandard.piv.Client.run(Client.java:87) [java]     at
> > > ch.itserve.lohnstandard.piv.Client.main(Client.java:211)
> > >
> > > The mapping looks like this
> > >
> > >  <class name="ZIPCodeType">
> > >          <description>Default mapping for class ZIPCodeType</description>
> > >          <map-to xml="ZIP-Code"/>
> > >          <field name="Value" type="org.apache.axis.types.NMToken">
> > >                  <bind-xml name="Value" node="element"/>
> > >          </field>
> > >  </class>
> > >
> > > The java implementation
> > >
> > > public class ZIPCodeType  implements java.io.Serializable,
> > > org.apache.axis.encoding.SimpleType { private
> > > org.apache.axis.types.NMToken value;
> > >
> > >         public ZIPCodeType() {
> > >                 System.out.println("ZIPCodeType");
> > >         }
> > >
> > >         public ZIPCodeType(org.apache.axis.types.NMToken value) {
> > >                 System.out.println("ZIPCodeType:"+value);
> > >                 this.value = value;
> > >         }
> > >
> > >         // Simple Types must have a String constructor
> > >         public ZIPCodeType(java.lang.String value) {
> > >                 System.out.println("ZIPCodeType:"+value);
> > >                 this.value = new org.apache.axis.types.NMToken(value);
> > >         }
> > >
> > >         // Simple Types must have a toString for serializing the value
> > >         public java.lang.String toString() {
> > >                 return value == null ? null : value.toString();
> > >         }
> > >
> > >         public org.apache.axis.types.NMToken getValue() {
> > >                 return value;
> > >         }
> > >
> > >         public void setValue(org.apache.axis.types.NMToken value) {
> > >                 System.out.println("ZIPCodeType:setValue"+value);
> > >                 this.value = value;
> > >         }
> > >
> > > Using version 0.9.5
> > >
> > > Thanks in advance
> > > -David
> > >
> > > -----------------------------------------------------------
> > > If you wish to unsubscribe from this mailing, send mail to
> > > [EMAIL PROTECTED] with a subject of:
> > >         unsubscribe castor-dev
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-dev
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

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

Reply via email to