Thank you for your response. I have a couple of follow-up questions based on your message.
1. How do classes (in the package) get associated with "any"? For instance I have two elements Form and Aggregate that I want associated (and Castor to generate based on). How do I do this with "any"? 2. Is this a way of modelling inheritence in xsd/Castor generation? Luke Stephens -----Original Message----- From: BEDNARIK,LASLO (HP-Germany,ex1) [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 9:54 AM To: [EMAIL PROTECTED] Subject: Re: [castor-dev] Generating Objects from Elements that are just t ags. Hi Luke, sounds like you could use the "any" construct in your schema, for example as follows (the "MessageBody" can have any XML content, in my case as a single tree): <xsd:element name="MessageBody"> <xsd:complexType> <xsd:sequence> <xsd:any processContents="lax" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> Castor will react in one of two ways. If the elements encountered in the "any" have associated Java classes in the same package as the one generated for "MessageBody" it will build up the tree as usual - otherwise it will build a tree of AnyNode instances. You may then just ignore the subtree or use it e.g. as follows (this may be a simple example as it marshalls the piece just after it had been unmarshalled): java.lang.Object content = m.getMessageBody().getAnyObject(0); StringWriter myWriter = new StringWriter(); org.exolab.castor.xml.Marshaller ma = new org.exolab.castor.xml.Marshaller(myWriter); ma.setMarshalAsDocument(false); ma.marshal((org.exolab.castor.types.AnyNode)content); myWriter.close(); xmlBody = myWriter.toString(); The above code assumes you got a tree of AnyNodes. Hope this helps, Laslo ====================================================================== _ _ ___ ___ Laslo Bednarik Tel. {0|49}-7031-468-2025 | || | _ \/ __| Software Engineer Telnet 701-2025 | __ | _/\__ \ Fax {0|49}-7031-468-2207 |_||_|_| |___/ 701-2207 =========== Hewlett-Packard ============ ___ _____ = HP Services IT = |_ _|_ _| = Mail: [EMAIL PROTECTED] = | | | | = http://isoit155.bbn.hp.com/~lbednari = |___| |_| ====================================================================== -----Original Message----- From: Stephens, Luke [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 3:17 PM To: [EMAIL PROTECTED] Subject: [castor-dev] Generating Objects from Elements that are just tags. I have a couple of Elements in my schema, that I want to treat as PCData (i.e., they are elements that delimit other xml structures/schemas that are not relevant to me. For instance I want to embed a SOAPRequest in another xml doc, but all I care about is getting the SOAPRequest out of my doc. I don't care about the form or structure of the SOAPRequest). If I create Elements in my schema that have no attributes or other elements, Castor does not generate a class for it. Any ideas? Luke Stephens ----------------------------------------------------------- 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
