From Rob.Ursem at cmgl.ca Fri May 2 01:35:14 2014 From: Rob.Ursem at cmgl.ca (Rob Ursem) Date: Fri May 2 11:32:51 2014 Subject: [xsd-users] Polymorphism, am I doing something wrong? Message-ID: I've been looking at the polymorphism example and see how that works , but I can't seem to make my example work. Consider the following schema: References: Message-ID: Hi Rob, Rob Ursem writes: > Consider the following schema: For some reason your emails come really garbled up. I can barely decipher what's going on. Could you try to send thing in plain text next time. > Am I missing something? If I managed to understand your question, you are not clear on how to discover what the concrete (derived) type of the instance is and how to get hold of it. If that's the case, then what you use is dynamic_cast to discover and get the concrete type at runtime. Section 2.11, "Mapping for xsi:type and Substitution Groups" in the C++/Tree Mapping User Manual shows how to do this: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11 Boris From Rob.Ursem at cmgl.ca Fri May 2 12:32:28 2014 From: Rob.Ursem at cmgl.ca (Rob Ursem) Date: Fri May 2 15:36:05 2014 Subject: [xsd-users] Polymorphism, am I doing something wrong? In-Reply-To: References: , Message-ID: Boris, I have put the plain text below, hopefully that cleans things up. I am having trouble getting the derived_cast to work since the generated code does not provide a pointer variable to me. I have made the data members public so I could use the "detach()" method on the one class, which provides me an auto_ptr but that is not a generic method. Alternatively I can write some perl to generate custom classes that provide me the pointers that I need but I was hoping for a more structural method since the deserialization seems to do the right thing (as I can see in the debugger). ORIGINAL MESSAGE: ======================================================= I've been looking at the polymorphism example and see how that works, but I can't seem to make my example work. Consider the following schema: In this schema we define a "cs_pointGeometryPatch" type that has an element named "points" of type "cs_abstractArrayOfPoints3d". This type is an abstract type and for the sake of the example, there is only one 'implementation' of this abstract class in the schema. An example xml for this schema is: 3 In this case a non-abstract class is used for the points element. This class is derived from "cs_abstractArrayOfPoints3d" so all is well. The generated code (only hxx shown) is: class cs_pointGeometryPatch: public ::xml_schema::type { public: // points // typedef ::cs_abstractArrayOfPoints3d points_type; typedef ::xsd::cxx::tree::traits< points_type, char > points_traits; const points_type& points () const; points_type& points (); void points (const points_type& x); void points (::std::auto_ptr< points_type > p); // Constructors. // cs_pointGeometryPatch (const points_type&); cs_pointGeometryPatch (const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); cs_pointGeometryPatch (const cs_pointGeometryPatch& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); virtual cs_pointGeometryPatch* _clone (::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; virtual ~cs_pointGeometryPatch (); // Implementation. // protected: void parse (::xsd::cxx::xml::dom::parser< char >&, ::xml_schema::flags); protected: ::xsd::cxx::tree::one< points_type > points_; }; We can see that when we request "points()" from a cs_pointGeometryPatch class, we get a reference to points_type, which is the abstract datatype. I see that when I parse the given xml with the schema, the parser instantiates an instance of "cs_arrayOfExplicitPoints3d" but due to the fact that the accessor for points is a reference and not a pointer, there is no way for me to typecast the abstract type to a derived type. I thus see no way to programmatically get to the value 3 (for coordinates) in the above shown xml. Am I missing something? ________________________________________ From: Boris Kolpackov [boris@codesynthesis.com] Sent: Friday, May 02, 2014 9:58 AM To: Rob Ursem Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Polymorphism, am I doing something wrong? Hi Rob, Rob Ursem writes: > Consider the following schema: For some reason your emails come really garbled up. I can barely decipher what's going on. Could you try to send thing in plain text next time. > Am I missing something? If I managed to understand your question, you are not clear on how to discover what the concrete (derived) type of the instance is and how to get hold of it. If that's the case, then what you use is dynamic_cast to discover and get the concrete type at runtime. Section 2.11, "Mapping for xsi:type and Substitution Groups" in the C++/Tree Mapping User Manual shows how to do this: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11 Boris From alexander.gosling at kongsberg.com Mon May 5 12:37:52 2014 From: alexander.gosling at kongsberg.com (alexander.gosling@kongsberg.com) Date: Mon May 5 12:38:04 2014 Subject: [xsd-users] Double definitions when using DLLs Message-ID: Hello, We are in the process of porting a SW system using CodeSynthesis from Visual Studio 2005 to Visual Studio 2012. We have experienced here that CodeSynthesis works fine if the libraries containing generated code are linked statically to the executable. If we however produce the libraries with generated code as DLLs, we run into a problem that we believe is the same as is widely discussed on the net concerning inheritance of std::string. In xsd-3.3.0-i686-windows\libxsd\xsd\cxx\tree\types.hxx the class xsd::cxx:tree:string is declared inheriting from std::string. When variables from this class are used in the interface of generated classes as parameters and return values, and these generated classes are a part of the interface of the DLL (the methods are declared with dll_export/dll_import as part of the signature) this leads to doubly defined std::npos when linking the library (DLL) to the executable. This happens if the main program also uses std::string, and I believe also if I link more than one library of CodeSynthesis generated code with the characteristics described above. You will find a lot of references to the problem of doubly defined std::npos on using classes that inherit from std::string by searching for "std::string already defined". >From what I have read about the problem I see no other solution than reimplementing xsd::cxx:tree:string so that it creates a facade to a contained std::string instead of inheriting std::string. But we are open to any solution that is simple from the user perspective. -- alex ________________________________ CONFIDENTIALITY This e-mail and any attachment contain KONGSBERG information which may be proprietary, confidential or subject to export regulations, and is only meant for the intended recipient(s). Any disclosure, copying, distribution or use is prohibited, if not otherwise explicitly agreed with KONGSBERG. If received in error, please delete it immediately from your system and notify the sender properly. From boris at codesynthesis.com Mon May 5 12:55:27 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 5 12:52:56 2014 Subject: [xsd-users] Double definitions when using DLLs In-Reply-To: References: Message-ID: Alexander, I believe you can resolve this issue if you can make one of the DLLs "root" and export std::basic_string from it while importing it in all the other DLLs and your executable. This earlier post has the instructions: http://www.codesynthesis.com/pipermail/xsd-users/2010-September/003011.html With this email containing more analysis/information on the problem: http://www.codesynthesis.com/pipermail/xsd-users/2010-September/003019.html Let me know how it goes or if something is not clear. Boris From boris at codesynthesis.com Mon May 5 13:00:51 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 5 12:58:26 2014 Subject: [xsd-users] Polymorphism, am I doing something wrong? In-Reply-To: References: Message-ID: Hi Rob, Rob Ursem writes: > We can see that when we request "points()" from a cs_pointGeometryPatch > class, we get a reference to points_type, which is the abstract datatype. > I see that when I parse the given xml with the schema, the parser > instantiates an instance of "cs_arrayOfExplicitPoints3d" but due to > the fact that the accessor for points is a reference and not a pointer, > there is no way for me to typecast the abstract type to a derived type. You can always get a pointer from a reference with the '&' operator: cs_pointGeometryPatch x = ... // parse cs_abstractArrayOfPoints3d& ref = x.points (); cs_abstractArrayOfPoints3d* ptr = &ref; In your case, you can discover the concrete type like this: if (cs_arrayOfExplicitPoints3d* x = dynamic_cast (ptr)) { // It is cs_arrayOfExplicitPoints3d, 'x' points to the instance. } else { // Something else. } Boris From Rob.Ursem at cmgl.ca Mon May 5 13:54:56 2014 From: Rob.Ursem at cmgl.ca (Rob Ursem) Date: Mon May 5 13:58:46 2014 Subject: [xsd-users] Polymorphism, am I doing something wrong? In-Reply-To: References: Message-ID: Boris, I thought that's what I had replied to Wesley but I added a "DUH" to it as it was a headslap moment. But then again, I sent that email from the airport so it might not have gone through. It all works nicely now. Thanks for the help! Rob -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Monday, May 05, 2014 11:01 AM To: Rob Ursem Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Polymorphism, am I doing something wrong? Hi Rob, Rob Ursem writes: > We can see that when we request "points()" from a > cs_pointGeometryPatch class, we get a reference to points_type, which is the abstract datatype. > I see that when I parse the given xml with the schema, the parser > instantiates an instance of "cs_arrayOfExplicitPoints3d" but due to > the fact that the accessor for points is a reference and not a > pointer, there is no way for me to typecast the abstract type to a derived type. You can always get a pointer from a reference with the '&' operator: cs_pointGeometryPatch x = ... // parse cs_abstractArrayOfPoints3d& ref = x.points (); cs_abstractArrayOfPoints3d* ptr = &ref; In your case, you can discover the concrete type like this: if (cs_arrayOfExplicitPoints3d* x = dynamic_cast (ptr)) { // It is cs_arrayOfExplicitPoints3d, 'x' points to the instance. } else { // Something else. } Boris From owagh at tower-research.com Mon May 5 14:37:03 2014 From: owagh at tower-research.com (Omkar Wagh) Date: Mon May 5 14:37:07 2014 Subject: [xsd-users] reading from string streams Message-ID: <4615F466BD17634BB399D1232F9D687835C8E6FA@msxny2.windows.tower-research.com> Hi I'm not sure what's going wrong with my setup but what I'm doing is basically creating an istringstream object and trying to parse with it. Unfortunately, I keep getting an error like :- :444:1 error: Expected comment or processing instruction My code is like this :- std::string file_str(reinterpret_cast (plaintext)); std::istringstream ptext_stream(file_str); auto_ptr model2(root_type_(ptext_stream)); This throws the above exception. However, if I write the above to a temporary file, I don't get the error mentioned above. Any idea on how I can get some more detailed error messages to debug the issue? Omkar From boris at codesynthesis.com Mon May 5 20:11:48 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 5 20:09:18 2014 Subject: [xsd-users] reading from string streams In-Reply-To: <4615F466BD17634BB399D1232F9D687835C8E6FA@msxny2.windows.tower-research.com> References: <4615F466BD17634BB399D1232F9D687835C8E6FA@msxny2.windows.tower-research.com> Message-ID: Hi Omkar, Omkar Wagh writes: > :444:1 error: Expected comment or processing instruction > > std::string file_str(reinterpret_cast (plaintext)); > std::istringstream ptext_stream(file_str); This normally has something to do with encoding or stray characters in the XML string. What encoding is your XML in? Can you also print the string you have created and see what's at line 444? cerr << endl << "'" << file_str << "'" << endl; Boris From owagh at tower-research.com Tue May 6 09:37:07 2014 From: owagh at tower-research.com (Omkar Wagh) Date: Tue May 6 09:37:11 2014 Subject: [xsd-users] reading from string streams In-Reply-To: References: <4615F466BD17634BB399D1232F9D687835C8E6FA@msxny2.windows.tower-research.com>, Message-ID: <4615F466BD17634BB399D1232F9D687835C8FC24@msxny2.windows.tower-research.com> You are right... openssl does not null terminate strings while decrypting Thanks ________________________________________ From: Boris Kolpackov [boris@codesynthesis.com] Sent: Monday, May 05, 2014 8:11 PM To: Omkar Wagh Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] reading from string streams Hi Omkar, Omkar Wagh writes: > :444:1 error: Expected comment or processing instruction > > std::string file_str(reinterpret_cast (plaintext)); > std::istringstream ptext_stream(file_str); This normally has something to do with encoding or stray characters in the XML string. What encoding is your XML in? Can you also print the string you have created and see what's at line 444? cerr << endl << "'" << file_str << "'" << endl; Boris From vladimir.zykov at ncloudtech.ru Wed May 7 06:23:35 2014 From: vladimir.zykov at ncloudtech.ru (Vladimir Zykov) Date: Wed May 7 11:07:05 2014 Subject: [xsd-users] Ignoring unknown attributes/elements as if there were a wildcard in schema Message-ID: <553F7857-E144-4F9E-985C-E68AB6319748@ncloudtech.ru> Hi Boris, Is there any way to ignore/not validate attributes/elements that were not declared in schema but which occur in an XML instance? This might sound strange that we have XML schema that only partially describes XML markup but this is how Office Open XML handles extensions to the format. There is Markup Compatibility and Extensibility mechanism that allows certain attributes/elements anywhere in an XML document. Currently we add xs:anyAttribute/xs:any to complex types which we found can contain those MC extensions but this is tedious and will not work reliably (unless we add wildcards to all complex types). Maybe there is a simpler way to fix it. We use XSD version 4.0.0.a14 in cxx-tree mode. Thanks Vladimir Zykov Software Engineer New Cloud Technologies, LLC From boris at codesynthesis.com Wed May 7 11:33:53 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 7 11:31:23 2014 Subject: [xsd-users] Ignoring unknown attributes/elements as if there were a wildcard in schema In-Reply-To: <553F7857-E144-4F9E-985C-E68AB6319748@ncloudtech.ru> References: <553F7857-E144-4F9E-985C-E68AB6319748@ncloudtech.ru> Message-ID: Hi Vladimir, Vladimir Zykov writes: > Is there any way to ignore/not validate attributes/elements that were > not declared in schema but which occur in an XML instance? The only way to do this is to disable validation. The object model parsing code will ignore such extra elements/attributes. Boris From alexander.gosling at kongsberg.com Mon May 12 11:56:55 2014 From: alexander.gosling at kongsberg.com (alexander.gosling@kongsberg.com) Date: Mon May 12 11:57:07 2014 Subject: [xsd-users] Double definitions when using DLLs In-Reply-To: References: Message-ID: Hi, We have looked at the solution, and it is ok as a temporary work around. Are there any plans to fix this more permanently? -- alex -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: 5. mai 2014 18:55 To: Gosling, Alexander Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Double definitions when using DLLs Alexander, I believe you can resolve this issue if you can make one of the DLLs "root" and export std::basic_string from it while importing it in all the other DLLs and your executable. This earlier post has the instructions: http://www.codesynthesis.com/pipermail/xsd-users/2010-September/003011.html With this email containing more analysis/information on the problem: http://www.codesynthesis.com/pipermail/xsd-users/2010-September/003019.html Let me know how it goes or if something is not clear. Boris ________________________________ CONFIDENTIALITY This e-mail and any attachment contain KONGSBERG information which may be proprietary, confidential or subject to export regulations, and is only meant for the intended recipient(s). Any disclosure, copying, distribution or use is prohibited, if not otherwise explicitly agreed with KONGSBERG. If received in error, please delete it immediately from your system and notify the sender properly. From boris at codesynthesis.com Mon May 12 23:35:12 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 12 23:32:40 2014 Subject: [xsd-users] Double definitions when using DLLs In-Reply-To: References: Message-ID: Hi Alexander, alexander.gosling@kongsberg.com writes: > Are there any plans to fix this more permanently? This is really a problem in the MS toolchain. Essentially, with VC++ it is impossible to derive from std::string if DLLs are used. Unfortunately there is no easy way to work around this problem from our side. The "permanent" way to fix this would be to stop deriving from std::string. But that would also remove fairly useful functionality: right now one can pass xml_schema::string (or any other string-based type) to an interface that expects std::string and everything will work out of the box. Removing this functionality for everyone just because Microsoft's toolchain is broken seems like a bad idea. Note also that it is already possible to customize the xs:string type and provide your own implementation without inheritance. Maybe providing a custom implementation like this and instructions that describe how to set everything up would be sufficient? Boris From alexander.gosling at kongsberg.com Wed May 14 04:56:35 2014 From: alexander.gosling at kongsberg.com (alexander.gosling@kongsberg.com) Date: Wed May 14 04:56:50 2014 Subject: [xsd-users] Double definitions when using DLLs In-Reply-To: References: Message-ID: Thanks for the useful tip :) We will do this. -- alex -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: 13. mai 2014 05:35 To: Gosling, Alexander Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Double definitions when using DLLs Hi Alexander, alexander.gosling@kongsberg.com writes: > Are there any plans to fix this more permanently? This is really a problem in the MS toolchain. Essentially, with VC++ it is impossible to derive from std::string if DLLs are used. Unfortunately there is no easy way to work around this problem from our side. The "permanent" way to fix this would be to stop deriving from std::string. But that would also remove fairly useful functionality: right now one can pass xml_schema::string (or any other string-based type) to an interface that expects std::string and everything will work out of the box. Removing this functionality for everyone just because Microsoft's toolchain is broken seems like a bad idea. Note also that it is already possible to customize the xs:string type and provide your own implementation without inheritance. Maybe providing a custom implementation like this and instructions that describe how to set everything up would be sufficient? Boris ________________________________ CONFIDENTIALITY This e-mail and any attachment contain KONGSBERG information which may be proprietary, confidential or subject to export regulations, and is only meant for the intended recipient(s). Any disclosure, copying, distribution or use is prohibited, if not otherwise explicitly agreed with KONGSBERG. If received in error, please delete it immediately from your system and notify the sender properly. From debian at jff-webhosting.net Mon May 19 11:56:20 2014 From: debian at jff-webhosting.net (=?ISO-8859-1?Q?J=F6rg_Frings-F=FCrst?=) Date: Mon May 19 11:56:24 2014 Subject: [xsd-users] Re: xsd - Package in debian In-Reply-To: <1397127897.29594.8.camel@merkur> References: <1397127897.29594.8.camel@merkur> Message-ID: <1400514980.31979.28.camel@merkur> Hello, Am Donnerstag, den 10.04.2014, 13:04 +0200 schrieb J?rg Frings-F?rst: > Hallo, > > my name is J?rg Frings-F?rst and I live in a small village near by > Trier, Germany. > > I'm the new debian maintainer for the xsd-package. The package was > updated to V 3.3.0.2 and is now in the sponsoring queue. > > > I hope for a good collaboration. > > Have a nice day > > J?rg > sorry for my delayed work. In debian everything takes a little longer. The package in version 3.3.0.2-2 is through the sponsoring and uploaded to testing. After 5 days it will be uploaded in unstable. Regards, J?rg -- pgp Fingerprint: 7D13 3C60 0A10 DBE1 51F8 EBCB 422B 44B0 BE58 1B6E pgp Key: BE581B6E CAcert Key S/N: 0E:D4:56 J?rg Frings-F?rst D-54526 Niederkail IRC: j_f-f@freenode.net j_f-f@oftc.net -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20140519/0f47bfb8/attachment.pgp From boris at codesynthesis.com Mon May 19 14:37:04 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 19 14:34:35 2014 Subject: [xsd-users] Re: xsd - Package in debian In-Reply-To: <1400514980.31979.28.camel@merkur> References: <1397127897.29594.8.camel@merkur> <1400514980.31979.28.camel@merkur> Message-ID: Hi J?rg, J?rg Frings-F?rst writes: > The package in version 3.3.0.2-2 is through the sponsoring and uploaded > to testing. After 5 days it will be uploaded in unstable. Thanks for the update. As a minor correction, I think you meant that it has been uploaded to unstable and after 5 days it will be in testing. Boris From sabitha.reddi at gmail.com Mon May 19 14:53:35 2014 From: sabitha.reddi at gmail.com (sabitha reddy) Date: Mon May 19 14:53:43 2014 Subject: [xsd-users] Error in compilation and question about parsing Message-ID: Hello Dev's, I am using XDS of CodeSynthesis to geenrate C++ classes by c++ tree mapping. When I try to create an object of any class, I am getting following compilation error: error: request for member host in h, which is of non-class type std::auto_ptr ()(Hosts*) My code: auto_ptr h(Hosts (argv[1])); Hosts::host_sequence& hs (h->host ()); And also, my other question is, if we create an object without sending xml file, is there any way I can read it later into the object?, Any help would be greatly appreciated. Thanks in advance. Regards, Sabitha From boris at codesynthesis.com Mon May 19 20:40:34 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 19 20:38:00 2014 Subject: [xsd-users] Error in compilation and question about parsing In-Reply-To: References: Message-ID: Hi Sabitha, sabitha reddy writes: > auto_ptr h(Hosts (argv[1])); In XSD, this line has the following pattern: auto_ptr h (ElementName (argv[1])); If both your ElementName and TypeName are actually the same name, then XSD append '_' at the end to make ElementName. So in your case the code most likely should look like this: auto_ptr h (Hosts_ (argv[1])); > And also, my other question is, if we create an object without sending xml > file, is there any way I can read it later into the object?, I am not sure I understand what you are trying to achieve. If it is already an object, why would you need to later read into an object? Boris From sabitha.reddi at gmail.com Mon May 19 22:28:59 2014 From: sabitha.reddi at gmail.com (sabitha reddy) Date: Mon May 19 22:29:06 2014 Subject: [xsd-users] Error in compilation and question about parsing In-Reply-To: References: Message-ID: Hey Boris, I really appreciate your help. It worked after I changed it to: auto_ptr h(hosts (argv[1])); Hosts::host_sequence& hs (h->host ()); My second question was: We create Hosts object by sending xml file name as input[argv[1]. Instead is there a way I can do it by sending my xml data as char string and not by writing it to file and passing file name?. And also, my test program worked only after I specified the XSD file path in input xml file as follows: Is there any way I can avoid this?. My xml file is generated by some other source and its difficult to edit to add the xsd path to it. Thanks in advance for your help. Regards, Sabitha. On Mon, May 19, 2014 at 8:40 PM, Boris Kolpackov wrote: > Hi Sabitha, > > sabitha reddy writes: > > > auto_ptr h(Hosts (argv[1])); > > In XSD, this line has the following pattern: > > auto_ptr h (ElementName (argv[1])); > > If both your ElementName and TypeName are actually the same name, then > XSD append '_' at the end to make ElementName. So in your case the code > most likely should look like this: > > auto_ptr h (Hosts_ (argv[1])); > > > > And also, my other question is, if we create an object without sending > xml > > file, is there any way I can read it later into the object?, > > I am not sure I understand what you are trying to achieve. If it is > already an object, why would you need to later read into an object? > > Boris > From boris at codesynthesis.com Tue May 20 19:09:16 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 20 19:06:41 2014 Subject: [xsd-users] Error in compilation and question about parsing In-Reply-To: References: Message-ID: Hi Sabitha sabitha reddy writes: > We create Hosts object by sending xml file name as input[argv[1]. Instead > is there a way I can do it by sending my xml data as char string and not by > writing it to file and passing file name? Yes, you can, for example, use std::istringstream. See Chapter 5, "Parsing" in the C++/Tree Mapping Getting Started Guide: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#5 > And also, my test program worked only after I specified the XSD file > path in input xml file as follows: > > xsi:noNamespaceSchemaLocation="hosts_file.xsd"> > > Is there any way I can avoid this? Yes, see Section 5.1, "XML Schema Validation and Searching" in the C++/Tree Mapping Getting Started Guide: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#5.1 As you can see, your questions are already answered in the documentation. In the future, please consult it before posting questions to the mailing list. Boris From soroush.rabiei at gmail.com Tue May 27 02:20:57 2014 From: soroush.rabiei at gmail.com (Soroush Rabiei) Date: Tue May 27 02:21:24 2014 Subject: [xsd-users] xsd-generated code ignores attributes Message-ID: Hi I have a problem with my XSD schema. I'm not sure if I'm defining XSD in a wrong way or there is something to do with XSD-C++ tree map. The problem is that attributes are simply ignored by the parser. For example the "presentation" element type is defined like this: And this type is used somewhere is "instance" element type: Finally, there is only one "instance" element which is root element in document: And corresponding parser source is: class XPresentationParser: public presentation_t_pskel { public: XPresentationParser(CSP_Problem&); ~XPresentationParser(); void name(const std::string&); void type(const AIT::CSP::CSP_Problem::Type&); private: CSP_Problem& instance; }; The "name" and "type" member functions in above code are never called. This happens for all my elements that have attributes. Contents are parsed successfully but all attributes are ignored. From chew.on.it at gmail.com Tue May 27 08:25:36 2014 From: chew.on.it at gmail.com (Chew kk) Date: Tue May 27 09:35:27 2014 Subject: [xsd-users] Codesynthesis XSD Access Violation using xsd:any Message-ID: Hi, I'm getting an exception "Unhandled exception at 0x1202e9fd (xerces-c_3_1D_vc100.dll) in driver.exe: 0xC0000005: Access violation reading location 0xfeeefef6" when I tried to run the following code. Appreciate if someone could help. I'm using generate-wildcard and generate-serialization with the xsd. My intention is to keep the optional element when the xsd serialize the xml after modification. xercesc::XMLPlatformUtils::Initialize (); if (argc != 2) { cerr << "usage: " << argv[0] << " hello.xml" << endl; return 1; } try { auto_ptr h (hello (argv[1], xml_schema::flags::keep_dom | xml_schema::flags::dont_initialize)); for (hello_t::name_const_iterator i (h->name ().begin ()); i != h->name ().end (); ++i) { cout << h->greeting () << ", " << *i << "!" << endl; } h->greeting("www"); //getch(); xml_schema::namespace_infomap map; map[""].schema = "hello.xsd"; // Serialize to a file. // std::ofstream ofs("hello.xml"); hello(ofs, *h, map,"UTF-8",xml_schema::flags::keep_dom|xml_schema::flags::dont_initialize); xercesc::XMLPlatformUtils::Terminate (); } catch (const xml_schema::exception& e) { cerr << e << endl; return 1; } Here's my xsd The hello_t type consists of a greeting phrase and a collection of names to which this greeting applies. The greeting element contains the greeting phrase for this hello object. The name elements contains names to be greeted. The hello element is a root of the Hello XML vocabulary. Every conforming document should start with this element. Thank You, Chew From knesmith at si2.org Tue May 27 17:02:09 2014 From: knesmith at si2.org (Kevin Nesmith) Date: Tue May 27 17:02:01 2014 Subject: [xsd-users] xsd:list of type xsd:integer problem Message-ID: <5384FD51.6060205@si2.org> When creating an element with a list of integers.... running this command with xsdcxx version 3.3.0 xsdcxx cxx-tree --char-encoding utf8 --hxx-suffix .h --cxx-suffix .cpp \ --extern-xml-schema xml_schema.h \ --generate-doxygen \ --root-element test \ --generate-serialization \ test.xsd then compiling in Fedora 17 with GCC 4.7.2(64bit) /usr/bin/g++ -c -Wall -fPIC -O2 -o test.o test.cpp In file included from /usr/include/xsd/cxx/tree/parsing.hxx:9:0, from xml_schema.h:69, from test.h:63, from test.cpp:41: /usr/include/xsd/cxx/tree/parsing.txx: In instantiation of 'void xsd::cxx::tree::list::init(const std::basic_string&, const xercesc_3_1::DOMElement*) [with T = long long int; C = char; xsd::cxx::tree::schema_type::value ST = (xsd::cxx::tree::schema_type::value)0u]': /usr/include/xsd/cxx/tree/parsing.txx:258:9: required from 'xsd::cxx::tree::list::list(const xercesc_3_1::DOMElement&, xsd::cxx::tree::flags, xsd::cxx::tree::container*) [with T = long long int; C = char; xsd::cxx::tree::schema_type::value ST = (xsd::cxx::tree::schema_type::value)0u; xsd::cxx::tree::container = xsd::cxx::tree::_type]' test.cpp:11234:72: required from here /usr/include/xsd/cxx/tree/parsing.txx:302:13: error: 'push_back' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] /usr/include/xsd/cxx/tree/parsing.txx:302:13: note: declarations in dependent base 'std::vector >' are not found by unqualified lookup /usr/include/xsd/cxx/tree/parsing.txx:302:13: note: use 'this->push_back' instead /usr/include/xsd/cxx/tree/parsing.txx:312:13: error: 'push_back' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] /usr/include/xsd/cxx/tree/parsing.txx:312:13: note: declarations in dependent base 'std::vector >' are not found by unqualified lookup /usr/include/xsd/cxx/tree/parsing.txx:312:13: note: use 'this->push_back' instead make: *** [test.o] Error 1 If I change the *itemType* from *xsd:integer* to *xsd:string*, it compiles fine. I double check with WC3, their examples include an xsd:integer suggesting to me that this should work. (http://www.w3schools.com/schema/el_list.asp) Do you see something I am doing wrong, or is there a work around? Thanks in advanced, -- *Kevin Nesmith* /Chief Architect/ *Silicon Integration Initiative, Inc.* From boris at codesynthesis.com Wed May 28 04:12:54 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 28 04:10:15 2014 Subject: [xsd-users] xsd-generated code ignores attributes In-Reply-To: References: Message-ID: Hi Soroush, Soroush Rabiei writes: > [...] or there is something to do with XSD-C++ tree map. You seem to be using the C++/Parser mapping, not C++/Tree. Or are you talking about "type map", not "tree map"? Generally, when describing a problem, try to be precise. Otherwise there is no guarantee we will be talking about the same thing. > class XPresentationParser: public presentation_t_pskel > { > void name(const std::string&); > void type(const AIT::CSP::CSP_Problem::Type&); > }; In your schema, you don't have the "type" attribute. You have "format" instead. So that would explain why the type() function is not called. To understand why name() is not called, check the signature of that function in presentation_t_pskel and make sure that it matches what you have in XPresentationParser. Boris From boris at codesynthesis.com Wed May 28 04:17:47 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 28 04:15:12 2014 Subject: [xsd-users] Codesynthesis XSD Access Violation using xsd:any In-Reply-To: References: Message-ID: Hi Chew, You don't need to use keep_dom with --generate-wildcard. While it shouldn't make your code crash, try to remove this flag from both parsing and serialization and see if anything changes. Other than that, I don't see anything wrong with your code. Can you run it under the debugger and show the stack trace of the access violation? Boris From boris at codesynthesis.com Wed May 28 04:25:19 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 28 04:22:39 2014 Subject: [xsd-users] xsd:list of type xsd:integer problem In-Reply-To: <5384FD51.6060205@si2.org> References: <5384FD51.6060205@si2.org> Message-ID: Hi Kevin, Kevin Nesmith writes: > /usr/include/xsd/cxx/tree/parsing.txx:302:13: error: 'push_back' was > not declared in this scope, and no declarations were found by > argument-dependent lookup at the point of instantiation > > /usr/include/xsd/cxx/tree/parsing.txx:312:13: error: 'push_back' was > not declared in this scope, and no declarations were found by > argument-dependent lookup at the point of instantiation This is a known problem with newer C++ compilers (GCC, Clang) that has been fixed for the next release (out soon). The fix is to qualify these calls to push_back() with 'this->'. There is a patch that fixes all these issues in the vanilla 3.3.0 distribution: http://codesynthesis.com/~boris/tmp/xsd/xsd-3.3.0-gcc-4.7-clang.patch Chances are, however, that the Fedora package already has some of those fixes applied, in which case it would probably be easier to just add 'this->' in those two places manually. Boris From knesmith at si2.org Wed May 28 08:05:01 2014 From: knesmith at si2.org (Kevin Nesmith) Date: Wed May 28 08:04:51 2014 Subject: [xsd-users] xsd:list of type xsd:integer problem In-Reply-To: References: <5384FD51.6060205@si2.org> Message-ID: <5385D0ED.5030106@si2.org> Thank you Boris. Kevin On 5/28/14, 3:25 AM, Boris Kolpackov wrote: > Hi Kevin, > > Kevin Nesmith writes: > >> /usr/include/xsd/cxx/tree/parsing.txx:302:13: error: 'push_back' was >> not declared in this scope, and no declarations were found by >> argument-dependent lookup at the point of instantiation >> >> /usr/include/xsd/cxx/tree/parsing.txx:312:13: error: 'push_back' was >> not declared in this scope, and no declarations were found by >> argument-dependent lookup at the point of instantiation > This is a known problem with newer C++ compilers (GCC, Clang) that has > been fixed for the next release (out soon). The fix is to qualify > these calls to push_back() with 'this->'. There is a patch that fixes > all these issues in the vanilla 3.3.0 distribution: > > http://codesynthesis.com/~boris/tmp/xsd/xsd-3.3.0-gcc-4.7-clang.patch > > Chances are, however, that the Fedora package already has some > of those fixes applied, in which case it would probably be > easier to just add 'this->' in those two places manually. > > Boris From chew.on.it at gmail.com Fri May 30 10:17:11 2014 From: chew.on.it at gmail.com (Chew kk) Date: Fri May 30 11:36:09 2014 Subject: [xsd-users] Codesynthesis XSD Access Violation using xsd:any In-Reply-To: References: Message-ID: Hi Boris, I think the problem is the position of the call to xercesc::XMLPlatformUtils::Terminate (). I moved it to after the catch and am not seeing the exception again. How can this be explained? Regards, Chew On Wed, May 28, 2014 at 4:17 PM, Boris Kolpackov wrote: > Hi Chew, > > You don't need to use keep_dom with --generate-wildcard. While it > shouldn't make your code crash, try to remove this flag from both > parsing and serialization and see if anything changes. > > Other than that, I don't see anything wrong with your code. Can > you run it under the debugger and show the stack trace of the > access violation? > > Boris > From boris at codesynthesis.com Fri May 30 11:41:59 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri May 30 11:39:19 2014 Subject: [xsd-users] Codesynthesis XSD Access Violation using xsd:any In-Reply-To: References: Message-ID: Hi Chew, Chew kk writes: > I think the problem is the position of the call to > xercesc::XMLPlatformUtils::Terminate (). I moved it to after the catch and > am not seeing the exception again. How can this be explained? Ah, that's right, I haven't noticed the Terminate() call. Now it makes perfect sense. You terminate Xerces-C++ before the object model (which contains the Xerces-C++ DOM fragments for wildcards) is deleted. Boris From leon at securigy.com Fri May 30 19:51:57 2014 From: leon at securigy.com (Leon) Date: Sat May 31 04:15:20 2014 Subject: [xsd-users] generating C++ class from XML instance document (not schema) Message-ID: <1401493917.10214.YahooMailNeo@web142505.mail.bf1.yahoo.com> I am composing XML file that serves as Camera Description File and is based on the following schema: http://www.emva.org/cms/upload/Standards/GenICam_Downloads/GenApiSchema_Version_1_1.xsd It is very large and comprehensive schema for cameras. Questions: 1. Is that something that you think you can compile with your XSD compiler? 2. If I generated XML file based on this schema, is there any way or tools that I can generate C++ classes from this XML file?? (and not from schema - because my XML file includes only a fraction of what's in the schema) Leon From boris at codesynthesis.com Sat May 31 04:45:02 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sat May 31 04:42:22 2014 Subject: [xsd-users] generating C++ class from XML instance document (not schema) In-Reply-To: <1401493917.10214.YahooMailNeo@web142505.mail.bf1.yahoo.com> References: <1401493917.10214.YahooMailNeo@web142505.mail.bf1.yahoo.com> Message-ID: Hi Leon, Leon writes: > It is very large and comprehensive schema for cameras. > > 1. Is that something that you think you can compile with your XSD compiler? This is actually a very tame schema, compared to other stuff out there ;-). I just tried to compile it and there doesn't seem to be any issues. > 2. If I generated XML file based on this schema, is there any way or tools > that I can generate C++ classes from this XML file? (and not from schema - > because my XML file includes only a fraction of what's in the schema) Generally, trying to get from XML to XML Schema (or C++ classes) is a very error-prone process except for really simple cases. If you still want to go this route, then I think your best bet is to look for an XML-to-XML Schema tool rather than XML-to-C++. I personally haven't used any but this SO page has some recommendations: http://stackoverflow.com/questions/74879/any-tools-to-generate-an-xsd-schema-from-an-xml-instance-document Boris > > Leon