[xsde-users] Program crash: How to use XML-Schema built-in string type

Adinath Shetye adi4info at gmail.com
Fri May 1 12:02:06 EDT 2015


Hi All,
I'm trying to generate XMl from below shcema and need help to initialse a
XML-Schema built-in string type and my program is crashing:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

        <xs:simpleType name="UUID">
                <xs:restriction base="xs:string">
                        <xs:length value="36"/>
                </xs:restriction>
        </xs:simpleType>

        <xs:complexType name="GetID">
                <xs:sequence>
                        <xs:element name="IDField" type="UUID"/>
                </xs:sequence>
        </xs:complexType>

        <xs:element name="RootNode" type="GetID"/>
</xs:schema>

Generated code using command:xsde cxx-hybrid --generate-parser
--generate-serializer --generate-aggregate Schema.xsd

*Schema.hxx file:*

// UUID (fixed-length)
//
class UUID: public ::std::string
{
  public:
  UUID ();
};

// GetID (fixed-length)
//
class GetID
{
  public:
  GetID ();

  GetID (const GetID&);
  GetID& operator= (const GetID&);

  ~GetID ();

  // IDField
  //
  const ::UUID&
  IDField () const;

  ::UUID&
  IDField ();

  void
  IDField (const ::UUID&);

  private:
  ::UUID IDField_;
};


*Main Program:*
int
main (int argc, char* argv[])
{
        UUID UObj;
        std::string Str("adasddsaadasddsa");
        UObj.assign(Str);* //---Core Dump*
//      UObj.base_value(Str); *//---Compilation Error*
        GetID IDObj;
        IDObj.IDField(UObj);

        RootNode_saggr getid_s;
        xml_schema::document_simpl doc_s (getid_s.root_serializer (),
                        getid_s.root_name ());
        ostringstream ostr;
        ofstream myfile;
        myfile.open ("example.xml");
        myfile << "<?xml version=\"1.0\" encoding=\"UTF-8\"
standalone=\"no\" ?>\n";
        myfile << "<SNAP-Reponse xmlns:xsi=\"
http://www.w3.org/2001/XMLSchema-instance\"
xsi:noNamespaceSchemaLocation=\"Schema.xsd\">\n";
        getid_s.pre (IDObj);
        doc_s.serialize (cout,xml_schema::document_simpl::pretty_print);
        getid_s.post ();
        myfile.close();
        cout << ostr.str () << endl;

        return 0;
}


*Compilation Error:*
>From the link(
http://www.codesynthesis.com/projects/xsde/documentation/cxx/hybrid/guide/#5)
I tried to initialise UUID as below but getting compilation error:
Main.cxx: In function ‘int main(int, char**)’:
Main.cxx:15:7: error: ‘class UUID’ has no member named ‘base_value’
  UObj.base_value(Str);

*Program Crash:*
When I try UObj.assign(Str); the program compiles but I get core dump:
terminate called after throwing an instance of
'xsde::cxx::serializer::schema'
  what():  schema error
<RootNode>Aborted (core dumped)

GDB stack frames:
#0  0xb7fdbd4c in __kernel_vsyscall ()
#1  0xb7d38607 in __GI_raise (sig=sig at entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#2  0xb7d3ba33 in __GI_abort () at abort.c:89
#3  0xb7f22595 in __gnu_cxx::__verbose_terminate_handler() () from
/usr/lib/i386-linux-gnu/libstdc++.so.6
#4  0xb7f201f3 in ?? () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#5  0xb7f2022f in std::terminate() () from
/usr/lib/i386-linux-gnu/libstdc++.so.6
#6  0xb7f20496 in __cxa_throw () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#7  0x08056d6a in
xsde::cxx::serializer::genx::document_simpl::serialize(genxWriter_rec*) ()
#8  0x08056fdc in
xsde::cxx::serializer::genx::document_simpl::serialize(std::ostream&,
unsigned short) ()
#9  0x08049a94 in main (argc=1, argv=0xbffff5a4) at Main.cxx:28

Thanks in Advance,
Adinath


More information about the xsde-users mailing list