From justinjose12002 at gmail.com Thu Sep 1 09:26:24 2011 From: justinjose12002 at gmail.com (Justin Jose) Date: Thu Sep 1 09:26:51 2011 Subject: [xsd-users] Serialization issue with Latin characters Message-ID: I am facing an issue related to serialization. My xsd: I have used xsd cxx-tree to generate classes from xsd. I am able to serialize xml for normall english characeters but getting exception while using the value "Union pour le financement d'Immeubles de Soci?t?s" Throwing exception when I serialize the object. I found that this is because of some spl charaters in "Soci?t?s" So I tried with wchar_t commandline option; Now I am not getting exception while serialization but the XML string looks not correct: Any help really appriciated. Please ask me if you need any more info..Thanks in advance. Justin From boris at codesynthesis.com Thu Sep 1 10:25:16 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 1 10:27:47 2011 Subject: [xsd-users] Serialization issue with Latin characters In-Reply-To: References: Message-ID: Hi Justin, Justin Jose writes: > I am able to serialize xml for normall english characeters but getting > exception while using the value "Union pour le financement d'Immeubles de > Soci?t?s" This is because by default XSD assumes that the object model text is encoded in UTF-8. '?t' in Soci?t?s is not a valid UTF-8 character sequence. The easiest way to resolve this is probably to switch to the ISO8859-1 (aka Latin1) encoding using the --char-encoding XSD compiler option: --char-encoding iso8859-1 See the XSD compiler command line manual (man pages) for details: http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml Boris From boris at codesynthesis.com Thu Sep 1 10:38:30 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 1 10:41:01 2011 Subject: [xsd-users] [xsd/cxx/tree/serialization/{float, double}.hxx] warning: comparing floating point with == or != is unsafe In-Reply-To: References: Message-ID: Hi Eric, Keller, Eric writes: > xsd/cxx/tree/serialization/float.hxx:35:37 > xsd/cxx/tree/serialization/double.hxx:33:35:37:85 > > warning: comparing floating point with == or != is unsafe These comparisons are there to detect special values (INF, NaN, etc) which have to be serialized specially. > unfortunately the gcc version we are using to compile, has some issue > with the #pragma GCC diagnostic push/ignored/pop so disabling these > warning is currently not possible... > > [...] > > Compiler version: gcc 4.4.3 #pragma GCC diagnostic is only supported in GCC 4.6 and up. Also, I tried to reproduce this since we don't get these warnings in our test builds. It seems that this warning has to explicitly requested with the -Wfloat-equal option. -Wall doesn't turn it on, not even -Wextra. I think that tell us that this warning is pretty useless because of the noise it creates. So my suggestion would be to remove the -Wfloat-equal option from your GCC command line. Boris From boris at codesynthesis.com Thu Sep 1 13:54:30 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 1 13:57:01 2011 Subject: [xsd-users] Serialization issue with Latin characters In-Reply-To: References: Message-ID: Hi Justin, In the future please keep your replies CC'ed to the xsd-users mailing list as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Justin Jose writes: > Hi Boris, > > Thanks alot for your quick reply. > > > I tried with the option --char-encoding iso8859-1 and also --char-encoding > lsp > I am not getting the exception now. But the string is still not proper. the > ? is coming as junk. > > > > > This is actually the correct encoding of '?' in UTF-8. See that encoding="UTF-8" attribute in the XML declaration? That means the document is in UTF-8 even though your application internally is using ISO8859-1. Generally, the input XML encoding, application encoding, and output XML encoding can all be different. If you want your XML to also be in ISO8859-1 (by default it is UTF-8), you will need to specify this encoding when calling one of the serialization functions, for example: root (std::cout, obj_model, map, "ISO8859-1"); Boris [The rest of the original email follows for context.] > > Didnt find any other encode header files under cxx/xml. > > Another way i can get the correct string? > > Thanks in advance. > Justin From justinjose12002 at gmail.com Fri Sep 2 07:24:04 2011 From: justinjose12002 at gmail.com (Justin Jose) Date: Fri Sep 2 07:24:33 2011 Subject: [xsd-users] Serialization issue with Latin characters In-Reply-To: References: Message-ID: Thanks alot Boris, It worked. Sure i will remember to CC xsd-users. Thanks Justin On 2 September 2011 01:54, Boris Kolpackov wrote: > Hi Justin, > > In the future please keep your replies CC'ed to the xsd-users > mailing list as discussed in the posting guidelines: > > http://www.codesynthesis.com/support/posting-guidelines.xhtml > > Justin Jose writes: > > > Hi Boris, > > > > Thanks alot for your quick reply. > > > > > > I tried with the option --char-encoding iso8859-1 and also > --char-encoding > > lsp > > I am not getting the exception now. But the string is still not proper. > the > > ? is coming as junk. > > > > > > > > > > > > This is actually the correct encoding of '?' in UTF-8. See that > encoding="UTF-8" attribute in the XML declaration? That means the > document is in UTF-8 even though your application internally is > using ISO8859-1. Generally, the input XML encoding, application > encoding, and output XML encoding can all be different. > > If you want your XML to also be in ISO8859-1 (by default it is > UTF-8), you will need to specify this encoding when calling one > of the serialization functions, for example: > > root (std::cout, obj_model, map, "ISO8859-1"); > > Boris > > [The rest of the original email follows for context.] > > > > > Didnt find any other encode header files under cxx/xml. > > > > Another way i can get the correct string? > > > > Thanks in advance. > > Justin > From Vaughan at Roberts.name Mon Sep 12 19:34:01 2011 From: Vaughan at Roberts.name (Vaughan Roberts) Date: Mon Sep 12 19:34:13 2011 Subject: [xsd-users] Using both cxx-tree and cxx-parser in one application Message-ID: <012b01cc71a4$74277560$5c766020$@Roberts.name> I have an application where I want to use cxx-parser to read in detailed information based on one xml-schema, but would like to output summary information using another xml-schema using cxx-tree after building its object model from the detailed one. The two schema have some common elements but I don't want to be locked into being forced to conform to the summary schema. Is it possible to have both cxx-parser and cxx-tree in one application? I have tried this, but I am having trouble with common typedefs between the two, e.g. these, amongst others, appear to have both a tree version and a parser version: typedef ::xsd::cxx::tree::buffer< char > buffer; typedef ::xsd::cxx::tree::flags flags; typedef ::xsd::cxx::tree::properties< char > properties; I am guessing that smart use of namespaces or header file inclusions may work, but I would appreciate a little guidance about how to do this. Best regards, Vaughan Mob: 0412 122 362 From boris at codesynthesis.com Tue Sep 13 09:59:28 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 13 10:02:01 2011 Subject: [xsd-users] Using both cxx-tree and cxx-parser in one application In-Reply-To: <012b01cc71a4$74277560$5c766020$@Roberts.name> References: <012b01cc71a4$74277560$5c766020$@Roberts.name> Message-ID: Hi Vaughan, Vaughan Roberts writes: > Is it possible to have both cxx-parser and cxx-tree in one application? Yes, that should be possible. You will need to re-map the XML Schema namespace (xml_schema) for one of the mappings. For example, you could add: --namespace-map http://www.w3.org/2001/XMLSchema=xml_schema_tree When compiling with cxx-tree and: --namespace-map http://www.w3.org/2001/XMLSchema=xml_schema_parser When compiling with cxx-parser. Also, if you use schemas with the same namespace in both mappings, then you will need to map them to different namespaces as well. See the XSD compiler command line manual (man pages) for details on the --namespace-map option: http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml Boris From Vaughan at Roberts.name Tue Sep 13 19:46:05 2011 From: Vaughan at Roberts.name (Vaughan Roberts) Date: Tue Sep 13 19:46:16 2011 Subject: [xsd-users] Using both cxx-tree and cxx-parser in one application In-Reply-To: References: <012b01cc71a4$74277560$5c766020$@Roberts.name> Message-ID: <018c01cc726f$4e20f1e0$ea62d5a0$@Roberts.name> Thanks Boris! I set the xsd namespace-map compiler option in the cxx-tree version as suggested below and that did the trick. Best regards, Vaughan Mob: 0412 122 362 -----Original Message----- From: xsd-users-bounces@codesynthesis.com [mailto:xsd-users-bounces@codesynthesis.com] On Behalf Of Boris Kolpackov Sent: Tuesday, 13 September 2011 23:59 To: Vaughan Roberts Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Using both cxx-tree and cxx-parser in one application Hi Vaughan, Vaughan Roberts writes: > Is it possible to have both cxx-parser and cxx-tree in one application? Yes, that should be possible. You will need to re-map the XML Schema namespace (xml_schema) for one of the mappings. For example, you could add: --namespace-map http://www.w3.org/2001/XMLSchema=xml_schema_tree When compiling with cxx-tree and: --namespace-map http://www.w3.org/2001/XMLSchema=xml_schema_parser When compiling with cxx-parser. Also, if you use schemas with the same namespace in both mappings, then you will need to map them to different namespaces as well. See the XSD compiler command line manual (man pages) for details on the --namespace-map option: http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml Boris From jason.friess at lmco.com Tue Sep 20 17:14:44 2011 From: jason.friess at lmco.com (Friess, Jason) Date: Tue Sep 20 17:15:00 2011 Subject: [xsd-users] Serialization of Polymorphic Sequences Message-ID: Hi, We are using CodeSynthesis XSD to generate C++ code from a set of XSD's that we have created and we have run into a potential issue. Several of the complexTypes defined in our schemas include polymorphic sequences. We have defined some sequences as sequences of some parent type but we would like to put child type instances in them. In our tests we have been able to put pointers to child type instances in the sequences - but when we serialize to XML the resulting XML does not seem to reflect the child instances. Is there something we are doing wrong? Thanks! Jason Example Code: // create a MessageType object from XML string - this works! std::istringstream iss (xml); auto_ptr mfs (Message (iss)); // create a ChildType object (subclass of ParentType) - this works! auto_ptr pt(new ChildType()); // add ChildType to MessageType Payload sequence - this works! mfs->Payload().push_back(pt); cout << endl << "-------------------------------------" << endl << "Message with ChildType payload "; // verify that element 0 is a ChildType - this works! - prints "valid derived pointer" ChildType *e0 = dynamic_cast(&mfs->Payload()[0]); if (e0) cout << "(valid derived pointer)" << endl << endl; else cout << "(invalid derived pointer)" << endl << endl; // display XML of modified MessageType object - this does not work! - the XML printed here does not reflect the ChildType instance - only that a ParentType has been included Message (cout, *mfs, map); From boris at codesynthesis.com Wed Sep 21 02:47:12 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 21 02:49:44 2011 Subject: [xsd-users] Serialization of Polymorphic Sequences In-Reply-To: References: Message-ID: Hi Jason, Friess, Jason writes: > // display XML of modified MessageType object - this does not work! - the > // XML printed here does not reflect the ChildType instance - only that a > // ParentType has been included > > Message (cout, *mfs, map); Your code looks fine to me. Have you compiled your schemas with the --generate-polymorphic option and used the --polymorphic-type option to mark ParentType as the root of a polymorphic type hierarchy? See the XSD compiler command line manual (man pages) for more information on these options: http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml Boris From jason.friess at lmco.com Wed Sep 21 16:53:19 2011 From: jason.friess at lmco.com (Friess, Jason) Date: Wed Sep 21 16:53:40 2011 Subject: EXTERNAL: Re: [xsd-users] Serialization of Polymorphic Sequences In-Reply-To: References: Message-ID: Thanks! Using "--polymorphic-type ParentType" when generating the C++ code seems to work for us. It seems like CodeSynthesis was not automatically recognizing ParentType as the root of a polymorphic type hierarchy (probably because we're not using "substitutionGroup" declarations in our XSD's. We are now seeing the result we're expecting when serializing to XML. Thanks, Jason -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Wednesday, September 21, 2011 2:47 AM To: Friess, Jason Cc: xsd-users@codesynthesis.com; Pravia, Marco (US SSA); Olbert, Adolf (US SSA); Dibona, Phillip J; basil.krikeles@baesystems.com; Czajkowski, Michael; Jameson, Stephen M Subject: EXTERNAL: Re: [xsd-users] Serialization of Polymorphic Sequences Hi Jason, Friess, Jason writes: > // display XML of modified MessageType object - this does not work! - the > // XML printed here does not reflect the ChildType instance - only that a > // ParentType has been included > > Message (cout, *mfs, map); Your code looks fine to me. Have you compiled your schemas with the --generate-polymorphic option and used the --polymorphic-type option to mark ParentType as the root of a polymorphic type hierarchy? See the XSD compiler command line manual (man pages) for more information on these options: http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml Boris From mjklaim at gmail.com Tue Sep 27 09:57:31 2011 From: mjklaim at gmail.com (=?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?=) Date: Tue Sep 27 09:57:41 2011 Subject: [xsd-users] [xsd][tree] The parent object Message-ID: Hi, As I didn't find anything about that, I'm supposing it's not possible but I need to be sure : Once I've parsed an xml file and get the C++ instances (wich types are generated using xsd), given one object, is there a way to get the parent object, that is the object that contains this object? I don't see anything like that in the code but I'm not sure so can you confirm that it's not possible? Thanks. Jo?l Lamotte From erik.sjolund at gmail.com Tue Sep 27 10:25:21 2011 From: erik.sjolund at gmail.com (=?ISO-8859-1?Q?Erik_Sj=F6lund?=) Date: Tue Sep 27 10:25:29 2011 Subject: [xsd-users] [xsd][tree] The parent object In-Reply-To: References: Message-ID: I think you can use the member function _container() See for instance: http://www.codesynthesis.com/pipermail/xsd-users/2007-June/001046.html cheers, Erik Sj?lund 2011/9/27 Klaim - Jo?l Lamotte : > Hi, > > As I didn't find anything about that, I'm supposing it's not possible but I > need to be sure : > > Once I've parsed an xml file and get the C++ instances (wich types are > generated using xsd), > given one object, is there a way to get the parent object, that is the > object that contains this object? > > I don't see anything like that in the code but I'm not sure so can you > confirm that it's not possible? > > Thanks. > > Jo?l Lamotte >