"Mujtaba,Shelly" wrote: > > Keith, > Given this xml: > > <Party xsi:type="org"> > > <name>Acme</name> > > </Party> > > > > <Party xsi:type="person"> > > <name>Jeff</name> > > </Party> > > How Would castor know when to create a com.acme.Person v/s > com.acme.MyOrg ?
By using the xsi:type and the class mappings specified in the mapping file. > > Also on the marshaling, the xml needs to be populated with the mapped > types "person" and "org" and not the class names. So if we could some > how map "org" and "person" to correct class names during un/marshalling > we would be fine. I believe if you add <bind-xml ... type="org"/> to the field mapping it should use that instead of the class name during marshalling. --Keith -----Original Message----- > From: Keith Visco [mailto:[EMAIL PROTECTED] > Sent: Friday, October 31, 2003 9:27 PM > To: [EMAIL PROTECTED] > Subject: Re: [castor-dev] Adding indirection to xsi:type > > Hi Shelly, > > It *should* already work, have you tried the following: > > <class name="com.acme.Party"> > ... > </class> > > <class name="com.acme.MyOrg" extends="com.acme.Party"> > <map-to xml="org"/> > ... > </class> > > <class name="com.acme.MyPerson" extends="com.acme.Party"> > <map-to xml="person"/> > ... > </class> > > <class name="com.acme.Root"> > <field name="party" type="com.acme.Party"> > <bind-xml name="Party"/> > </field> > </class> > > --Keith > > "Mujtaba,Shelly" wrote: > > > > Castor has a well defined method for supporting interfaces i.e using > > xsi:type within the element. Now here is the problem: The xml we > > receive already has xsi:type populated with generic names such as org, > > > person, party etc. For example > > <Party xsi:type="org"> > > <name>Acme</name> > > </Party> > > > > <Party xsi:type="person"> > > <name>Jeff</name> > > </Party> > > > > We would like to be able to map the "org" and "person" to concrete > > classes. Castor currently does not provide this indirection. So my > > question is: > > > > 1. If I want to add this indirection, which classes should I modify > > both for marshalling and unmarshalling. 2. Would this be something we > > may consider for a patch or addon to castor? > > > > Thanks > > Shelly > > > > -----Original Message----- > > From: Keith Visco [mailto:[EMAIL PROTECTED] > > Sent: Friday, October 31, 2003 3:29 PM > > To: [EMAIL PROTECTED] > > Subject: Re: [castor-dev] Source generator chocking at "namespace > > prefix not recognized" > > > > Jing, > > > > Castor's source generator uses XML Schema (see W3C XML Schema 1.0 > > Recommendation) for creating source code, not DTDs. You'll need to > > convert your DTD to an XML Schema before the source generator will be > > able to generate any source code for it. > > > > Castor has a tool (org.exolab.castor.xml.dtd.Converter) that can help > > you. There are also a number of 3rd party tools that can convert DTDs > > to XML Schema. > > > > --Keith > > > > [EMAIL PROTECTED] wrote: > > > > > > We really need help with this problem that I've posted earlier! and > > > to > > > > > make it easier for you to identify the problem, i've minimized the > > > dtd > > > > > as the following: > > > > > > ################################################################## > > > > > > <!ENTITY parseType "CDATA #FIXED 'Resource'"> > > > > > > <!ELEMENT go:go ( > > > go:version?, > > > rdf:RDF > > > )> > > > > > > <!ATTLIST go:go > > > xmlns:go CDATA #FIXED > > "http://www.geneontology.org/dtds/go.dtd#" > > > xmlns:rdf CDATA #FIXED > > > "http://www.w3.org/1999/02/22-rdf-syntax-ns#" > > > > > > > > > > <!ELEMENT go:version (#PCDATA)> > > > > > > <!ATTLIST go:version > > > timestamp CDATA #IMPLIED > > > > > > > > > > <!ELEMENT rdf:RDF (go:term*)> > > > > > > <!ELEMENT go:term ( > > > go:name, > > > go:part_of* > > > )> > > > > > > <!ATTLIST go:term > > > rdf:about CDATA #REQUIRED > > > > > > > > > > <!ELEMENT go:name (#PCDATA)> > > > > > > <!ELEMENT go:part_of (#PCDATA)> > > > <!ATTLIST go:part_of > > > rdf:resource CDATA #REQUIRED > > > > > > > #################################################################### > > > ## > > > ### > > > > > > with this dtd, I wasn't able to get any generated source, but only > > > got > > > > > Exception in thread "main" java.lang.IllegalArgumentException: > > > getElementDecl: Namespace prefix not recognized 'go' > > > > > > [java] at > > > org.exolab.castor.xml.schema.Schema.getElementDecl(Unknown Source) > > > [java] at > > > org.exolab.castor.xml.schema.ElementDecl.getReference(Unknown > Source) > > > [java] at > > > org.exolab.castor.xml.schema.ElementDecl.getType(Unknown Source) > > > [java] at > > > org.exolab.castor.builder.SourceFactory.processContentModel(Unknown > > > Source) > > > [java] at > > > org.exolab.castor.builder.SourceFactory.processContentModel(Unknown > > > Source) > > > [java] at > > > org.exolab.castor.builder.SourceFactory.processComplexType(Unknown > > > Source) > > > [java] at > > > org.exolab.castor.builder.SourceFactory.createSourceCode(Unknown > > > Source) > > > [java] at > > > org.exolab.castor.builder.SourceGenerator.createClasses(Unknown > > > Source) > > > [java] at > > > org.exolab.castor.builder.SourceGenerator.createClasses(Unknown > > > Source) > > > [java] at > > > org.exolab.castor.builder.SourceGenerator.generateSource(Unknown > > > Source) > > > [java] at > > > org.exolab.castor.builder.SourceGenerator.generateSource(Unknown > > > Source) > > > [java] at > > > org.exolab.castor.builder.SourceGenerator.generateSource(Unknown > > > Source) > > > [java] at > > org.exolab.castor.builder.SourceGenerator.main(Unknown > > > Source) > > > > > > Is this way to declare namespace acceptable to Castor? Will it > > > matter that it uses two identical "go", one as the prefix and the > > > other as the element name? Any suggestions will be greatly > > > appreciated! > > > > > > Thanks! > > > Jing > > > > > > ----------------------------------------------------------- > > > 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 ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
