Keith - The output from SourceGenerator says that it cannot find the type for PRICE:
-- Suppressing non fatal warnings. Warning : do not forget to generate the source for the schema with this targetNamespace: pub3 Warning : do not forget to generate the source for the schema with this targetNamespace: pub3 Warning : do not forget to generate the source for the schema with this targetNamespace: pub3 Type not found for element: PRICE Does SourceGenerator actually try to find the pacakge.class that is specified in castor.properties? Thanks again for your help. -ken Here are my files: --- SourceGenerator Command --- java org.exolab.castor.builder.SourceGenerator -f -types j2 -i test.xsd --- castorbuilder.properties --- org.exolab.castor.builder.nspackages=\ pub3=test --- fbtest.xsd --- <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="pub3"> <xsd:element name="FBNumber"> <xsd:complexType/> </xsd:element> </xsd:schema> --- test.xsd --- <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:fbns="pub3"> <xsd:import namespace="pub3" schemaLocation="testfb.xsd"/> <!-- ITEMPRICE --> <xsd:element name="ITEMPRICE"> <xsd:complexType> <xsd:all> <xsd:element name="ITEMID" type="xsd:string"/> <xsd:element name="EFFECTIVEDATE" type="xsd:dateTime"/> <xsd:element name="PRICE" type="fbns:FBNumber"/> </xsd:all> </xsd:complexType> </xsd:element> </xsd:schema> --- ITEMPRICE.java (generated) --- ... private java.lang.String _ITEMID; private java.util.Date _EFFECTIVEDATE; private PRICE _PRICE; ... --- ITEMPRICE.java (desired) --- ... private java.lang.String _ITEMID; private java.util.Date _EFFECTIVEDATE; private test.FBNumber _PRICE; ... -----Original Message----- From: Keith Visco [mailto:[EMAIL PROTECTED]] Sent: Friday, January 25, 2002 6:06 PM To: [EMAIL PROTECTED] Subject: Re: [castor-dev] Support for user-defined types in Castor XML Ok...I'll answer the question again...I did a quick search at mail-archive.com and didn't come up with it either, but it should be there, I forget the subject line of the message. Declare the type you want to use (ie. your user-defined type) in a separate external Schema file, don't worry this is just to trick Castor into thinking the type exists... For example: <?xml version="1.0"?> <xsd:schema targetNamespace="user-defined-namespace" ...> <xsd:element name="MyNumberPrice"> <xsd:complexType/> </xsd:element> </xsd:schema> Now import this Schema into your existing Schema (your main schema file): <xsd:import schemaLocation="user-defined.xsd"> Also make sure you declare a prefix for "user-defined-namespace" inside the main schema file as such: <xsd:schema .... xmlns:myTypes="user-defined-namespace" Once imported and have your namespaces set up, you can then refer to the type: <xsd:element name="PRICE" type="myTypes:MyNumberPrice"/> The only remaining thing to do is to map the package for MyNumberPrice to it's namespace in castorbuilder.properties file: # XML namespace mapping to Java packages # org.exolab.castor.builder.nspackages= user-defined-namespace=myPackage Now run the source code generator on your main Schema file. Castor will warn about the imported Schema and tell you that you must generate the source code for that Schema as well. Just ignore it, since of course you already have the class file for your user-defined type. Hope that helps, --Keith Kenneth Lim wrote: > > Keith - > > I've searched the archives and read many articles. > I'm still unsure of how to proceed. Let me explain > my scenario a bit more ... > > Here's the .xsd I will use as input to SourceGenerator > > <!-- ITEMPRICE --> > <xsd:element name="ITEMPRICE"> > <xsd:complexType> > <xsd:all> > <xsd:element name="ITEMID" type="xsd:string"/> > <xsd:element name="EFFECTIVEDATE" type="xsd:dateTime"/> > <xsd:element name="PRICE" type="xsd:decimal"/> > </xsd:all> > </xsd:complexType> > </xsd:element> > > And the generated ITEMPRICE.java file has the following members: > > private java.lang.String _ITEMID; > private java.util.Date _EFFECTIVEDATE; > private java.math.BigDecimal _PRICE; > > What do I have to do to the .xsd file to get SourceGenerator > to generate members like the following: > > private java.lang.String _ITEMID; > private java.util.Date _EFFECTIVEDATE; > private myPackage.myNumberClass _PRICE; // ********* // > > There were talks about adding FieldHandlers. And there were > talks about using a mapping.xml. My impression was that you > would use the mapping.xml when you already had java classes > and you want to make the XML fit it. Rather, my situation is > that I have an .xsd and want to generate the java classes. > > Thanks again. > -ken > > -----Original Message----- > From: Keith Visco [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 25, 2002 12:14 PM > To: [EMAIL PROTECTED] > Subject: Re: [castor-dev] Support for user-defined types in Castor XML > > Hi Ken, > > It's certainly possible...please search the archives: > > http://www.mail-archive.com/[email protected]/ > > I've answered this question in the recent past. > > Thanks, > > --Keith > > Kenneth Lim wrote: > > > > Hi - > > > > Can anyone tell me if Castor XML (SourceGenerator) can support > > user-defined types? More specifically ... I want to generate source > > code > > that uses a user-defined type (MyNumberClass) for a particular member, > > rather than the XML built-in types. If this is possible, would you > mind > > providing > > an example. > > > > Thanks for your time. > > -ken > > > > ----------------------------------------------------------- > > 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 ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
