I guess you need to design your schema so that it allows extensions.

One way of doing it is to put "any" content model at the end of your schema:

<xs:element name="foo">
 <xs:complexType>
  <xs:sequence>
   <xs:element name="bar" type="xs:string"/>
   <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" />
  </xs:sequence>
 </xs:complexType>
</xs:element>

This is a valid schema but when you marshal your objects, Castor Marshaller
do not keep the sequence, i.e.

<foo>
  <hello>hi</hello>
  <bar>hey</bar>
</foo>

IS THIS NORMAL? Castor Unmarshaller do not mind this but, other validators
can reject this XML.

Another way is to add an extension element and tell your clients to put new
stuff in there, ie.

<xs:element name="foo">
 <xs:complexType>
  <xs:sequence>
   <xs:element name="bar" type="xs:string"/>
   <xs:element name="extensions">
    <xs:complexType>
     <xs:sequence minOccurs="0" maxOccurs="unbounded">
       <xs:any namespace="##any" minOccurs="0" />
     </xs:sequence>
    </xs:complexType>
   </xs:element>
  </xs:sequence>
 </xs:complexType>
</xs:element>

Then this looks better, I guess, i.e.

<foo>
  <bar>hey</bar>
  <extensions>
          <hello>hi</hello>
  </extensions>
</foo>

Are the extensions defined in other namespaces?

Ozgur

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
Panduranga M. Prabhu
Sent: Thursday, February 14, 2002 8:06 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Castor support for additional nodes in XML


All.
We are using Castor in a large Enterprise Application Integration project.
We are using Castor to marshall/unmarshall XML messages to talk to different
Enterprise Applications through a Message Broker. Everything was going fine
until
we stumbled upon this problem.

    -- we generate classes from the XSDs for XML Messages given
        by systems that service many clients
    -- Along the way, some System adds some additional nodes to the XML
Messages for  particular
        client/s. The structure/names of earlier nodes reamin un-altered.
    -- These changes ideally should not affect us, as we as a client do not
        care about these new additional nodes.
However as we are using Castor, the generated classes throw Exception while
unmarshalling and only way is to regenerate the classes for new XSDs.

This is a big problem for us, as we need to regenerate the classes, bring
down our application
deploy and start application again.

Anybody has suggestions on how to avoid this code generation ?

Any inputs highly appreciated.
thanks
- prabhu

-----------------------------------------------------------
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