Hi Richard,
Your extra schema needs to declare the namespace as such: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.xyz.com/castor/schemas/test"> <complexType name="classname"> <sequence/> </complexType> </xsd:schema> --Keith "Davis, Richard" wrote: > > Keith, > > I like this idea of importing the schema for my own data type into the > source schema. I have the import specified in my xsd but I get an error > message that says: org.xml.sax.SAXException: namespace > 'http://www.xyz.com/castor/schemas/test > ' not declared in schema > > Can you tell me where I specify the namespace so the SourceGenerator won't > complain? I updated the castorbuilder.properties file as follows but I still > get the error. > > # XML namespace mapping to Java packages > # > org.exolab.castor.builder.nspackages=\ > http://www.xyz.com/castor/schemas/test=com.xyz.schemas.test > # > # > > The import in the source xsd looks like this: > > <xsd:import namespace="http://www.xyz.com/castor/schemas/test" > schemaLocation="ExternalDataTypes.xsd"> > <xsd:annotation> > <xsd:documentation> > Get access to external data types > </xsd:documentation> > </xsd:annotation> > </xsd:import> > > Thanks for the help. > > rich > -----Original Message----- > From: Keith Visco [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, November 28, 2001 7:27 PM > To: [EMAIL PROTECTED] > Subject: Re: [castor-dev] Source Generator > > "Davis, Richard" wrote: > > > > Keith, et-al > > > > I have a couple of questions regarding SourceGenerator and complexTypes. > I'm > > new to Castor so this info may be obvious. > > > > What I need is to be able to generate an object using SourceGenerator that > > has a field(s) that is of a type that is an existing class but not one of > > the built-in types. Is there a way to introduce a new XML schema data type > > and corresponding Java type that can be used by SourceGenerator. > > A trick is to create a separate Schema that contains a complexType > definition as such: > > <xsd:complexType name="existing-class-name-without-package-name"> > <xsd:sequence/> > </xsd:complexType> > > You can then import this Schema in your original Schema and refer to > this type where necessary and the source generator will produce the > appropriate code. > > The reason this works is that the Source Generator doesn't create > classes for imported schemas, it assumes you will run the Source > Generator on other Schema separately or have already done so. So it just > uses the class name where appropriate. > > Make sure you define a package name for the separate Schema in the > castorbuilder.properties file so that it uses the correct package name > of the existing class. > > Since the class already exists, you might need to create a Mapping file > for the class so that Castor will know how to marshal and unmarshal it. > Or you can rely on default introspector to try to figure it out. > > > > > Also, can I specify a Java Interface in the xsd that must be implemented > by > > objects generated by SourceGenerator? I do see that I can specify a super > > class. > > The source generator wouldn't know how to implement your interface. > > You can't do it directly, but since you can specify a super-class, > simply create an super class which declares this inteface. > > --Keith > > ----------------------------------------------------------- > 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
