[xsde-users] Polymorphism and multiple schema files

EL MOUADDINE, Hicham (Prestataire) Hicham.ELMOUADDINE-prestataire at ca-cib.com
Thu Nov 7 05:16:26 EST 2013


Hello Boris,

I 'm having some issues when serializating objects where dynamic_type is different from static_type.

Here are my generating options for xsde (from schema file to cpp classes):

xsde  cxx-hybrid --generate-parser --generate-serializer  --suppress-validation --no-long-long   --generate-polymorphic --polymorphic-type abstractPivot --generate-aggregate --root-element pricingContext container.xsd testPackage.xsd first.xsd

and the code I'm using to serialize :


//I'm trying to serialize pricingContext
container::pricingContext pc;

//doesn't work: testPackage::standardOption inherits from testPackage::unitaryPayoff
testPackage::standardOption * stdOption = new testPackage::standardOption();

//work
//testPackage::unitaryPayoff * stdOption = new testPackage::unitaryPayoff();

//unitaryPayoff is a sequence of testPackage::unitaryPayoff which is the static type of unitaryPayoff
pc.unitaryPayOff().push_back(stdOption);

//I'm using agregation
container::pricingContext_saggr contextAggr;

xml_schema::document_simpl doc_s (contextAggr.root_serializer (),
                                      contextAggr.root_name (),true);

//doc_s.add_no_namespace_schema ("container.xsd");
//    doc_s.add_no_namespace_schema ("testPackage.xsd");
//doc_s.add_no_namespace_schema ("first.xsd");

      contextAggr.pre(pc);

//
test::writer  w("containerSerialization.xml");

w.Open();


std::cout<<"Serializing"<<std::endl;
try
{
      //the exection stops here
      doc_s.serialize(w);
}
catch(const xml_schema::serializer_exception& e)
      {
            //no exception is throw perhaps because I'm using release mode?
            cout << "error: " << e.text () << endl;
            w.Close();
      }

      w.Close();

      contextAggr.post();

When the static type is the same as dynamic type for the pushed object in  unitaryPayOff(), this code works, but when I'm using standardOption which is a concrete class of unitaryPayoff, the execution stops when calling doc_s.serialize(w).

I can't find the problem, what I've forgotten?

See the attached schema files.

Thank you in advance.

And best regards.

This message and any attachments are intended for the sole use of its addressee.
If you are not the addressee, please immediately notify the sender and then destroy the message.
As this message and/or any attachments may have been altered without our knowledge, its content is not legally binding on Crédit Agricole Corporate and Investment Bank.
All rights reserved.

 
Ce message et ses pièces jointes sont destinés à l'usage exclusif de leur destinataire.
Si vous recevez ce message par erreur, merci d'en aviser immédiatement l'expéditeur et de le détruire ensuite.
Le présent message pouvant être altéré à notre insu, Crédit Agricole Corporate and Investment Bank ne peut pas être engagé par son contenu.
Tous droits réservés.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testPackage.xsd
Type: text/xml
Size: 1615 bytes
Desc: testPackage.xsd
Url : http://codesynthesis.com/pipermail/xsde-users/attachments/20131107/d906c8ff/testPackage.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: container.xsd
Type: text/xml
Size: 689 bytes
Desc: container.xsd
Url : http://codesynthesis.com/pipermail/xsde-users/attachments/20131107/d906c8ff/container.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: first.xsd
Type: text/xml
Size: 401 bytes
Desc: first.xsd
Url : http://codesynthesis.com/pipermail/xsde-users/attachments/20131107/d906c8ff/first.bin


More information about the xsde-users mailing list