From manav.rathi at incainformatics.com Fri Aug 1 08:39:49 2008 From: manav.rathi at incainformatics.com (Manav Rathi) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Copying xml_schema::exception In-Reply-To: <20080529130155.GA24115@karelia> Message-ID: <20080801124122.958CC1B529E@relay7.relay.sat.mlsrvr.com> I need to store a copy of the xml_schema::exception that I catch at a certain point in my code (I cannot propogate the exception at the point where I am catching it, so I thought I might store it and then throw it later from an appropriate function). Using the xml_schema::exception copy_constructor will lead to slicing. Any other ideas on how I might polymorphically copy it ? Thanks, Manav From gennadiy.katz at thomsonreuters.com Fri Aug 1 09:32:44 2008 From: gennadiy.katz at thomsonreuters.com (Gennadiy Katz) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] RE: Uncaught bounce notification In-Reply-To: <20080731204840.GD16413@karelia> Message-ID: Hello, My application throws exception "Priviledge instruction" from within xsd::cxx::tree::element_one ::~element_one () destructor while releasing internal xercesc::DOMElement* pointer. Any ideas why this may happen? Thank you -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Thursday, July 31, 2008 4:49 PM To: Gennadiy Katz Subject: Re: Uncaught bounce notification Hi Gennadiy, I was forwarded the below email which apparently was sent to xsd-users-bounces@codesynthesis.com. The proper email address for the xsd-users mailing list is xsd-users@codesynthesis.com Could you please re-send it to the correct email and also use that email in the future. Thank you, Boris mailman-bounces@codesynthesis.com writes: > The attached message was received as a bounce, but either the bounce > format was not recognized, or no member addresses could be extracted > from it. This mailing list has been configured to send all > unrecognized bounce messages to the list administrator(s). > > For more information see: > http://codesynthesis.com/mailman/admin/xsd-users/bounce > > From: Gennadiy Katz > Subject: xsd::cxx::tree::element_one::~element_one exception > Date: Thu, 31 Jul 2008 15:12:56 -0400 > Message-ID: > To: xsd-users-bounces@codesynthesis.com > > Hello, > > My application throws exception "Priviledge instruction" > from within xsd::cxx::tree::element_one ::~element_one () destructor > while releasing internal xercesc::DOMElement* pointer. Any ideas why > this may happen? > > Thank you > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * > Gennadiy Katz > Lead Software Engineer > > Thomson Reuters > > O (646)223-7724X 7724 > > gennadiy.katz@thomsonreuters.com > thomsonreuters.com > > > From boris at codesynthesis.com Fri Aug 1 10:01:15 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] serialization without pretty print In-Reply-To: <93E3AED1E31FB448AD0BDBE14BA50B1D02397380@EX01.dtn.com> References: <93E3AED1E31FB448AD0BDBE14BA50B1D02397380@EX01.dtn.com> Message-ID: <20080801140115.GA24298@karelia> Hi Mark, Mark Stevens writes: > I am also interested in switching off pretty print dynamically. > Per the message below, it appears that a patch was made in version > 3.1.1. > > Do you have a release date for a Solaris sparc bin release with this > patch included? The tentative release date for 3.1.1 is mid-September. There is going to be a beta release for 3.1.1 end of next week. We can build a SPARC binary if you would like to test/use it. Also note that the patch only affects headers in the XSD runtime (libxsd) so it is possible to apply this patch and use the stock XSD 3.1.0 compiler binaries. Boris From boris at codesynthesis.com Fri Aug 1 10:27:12 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Copying xml_schema::exception In-Reply-To: <20080801124122.958CC1B529E@relay7.relay.sat.mlsrvr.com> References: <20080529130155.GA24115@karelia> <20080801124122.958CC1B529E@relay7.relay.sat.mlsrvr.com> Message-ID: <20080801142712.GB24298@karelia> Hi Manav, Manav Rathi writes: > I need to store a copy of the xml_schema::exception that I catch at a > certain point in my code (I cannot propogate the exception at the point > where I am catching it, so I thought I might store it and then throw it > later from an appropriate function). > > Using the xml_schema::exception copy_constructor will lead to slicing. Any > other ideas on how I might polymorphically copy it ? There is no way to clone the exception polymorphically. Even if there was a way, you won't be able to re-throw it without slicing. If all you need when you are handling the exception is to print it then you can do that when you first catch it and store the string instead of the exception: try { ... } catch (const xml_schema::exception& e) { std::ostringstream os; os << e; std::string s = os.str (); // store s } Otherwise, the only way would be catch and handle each exception individually. Perhaps a little template like this will be helpful: struct holder { virtual ~holder () {} virtual void rethrow (); }; template struct holder_impl { holder_impl (const X& x) : x_ (x) virtual void rethrow () { throw x_; } private: X x_; }; std::auto_ptr h; try { ... } catch (const xml_schema::parsing& e) { h.reset (new holder_impl (x)); } catch (const xml_schema::expected_element& e) { h.reset (new holder_impl (x)); } ... if (h.get () != 0) h->rethrow (); Boris From boris at codesynthesis.com Fri Aug 1 10:33:00 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Re: xsd::cxx::tree::element_one::~element_one exception In-Reply-To: References: <20080731204840.GD16413@karelia> Message-ID: <20080801143300.GC24298@karelia> Hi Gennadiy, Gennadiy Katz writes: > My application throws exception "Priviledge instruction" > from within xsd::cxx::tree::element_one ::~element_one () destructor > while releasing internal xercesc::DOMElement* pointer. Any ideas why > this may happen? Most likely one of the following is happening: 1. You did not initialize the Xerces-C++ runtime as instructed in Section 2.12, "Mapping for any and anyAttribute": http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.12 2. But the more likely scenario in this case is the you terminate the Xerces-C++ runtime before the object model is destroyed. If none of these apply then we would need a test program that reproduces the problem (feel free to send it to me directly if you want to keep your code private). Boris From boris at codesynthesis.com Fri Aug 1 10:57:28 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] DbXml update In-Reply-To: <20080718125301.GB6852@karelia> References: <3542C03D-B2DB-42F7-8662-274762AFF612@mac.com> <20080718125301.GB6852@karelia> Message-ID: <20080801145728.GD24298@karelia> Hi Michael, Boris Kolpackov writes: > I've written to the DB XML folks to find out if they have plans > to support this in the near future. Will let you know what they > say. Ok, I've had a lengthy discussion with the DB XML folks regarding this issue. In short, currently there is no way to update a document fragment (as returned in XmlValue by a query) other than maybe running another XQuery. They are, however, thinking of extending the API to allow something along these lines (not an actual interface): XmlValue v; XmlResults res(mgr.query(...)); if (res.next(v)) { XmlResults fragRes = mgr.createResults(); XmlEventWriter &w = fragRes.asEventWriter(); // write w.close(); // see this function, below replaceNode(mgr, v, fragRes); } void replaceNode(XmlManager &mgr, XmlValue &v, XmlResults &res) { XmlQueryContext qc = mgr.createQueryContext(); qc.setVariableValue("node", $v); qc.setVariableValue("newNode", $res); mgr.query(qc, "replace node $node with $newNode"); } As you can see it will still involve XQuery so I don't know what kind of performance this method can achieve (though the DB XML folks say that it will be faster than the DOM approach). It also requires the user to perform a lot more actions compared the old approach. Generally, the common theme in our discussion was that they want to minimize the number of different ways it is possible to update documents so XQuery becomes the only way. This is obviously not how we think people prefer to perform complex document modifications so I am not sure there will be future for the XSD/DB XML integration should they go this direction. They, however, welcome feedback from their users, especially the paying ones ;-). So feel free to let them know how you use DB XML and what you need in terms of APIs. Boris From Raymond.Rizzuto at sig.com Tue Aug 5 09:35:07 2008 From: Raymond.Rizzuto at sig.com (Rizzuto, Raymond) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] wsdl support - slightly off-topic question Message-ID: I was wondering if there is any way to use xsd to compile a wsdl file into classes that can invoke remote method calls over soap. I know this is a long shot, but since wsdl is xml-based, I though I might as well ask. I'm open to any other suggestions, commercial or open source. The reason I ask is that I am looking for an alternate to the current tool we use for generating C++ classes/functions from a wsdl file. The current tool we use has very high costs, and the vendor isn't very responsive. Ray ________________________________ Ray Rizzuto raymond.rizzuto@sig.com Susquehanna International Group (610)747-2336 (W) (215)776-3780 (C) ________________________________ IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses. From atteeela at gmail.com Tue Aug 5 10:38:36 2008 From: atteeela at gmail.com (Attila) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] wsdl support - slightly off-topic question In-Reply-To: References: Message-ID: <4aeb04aa0808050738m50cb4134rd0fae4688b9dce74@mail.gmail.com> I have used gSOAP before with pretty good success. The one thing that I find lacking is support for non-standard interactions (such as notification/subscription interfaces). Also the client SOAP calls are blocking and takes some work to make it non-blocking. What tool do you use from before? I have explored a few options myself, but gSOAP still seems to come out on top. On Tue, Aug 5, 2008 at 9:35 AM, Rizzuto, Raymond wrote: > I was wondering if there is any way to use xsd to compile a wsdl file into > classes that can invoke remote method calls over soap. I know this is a > long shot, but since wsdl is xml-based, I though I might as well ask. I'm > open to any other suggestions, commercial or open source. > > The reason I ask is that I am looking for an alternate to the current tool > we use for generating C++ classes/functions from a wsdl file. The current > tool we use has very high costs, and the vendor isn't very responsive. > > Ray > > ________________________________ > Ray Rizzuto > raymond.rizzuto@sig.com > Susquehanna International Group > (610)747-2336 (W) > (215)776-3780 (C) > > > > ________________________________ > IMPORTANT: The information contained in this email and/or its attachments > is confidential. If you are not the intended recipient, please notify the > sender immediately by reply and immediately delete this message and all its > attachments. Any review, use, reproduction, disclosure or dissemination of > this message or any attachment by an unintended recipient is strictly > prohibited. Neither this message nor any attachment is intended as or should > be construed as an offer, solicitation or recommendation to buy or sell any > security or other financial instrument. Neither the sender, his or her > employer nor any of their respective affiliates makes any warranties as to > the completeness or accuracy of any of the information contained herein or > that this message or any of its attachments is free of viruses. > -- Attila Software Developer atteeela@gmail.com From sbalasub at qualcomm.com Tue Aug 5 13:35:00 2008 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] wsdl support - slightly off-topic question In-Reply-To: <4aeb04aa0808050738m50cb4134rd0fae4688b9dce74@mail.gmail.com> References: <4aeb04aa0808050738m50cb4134rd0fae4688b9dce74@mail.gmail.com> Message-ID: Hi, I have used XSD and gSOAP and here are my thoughts, XSD today is purely a data representation layer and has support for data binding as well. The feature that I liked most in XSD is the ability to associate a data binding to either one of the supported formats (XML, XDR, Boost archive, ACE CDR). I am sure this could be extended to any user required binding fairly easily. I believe boris has extended this to decouple the data and binding layer which IMO is really kewl. Supporting multiple data binding in the same runtime would be even great. gSOAP is very specific to SOAP protocol which is what you are specifically looking for. As you pointed out, gsoap provides one feature worth noting, RPC invocation when compared to XSD. However, gSOAP is not a true WSDL product for the reasons that WSDL provides multiple RPC protocols like JMS binding, http binding which gSOAP does not provide and rightfully not expected as well. The issue however is that once you change the RPC, all your client code now needs to be ripped off. So gSOAP is not for a forward looking application user. But I agree with Attila, if you are looking for something that fits only SOAP implementation of WSDL and are comfortable with interfaces that are tightly coupled with gSOAP, then it should work very well for you. The product is defnitely very stable and we use both gSOAP and XSD in our product. Ofcourse, we are in the path to get away from gSOAP for reasons mentioned above. My wish list for true SOA product would be [or what could be built using XSD that would make application developer life really simple], 1. Tuscany SCA architecture. 2. Use XSD for data representation layer. 3. WSDL 2.0 + additional interface support from SCA spec. [WSDL 2.0 would specifically help us to use XSD for generating all the message related schemas. It splits the data representation and RPC invocation layers more clearly.] Today, SCA uses SDO and DAS which IMO is cumbersome and I feel XSD solution would fit the requirements very well. Thanks, Shiva -----Original Message----- From: xsd-users-bounces@codesynthesis.com [mailto:xsd-users-bounces@codesynthesis.com] On Behalf Of Attila Sent: Tuesday, August 05, 2008 7:39 AM To: Rizzuto, Raymond Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] wsdl support - slightly off-topic question I have used gSOAP before with pretty good success. The one thing that I find lacking is support for non-standard interactions (such as notification/subscription interfaces). Also the client SOAP calls are blocking and takes some work to make it non-blocking. What tool do you use from before? I have explored a few options myself, but gSOAP still seems to come out on top. On Tue, Aug 5, 2008 at 9:35 AM, Rizzuto, Raymond wrote: > I was wondering if there is any way to use xsd to compile a wsdl file into > classes that can invoke remote method calls over soap. I know this is a > long shot, but since wsdl is xml-based, I though I might as well ask. > I'm open to any other suggestions, commercial or open source. > > The reason I ask is that I am looking for an alternate to the current > tool we use for generating C++ classes/functions from a wsdl file. > The current tool we use has very high costs, and the vendor isn't very responsive. > > Ray > > ________________________________ > Ray Rizzuto > raymond.rizzuto@sig.com > Susquehanna International Group > (610)747-2336 (W) > (215)776-3780 (C) > > > > ________________________________ > IMPORTANT: The information contained in this email and/or its > attachments is confidential. If you are not the intended recipient, > please notify the sender immediately by reply and immediately delete > this message and all its attachments. Any review, use, reproduction, > disclosure or dissemination of this message or any attachment by an > unintended recipient is strictly prohibited. Neither this message nor > any attachment is intended as or should be construed as an offer, > solicitation or recommendation to buy or sell any security or other > financial instrument. Neither the sender, his or her employer nor any > of their respective affiliates makes any warranties as to the > completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses. > -- Attila Software Developer atteeela@gmail.com From boris at codesynthesis.com Tue Aug 5 14:47:02 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] wsdl support - slightly off-topic question In-Reply-To: References: Message-ID: <20080805184702.GA30536@karelia> Hi Ray, Rizzuto, Raymond writes: > I was wondering if there is any way to use xsd to compile a wsdl file > into classes that can invoke remote method calls over soap. I know this > is a long shot, but since wsdl is xml-based, I though I might as well ask. No, there is no such support at the moment though we've been entertaining the idea of building a WSDL compiler on top of XSD along with a SOAP runtime for some time now. The main concern is whether we will be able to deliver a high-quality implementation seeing that the "WS" space is in quite a mess. Also there hasn't been any serious/commercial interest from the community. There are requests now and again but nobody seems to be interested enough to help define the product, beta-test, etc. So if you are interested we can definitely talk more about this. Boris From boris at codesynthesis.com Tue Aug 5 15:00:37 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] wsdl support - slightly off-topic question In-Reply-To: References: <4aeb04aa0808050738m50cb4134rd0fae4688b9dce74@mail.gmail.com> Message-ID: <20080805190037.GB30536@karelia> Hi Shiva, Thanks for providing your feedback. Balasubramanyam, Shivakumar writes: > gSOAP is very specific to SOAP protocol which is what you are > specifically looking for. As you pointed out, gsoap provides one feature > worth noting, RPC invocation when compared to XSD. However, gSOAP is not > a true WSDL product for the reasons that WSDL provides multiple RPC > protocols like JMS binding, http binding which gSOAP does not provide > and rightfully not expected as well. The issue however is that once you > change the RPC, all your client code now needs to be ripped off. So > gSOAP is not for a forward looking application user. Let me see if I understood your idea right. What you seem to want is to decouple the stub/servant (stub is a client-side class used to make an invocation and servant is a server-side class used to receive an invocation, using CORBA terminology) from the protocol/transport. This way the WSDL compiler generates data types for messages along with stubs/skeletons for the services which can be "attached" to any underlying messaging/RPC protocol (e.g., SOAP, etc) and transport (e.g., HTTP, raw TCP, etc). If that's what you are looking for then I was also thinking along these lines. In fact, at least at the beginning, we may not even provide the transport implementation. Instead, the user can use existing (or custom) libraries, for example, libculr on the client side and apache web server on the server side for the HTTP transport. Boris From sbalasub at qualcomm.com Tue Aug 5 16:38:40 2008 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] wsdl support - slightly off-topic question In-Reply-To: <20080805190037.GB30536@karelia> References: <4aeb04aa0808050738m50cb4134rd0fae4688b9dce74@mail.gmail.com> <20080805190037.GB30536@karelia> Message-ID: Boris, Yes. You are right. I agree, having some1 else provide the transport is a way for a disciplined layering of software. I also do not think providing solutions for already existing open source products also does not really help. In this case, there is no decent product out there for a WSDL to C++ compiler. If you have decided to use WSDL as an interface, then please refer to this spec which provides the specification for WSDL to C++ http://www.omg.org/docs/ptc/06-08-01.pdf I would also urge to take a look at the sca specifications for software architecture for reference. http://www.osoa.org/download/attachments/35/SCA_ClientAndImplementationM odel_Cpp-V100.pdf?version=2 IMO, the interface definition could be thought of three components, 1. Data Representation [XSD. Application data definition] 2. Interface Definition [WSDL. Has the RPC invocation info] 3. Service Definition [WSDL. Provides the Service Implementation info. Like XMLApplicationData/SOAP/HTTP or XML2BinApplicationData/SOAP/HTTP etc.] The software components would be, 1. Data binding layer [XSD to C++ using one of the serialization formats like XML,XDR,etc with existing XSD] 2. RPC specification [SOAP, RMI, JMS, HTTP, etc] 3. Transport Layer [HTTP, TCP, JMS/TCP, UDP, shared memory, etc] The reason I have JMS and HTTP in both 2 and 3 is basically that the RPC information could be encoded in the properties layer provided by these application protocols. I would be interested in brainstorming and providing any support/contribution in these areas. Thanks, Shiva -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Tuesday, August 05, 2008 12:01 PM To: Balasubramanyam, Shivakumar Cc: Rizzuto, Raymond; xsd-users@codesynthesis.com Subject: Re: [xsd-users] wsdl support - slightly off-topic question Hi Shiva, Thanks for providing your feedback. Balasubramanyam, Shivakumar writes: > gSOAP is very specific to SOAP protocol which is what you are > specifically looking for. As you pointed out, gsoap provides one > feature worth noting, RPC invocation when compared to XSD. However, > gSOAP is not a true WSDL product for the reasons that WSDL provides > multiple RPC protocols like JMS binding, http binding which gSOAP does > not provide and rightfully not expected as well. The issue however is > that once you change the RPC, all your client code now needs to be > ripped off. So gSOAP is not for a forward looking application user. Let me see if I understood your idea right. What you seem to want is to decouple the stub/servant (stub is a client-side class used to make an invocation and servant is a server-side class used to receive an invocation, using CORBA terminology) from the protocol/transport. This way the WSDL compiler generates data types for messages along with stubs/skeletons for the services which can be "attached" to any underlying messaging/RPC protocol (e.g., SOAP, etc) and transport (e.g., HTTP, raw TCP, etc). If that's what you are looking for then I was also thinking along these lines. In fact, at least at the beginning, we may not even provide the transport implementation. Instead, the user can use existing (or custom) libraries, for example, libculr on the client side and apache web server on the server side for the HTTP transport. Boris From raxody at yahoo.com Wed Aug 6 07:39:29 2008 From: raxody at yahoo.com (Erkan Kaya) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] optional-boolean with default values Message-ID: <438726.94423.qm@web54507.mail.re2.yahoo.com> Hey guys in our codebase, we are constantly getting bugs because of the way optional-values-with-defualt-values are generated. Optional boolean values are so many times confused with the booleans. What I'd like to ask is why doesn't xsd geneate the code like below: it has all the neccessary information to correctly create a class that would: if XXX exists in the config return what it reads from config else return the default value From boris at codesynthesis.com Wed Aug 6 08:16:14 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] optional-boolean with default values In-Reply-To: <438726.94423.qm@web54507.mail.re2.yahoo.com> References: <438726.94423.qm@web54507.mail.re2.yahoo.com> Message-ID: <20080806121614.GA2995@karelia> Hi Erkan, Erkan Kaya writes: > What I'd like to ask is why doesn't xsd geneate the code like below: > > > > > it has all the neccessary information to correctly create a class that > would: > > if XXX exists in the config > return what it reads from config > else > return the default value We cannot do this because that's not how elements with default values work in XML Schema. For attributes it is straightforward in that if an optional attribute is not present then the default value is used. With elements, things are more complicated. An optional element with a default value can be in three states: 1. present with custom value: true 2. present with default value: 3. not present That is, for an element to assume the default value it should be present but empty. I think these rules make elements with default values quite inconvenient to use and that's the reason why they are not very popular (unlike attributes with default values). BTW, the table in Appendix A, "Default and Fixed Values" in the C++/Tree Mapping User Manual summarizes the rules for default and fixed values in elements and attributes with various cardinalities: http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#A Boris From rkirtley at asinc.com Wed Aug 6 09:51:32 2008 From: rkirtley at asinc.com (Rance Kirtley) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Ostream operator for optional containers Message-ID: <005801c8f7cb$88e15670$c900000a@genesereth> Boris I'm using version XSD XML Schema to C++ compiler 3.1.1.a7 and have a minor problem with ostream operator generator code not handling optional container types correctly. For example the schema generates the code ::std::ostream& operator<< (::std::ostream& o, const ValuePathType& i) { if (i.Attribute ()) { o << ::std::endl << "Attribute: " << *i.Attribute (); } if (i.RemoteAttribute ()) { o << ::std::endl << "RemoteAttribute: " << *i.RemoteAttribute (); } if (i.Offset ()) { o << ::std::endl << "Offset: " << *i.Offset (); } if (i.TimeStamp ()) { o << ::std::endl << "TimeStamp: " << *i.TimeStamp (); } if (i.Literal ()) { o << ::std::endl << "Literal: " << *i.Literal (); } return o; } We get compile errors because the TimeStamp is in an optional container. My work-around is to further qualify the statement; eg o << ::std::endl << "TimeStamp: " << (*i.TimeStamp ()).hours(); Not a big issue, just reporting. Rance From boris at codesynthesis.com Wed Aug 6 10:06:21 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Ostream operator for optional containers In-Reply-To: <005801c8f7cb$88e15670$c900000a@genesereth> References: <005801c8f7cb$88e15670$c900000a@genesereth> Message-ID: <20080806140621.GB4052@karelia> Hi Rance, Rance Kirtley writes: > We get compile errors because the TimeStamp is in an optional container. > My work-around is to further qualify the statement; eg > > o << ::std::endl << "TimeStamp: " << (*i.TimeStamp ()).hours(); Does not look like this is an optional container problem. Rather, it seems that operator<< for xml_schema::time cannot be found for some reason. Maybe you are using --generate-xml-schema and forgot to add --generate-ostream to the command line (that option would trigger inclusion of the stream insertion operators for the built-in XML Schema types)? Boris From rkirtley at asinc.com Wed Aug 6 10:44:12 2008 From: rkirtley at asinc.com (Rance Kirtley) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Ostream operator for optional containers In-Reply-To: <20080806140621.GB4052@karelia> Message-ID: <006301c8f7d2$e46b76e0$c900000a@genesereth> Boris Thanks for the quick response. You're right, I had done exactly that; apologies for the bogus report. Rance -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Wednesday, August 06, 2008 10:06 AM To: Rance Kirtley Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Ostream operator for optional containers Hi Rance, Rance Kirtley writes: > We get compile errors because the TimeStamp is in an optional container. > My work-around is to further qualify the statement; eg > > o << ::std::endl << "TimeStamp: " << (*i.TimeStamp ()).hours(); Does not look like this is an optional container problem. Rather, it seems that operator<< for xml_schema::time cannot be found for some reason. Maybe you are using --generate-xml-schema and forgot to add --generate-ostream to the command line (that option would trigger inclusion of the stream insertion operators for the built-in XML Schema types)? Boris From boris at codesynthesis.com Wed Aug 6 11:20:08 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] wsdl support - slightly off-topic question In-Reply-To: References: <4aeb04aa0808050738m50cb4134rd0fae4688b9dce74@mail.gmail.com> <20080805190037.GB30536@karelia> Message-ID: <20080806152008.GB6930@karelia> Hi Shiva, Balasubramanyam, Shivakumar writes: > In this case, there is no decent product out there for a WSDL to C++ > compiler. If you have decided to use WSDL as an interface, then please > refer to this spec which provides the specification for WSDL to C++ > http://www.omg.org/docs/ptc/06-08-01.pdf If it is anything similar to the IDL to C++ mapping by OMG, then we are better off not looking in there... ;-) > I would be interested in brainstorming and providing any > support/contribution in these areas. I guess the main question at this point is what would be the minimal implementation that you would find usable. I guess the data binding as well as the service stub/skeletons from WSDL definitions are required. So when you call a stub you get serialized XML of the message on the other side. Similarly, you can pass an XML message to a skeleton and it will dispatch the corresponding virtual function. We can also provide support for wrapping/extraction these messages into/from a SOAP envelope (I think this can be done by compiling the SOAP schemas with XSD and then using the wildcard support to get/set the body of the envelope). So the question is whether something like this will be useful to you. Boris From atteeela at gmail.com Wed Aug 6 15:05:31 2008 From: atteeela at gmail.com (Attila) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Arbitrary XML inside XML element Message-ID: <4aeb04aa0808061205u1adcf3d9q46e2a806bcf40215@mail.gmail.com> Hi All, Is it possible to get arbitrary XML as a string inside of an element if it is so marked in a schema? If I use the method (as described here: http://www.xfront.com/ExtensibleContentModels.html#method2), can I retrieve the arbitrary XML as a string for an element? How does CS handle this situation? What I really want is a 'type="XML"'. I see the problems with parsing this and determining where an element starts/ends, so I think it may not be possible. Thanks, -- Attila Software Developer atteeela@gmail.com From boris at codesynthesis.com Wed Aug 6 16:48:44 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Arbitrary XML inside XML element In-Reply-To: <4aeb04aa0808061205u1adcf3d9q46e2a806bcf40215@mail.gmail.com> References: <4aeb04aa0808061205u1adcf3d9q46e2a806bcf40215@mail.gmail.com> Message-ID: <20080806204844.GB7591@karelia> Hi Attila, Attila writes: > If I use the method (as described here: > http://www.xfront.com/ExtensibleContentModels.html#method2), can I retrieve > the arbitrary XML as a string for an element? > How does CS handle this situation? XSD actually goes one step further and allows you to access XML fragments matched by wildcards (any and anyAttribute) as DOM nodes. You can even use these DOM nodes to create an object model if the content in your wildcards is described by a schema. For more information on all this see Section 2.12, "Mapping for any and anyAttribute" in the C++/Tree Mapping User Manual: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.12 As well as the 'wildcard' example in examples/cxx/tree/. If, for some reason, you would prefer to have the XML fragment as a string instead of DOM, then you can use the Xerces-C++ functionality to serialize the returned DOM node to a string. Boris From atteeela at gmail.com Wed Aug 6 17:32:51 2008 From: atteeela at gmail.com (Attila) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Arbitrary XML inside XML element In-Reply-To: <20080806204844.GB7591@karelia> References: <4aeb04aa0808061205u1adcf3d9q46e2a806bcf40215@mail.gmail.com> <20080806204844.GB7591@karelia> Message-ID: <4aeb04aa0808061432u63f4087n7356ed95eb34b819@mail.gmail.com> Thanks for the information. One more thing: Can I use the C++/Parser to do the same thing? I would like to be able to get the sub-XML text for specific nodes, but not receive callbacks for the "any'ed" elements that happen to show up. Would there be anyway to perform a test to see if there are "any" elements underneath a specific element that you just received a callback for? Background: We have a pseudo XML-RPC spec, and one of the tags needs to contain arbitrary XML, but it may not always be the case. I was thinking about revamping this pseudo XML-RPC spec to be more like SOAP (envelope/header/body) with the validation/binding done by XSD C++/Parser (as we are currently using Xerces/SAX). Thanks, On Wed, Aug 6, 2008 at 4:48 PM, Boris Kolpackov wrote: > Hi Attila, > > Attila writes: > > > If I use the method (as described here: > > http://www.xfront.com/ExtensibleContentModels.html#method2), can I > retrieve > > the arbitrary XML as a string for an element? > > How does CS handle this situation? > > XSD actually goes one step further and allows you to access XML > fragments matched by wildcards (any and anyAttribute) as DOM nodes. > You can even use these DOM nodes to create an object model if the > content in your wildcards is described by a schema. > > For more information on all this see Section 2.12, "Mapping for any > and anyAttribute" in the C++/Tree Mapping User Manual: > > > http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.12 > > As well as the 'wildcard' example in examples/cxx/tree/. > > If, for some reason, you would prefer to have the XML fragment as a > string instead of DOM, then you can use the Xerces-C++ functionality > to serialize the returned DOM node to a string. > > Boris > -- Attila Software Developer atteeela@gmail.com From boris at codesynthesis.com Thu Aug 7 10:17:54 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Arbitrary XML inside XML element In-Reply-To: <4aeb04aa0808061432u63f4087n7356ed95eb34b819@mail.gmail.com> References: <4aeb04aa0808061205u1adcf3d9q46e2a806bcf40215@mail.gmail.com> <20080806204844.GB7591@karelia> <4aeb04aa0808061432u63f4087n7356ed95eb34b819@mail.gmail.com> Message-ID: <20080807141754.GA5269@karelia> Hi Attila, Attila writes: > Thanks for the information. One more thing: Can I use the C++/Parser to do > the same thing? Yes, there is a similar facility in C++/Parser except there you receive raw SAX callbacks (e.g., start_element(), end_element(), attribute(), and characters()) for content matched by wildcards. The 'wildcard' example in examples/cxx/parser/ shows how this works. > I would like to be able to get the sub-XML text for specific nodes, but not > receive callbacks for the "any'ed" elements that happen to show up. Would > there be anyway to perform a test to see if there are "any" elements > underneath a specific element that you just received a callback for? Yes, you can override the above-mentioned functions (see the 'wildcard' example for details). There you can ignore/process/save content matched by the wildcard in any way you want (including routing it to the another parser). Boris From atteeela at gmail.com Thu Aug 7 11:54:08 2008 From: atteeela at gmail.com (Attila) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Arbitrary XML inside XML element In-Reply-To: <20080807141754.GA5269@karelia> References: <4aeb04aa0808061205u1adcf3d9q46e2a806bcf40215@mail.gmail.com> <20080806204844.GB7591@karelia> <4aeb04aa0808061432u63f4087n7356ed95eb34b819@mail.gmail.com> <20080807141754.GA5269@karelia> Message-ID: <4aeb04aa0808070854ladcba24ta9bf072826450689@mail.gmail.com> Hi Boris, It looks promising, but I am still not quite sure how I would fetch the text from underneath an element where processContents="skip". >From the examples/cxx/parser/wildcard/email.xsd: (I changed processContents to "skip") .... * * Now I would want a way to retrieve all "skipped" content underneath the element as a string. I do not want callbacks on each any'ed element (as I have indicated I want to skip processing the contents). XML Instance: a b c ... ... As text when processing ? I do not quite see how this processing would fit into the generated skeleton for envelope. Would I use: virtual void _any_characters (const ro_string& s) { // do something } And build up a buffer of any'ed elements that were skipped in here? Thanks, On Thu, Aug 7, 2008 at 10:17 AM, Boris Kolpackov wrote: > Hi Attila, > > Attila writes: > > > Thanks for the information. One more thing: Can I use the C++/Parser to > do > > the same thing? > > Yes, there is a similar facility in C++/Parser except there you receive > raw SAX callbacks (e.g., start_element(), end_element(), attribute(), > and characters()) for content matched by wildcards. The 'wildcard' > example in examples/cxx/parser/ shows how this works. > > > > I would like to be able to get the sub-XML text for specific nodes, but > not > > receive callbacks for the "any'ed" elements that happen to show up. > Would > > there be anyway to perform a test to see if there are "any" elements > > underneath a specific element that you just received a callback for? > > Yes, you can override the above-mentioned functions (see the 'wildcard' > example for details). There you can ignore/process/save content matched > by the wildcard in any way you want (including routing it to the another > parser). > > Boris > -- Attila Software Developer atteeela@gmail.com From jan.klimke at hpi.uni-potsdam.de Thu Aug 7 17:16:01 2008 From: jan.klimke at hpi.uni-potsdam.de (Jan Klimke) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] How to get Objects for Elements referenced by xlink:href Message-ID: <489B6611.302@hpi.uni-potsdam.de> Hi, i generated the GML, Web Feature Service classes as well as those for an application schema. I managed to sucessfully create requests and receive replies from my deegree WFS. The response look like this (currently there is some nonsense data in my database for testing puposes): 133 Friedrich Engels2 70 1.0 0.0 0.0 1.0 134 Friedrich Engels As you can see, the second user has a xlink reference in its property referencing "COLOR_70" which appeared "earlier" in the document. My problem is now to obtain a reference to the Color object for the "USER_134" object. How can i resolve such inner document xlink references ? Thanks, Jan From boris at codesynthesis.com Fri Aug 8 04:39:13 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] How to get Objects for Elements referenced by xlink:href In-Reply-To: <489B6611.302@hpi.uni-potsdam.de> References: <489B6611.302@hpi.uni-potsdam.de> Message-ID: <20080808083913.GC29145@karelia> Hi Jan, Jan Klimke writes: > > xmlns:app="http://www.deegree.org/app" > xmlns:wfs="http://www.opengis.net/wfs" > xmlns:xlink="http://www.w3.org/1999/xlink" > xmlns:gml="http://www.opengis.net/gml" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.deegree.org/app > http://servername:8080/deegree-wfs/services?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=app:User&NAMESPACE=xmlns(app=http://www.deegree.org/app) > http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"> > > > 133 > Friedrich Engels2 > > > 70 > 1.0 > 0.0 > 0.0 > 1.0 > > > > > > > 134 > Friedrich Engels > > > > > > As you can see, the second user has a xlink reference in its > property referencing "COLOR_70" which appeared "earlier" in the > document. My problem is now to obtain a reference to the Color object > for the "USER_134" object. How can i resolve such inner document xlink > references ? I checked the GML schema and the gml:id attribute is of xsd:ID type. If all href attributes always refer one of those gml:id attributes then this is pretty simple to do: std::string href = ... // contains "COLOR_70", without # color_t& color = ... // reference to an object containing href xml_schema::idref ref (href, 0, &color); xml_schema::type* p = ref.get (); // p points to the object with ID COLOR_70 // Now you can use static_cast (if you are sure about the type of p) or // dynamic_cast (if you are not) to cast it to the Color_t type. If you cannot assume that all href attributes point to one of the gml:id attributes (or other attributes as long as they are of the xsd:ID type) then things get a bit more complex. Let me know if this is the case and I will describe how this can be done. Boris From boris at codesynthesis.com Fri Aug 8 11:55:41 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] XSD 3.2.0 beta1 released Message-ID: <20080808155541.GA3515@karelia> Hi, We have released the first and hopefully the only beta for XSD 3.2.0. Initially this release was planned as 3.1.1 but due to the large number of new features it was changed to 3.2.0. The final release is planned for mid-September. One of the important changes in this release is the support for Xerces-C++ 3.0.0 beta2 which was released a couple of weeks ago. Xerces-C++ 3.0.0 includes a number of major fixes and enhancements (new ##other interpretation, large maxOccurs fix, 64-bit safe interfaces, automake-based build system, performance optimization, just to name a few) which is why we suggest that everyone considers migrating to Xerces-C++ 3.0.0 and help test XSD 3.2.0.b1 with Xerces-C++ 3.0.0.b2. For more information on Xerces-C++ 3.0.0.b2 including download locations, refer to the official announcement: http://marc.info/?l=xerces-c-users&m=121692508501507&w=2 The NEWS file entries for 3.2.0 so far are as follows: * New option, --disable-warning, disables printing of a warning with the specified id. Specifying 'all' for the warning id disables all warnings. * New options, --export-maps and --import-maps, provide support for splitting a polymorphic type hierarchy across several Win32 DLLs. See the compiler command line manual (man pages) for details. C++/Tree * During serialization the generated code automatically assigns generic prefixes (p1, p2, etc) to XML namespaces used in the vocabulary and for which no custom prefix-namespace mapping was provided via the xml_schema::namespace_infomap argument. The xml_schema::namespace_infomap argument in the serialization functions is now default-initialized to an empty map. The xml_schema::no_namespace_mapping and xml_schema::xsi_already_in_use exceptions have been removed. * New example, performance, measures the performance of parsing and serialization. This example also shows how to structure your code to achieve the maximum performance for these two operations. * New example, xpath, shows how to use the C++/Tree mapping together with XPath. * New options, --one-accessor-regex, --opt-accessor-regex, --seq-accessor-regex, --one-modifier-regex, --opt-modifier-regex, and --seq-modifier-regex, allow specification of transformations for accessor and modifier function names for elements and attributes with specific cardinalities. For more information see the NAMING CONVENTION section in the compiler command line manual (man pages). * Support for comparison (--generate-comparison) and printing (--generate-ostream) of polymorphic object models. * New serialization flag, xml_schema::flags::dont_pretty_print, disables extra spaces and new lines that make the resulting XML slightly bigger but easier to read. * New example, custom/double, shows how to customize parsing and serialization code for the xsd:double XML Schema built-in type. It can be used as a guide on how to customize built-in XML Schema types that are mapped to fundamental C++ types. * Support for fractionDigits and totalDigits facets in serialization of types derived from xsd:decimal. * New set of compile-time macros that control how the xsd:float, xsd:double, and xsd:decimal types are serialized. The following macros control the format: XSD_CXX_TREE_FLOAT_FIXED XSD_CXX_TREE_FLOAT_SCIENTIFIC XSD_CXX_TREE_DOUBLE_FIXED XSD_CXX_TREE_DOUBLE_SCIENTIFIC The following macros control the precision: XSD_CXX_TREE_FLOAT_PRECISION_MAX XSD_CXX_TREE_FLOAT_PRECISION XSD_CXX_TREE_DOUBLE_PRECISION_MAX XSD_CXX_TREE_DOUBLE_PRECISION XSD_CXX_TREE_DECIMAL_PRECISION_MAX XSD_CXX_TREE_DECIMAL_PRECISION If the *_PRECISION_MAX macro is defined then the maximum number of potentially significant decimal digits that the type can represent is used. Otherwise, if the *_PRECISION macro is defined then its value is used. By default the precision is set to the number of decimal digits that the type can represent without change. For more information on these options, refer to the following paper: http://www2.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf The old macro, XSD_FP_ALL_DIGITS, that was equivalent to defining all three *_PRECISION_MAX macros has been removed. An alternative to using these macros is to customize the floating point type as shown in the custom/double example. * An additional constructor is generated in situations where a type contains one or more required element of complex type (that is, it itself contains elements or attributes). In this constructor, initializers for such elements are passed as std::auto_ptr and the newly created instance is directly initialized with and assumes ownership of the pointed to objects. This constructor is a logical addition to the non-copying modifiers that were introduced in the previous version. * Extra conversion operators in the fundamental_base class template which is used to emulate inheritance from fundamental types are now disabled by default since they cause problems on several compilers. To enable them compile your code with the XSD_TREE_EXTRA_FUND_CONV macro defined. C++/Parser * New options, --generate-xml-schema and --extern-xml-schema, trigger generation of the mapping for the XML Schema namespace to a separate header file and inclusion of that header into other generated header files instead of generating the necessary declarations inline, respectively. See the compiler command line manual (man pages) for details. * New example, performance, measures the performance of XML parsing. This example also shows how to structure your code to achieve the maximum performance for this operation. * Type map files can now include comments. A comment starts with # and ends with a new line or end of file. To specify a name that contains # enclose it in "". * In type map files the optional argument type now defaults to the return type if the return type ends with * or & (that is, it is a pointer or a reference) and 'const return type&' otherwise. * The interface for polymorphic parsing has been simplified. Calling the *_parser() functions multiple times to specify several parsers is no longer supported. Instead you need to pass the xml_schema::parser_map object which contains the parsers. For more information refer to Section 5.4, "Support for Polymorphism" in the C++/Parser Mapping Getting Started Guide. * The use of virtual inheritance has been reduced which results in a much smaller object code size (more than factor of 2 on some tests) and faster C++ compilation with less RAM used. * The low-level Expat-specific parsing API (parse_begin() and parse_end()) has been extended to provide XML and XML Schema error translation to exceptions or error handler calls. See Section 7.2, "Expat Document Parser" in the C++/Parser Mapping Getting Started Guide for more information. To support both Xerces-3 and Xerces-2, the project and solution files for VC++ have been split with the files containing xerces2 in their names linking to Xerces-2.x.y libraries. If you would like to try the xpath example with Xerces-C++ 3.0.0.b2, you can use the following snapshot for XQilla 2.2.0: http://www.codesynthesis.com/~boris/tmp/xqilla-SVN-20080808.tar.gz http://www.codesynthesis.com/~boris/tmp/xqilla-SVN-20080808.zip The final XQilla 2.2.0 will be released after Xerces-C++ 3.0.0. Precompiled binary distributions for 3.2.0.b1 are available from the product's download page: http://www.codesynthesis.com/products/xsd/download.xhtml Source code for this release is available from the project's web page: http://www.codesynthesis.com/projects/xsd/ SHA1 checksums for the files: eca12ad79bf3f0de1f0eb3795e3fb9990d79b8b1 xsd-3.2.0.b1.tar.bz2 1bd66e0ab7fe45599425906c199e1aca5c11e261 xsd-3.2.0.b1-i686-linux-gnu.tar.bz2 230d2c683133da4d34fe3e6775f93e6bc3298bef xsd-3.2.0.b1-x86_64-linux-gnu.tar.bz2 bae84e30316a6448bd43122e1ca566e0e10ecf6a xsd-3.2.0.b1-i686-macosx.tar.bz2 411f34e17bc43c7f7cc67c03b32c95f2d31c1c14 xsd-3.2.0.b1-sparc-solaris.tar.gz b196af066bf548b0e76d2c1c56805e10478cae14 xsd-3.2.0.b1-i686-windows.zip Enjoy, Boris From boris at codesynthesis.com Fri Aug 8 12:33:06 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Arbitrary XML inside XML element In-Reply-To: <4aeb04aa0808070854ladcba24ta9bf072826450689@mail.gmail.com> References: <4aeb04aa0808061205u1adcf3d9q46e2a806bcf40215@mail.gmail.com> <20080806204844.GB7591@karelia> <4aeb04aa0808061432u63f4087n7356ed95eb34b819@mail.gmail.com> <20080807141754.GA5269@karelia> <4aeb04aa0808070854ladcba24ta9bf072826450689@mail.gmail.com> Message-ID: <20080808163306.GD3515@karelia> Hi Attila, Attila writes: > Now I would want a way to retrieve all "skipped" content underneath the > element as a string. I do not want callbacks on each any'ed > element (as I have indicated I want to skip processing the contents). processContent="skip" in XML Schema means that the content will not be validated, not that it won't be accessible to the application (e.g., in DOM or SAX). Furthermore, it is not possible for an XML parser to really skip a chunk of document since it needs to parse it in order to determine where to stop skipping (i.e., it needs to detect the closing tag of a fragment you want skipped). > XML Instance: > > > a > b > c > > ... > > > Would there be a way for me to retrieve: > > > ... > > > As text when processing ? The parser will deliver this fragment as raw SAX callbacks which you can override to construct an XML string from it. For example: struct message_pimpl: message_pskel { message_pimpl () : depth_ (0) { } virtual void _start_any_element (const xml_schema::ro_string& ns, const xml_schema::ro_string& name, const xml_schema::ro_string* type) { if (depth_ == 0) { start_tag_ = false; wildcard_content_.clear (); } if (start_tag_) wildcard_content_ += ">"; // Close previous start tag. wildcard_content_ += "<"; wildcard_content_ += name; start_tag_ = true; depth_++; } virtual void _any_attribute (const xml_schema::ro_string& ns, const xml_schema::ro_string& name, const xml_schema::ro_string& value) { wildcard_content_ += " "; wildcard_content_ += name; wildcard_content_ += "=\""; wildcard_content_ += value; wildcard_content_ += "\""; } virtual void _end_any_element (const xml_schema::ro_string& ns, const xml_schema::ro_string& name) { if (start_tag_) { wildcard_content_+= "/>" // Empty content element. start_tag_ = false; } else { wildcard_content_ += ""; } depth_--; } virtual void _any_characters (const ro_string& s) { if (start_tag_) { wildcard_content_ += ">"; // Close previous start tag. start_tag_ = false; } wildcard_content_ += s; } private: size_t depth_; bool start_tag_; string wildcard_content_; }; Boris From michael.coulman at mac.com Fri Aug 8 18:20:13 2008 From: michael.coulman at mac.com (Michael Coulman) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] XSD 3.2.0 beta1 released In-Reply-To: <20080808155541.GA3515@karelia> References: <20080808155541.GA3515@karelia> Message-ID: <52E3C799-35EB-4493-BE08-939B67B5BB7D@mac.com> On Aug 8, 2008, at 5:55 AM, Boris Kolpackov wrote: > * New example, xpath, shows how to use the C++/Tree mapping > together with XPath. How would one go about binding the DOM representation to the XSD object model so modifications to the XSD object model are "live?" I'd like XPath queries to return values that reflect the modification to the XSD object model, even though the XPath query runs against the DOM representation. Can it be done? If so, clues appreciated. TIA, -- Michael Coulman michael.coulman@mac.com From lvkun2006 at gmail.com Sun Aug 10 23:36:39 2008 From: lvkun2006 at gmail.com (lvkun) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] A Question about elements sequence References: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com> <20080414074517.GA4703@karelia> <32b74eaf0804140230u67504c7bsa48e93ffa98d35cf@mail.gmail.com> <20080415072736.GB17491@karelia> <000301c89ed5$4c958870$e5c09950$@com> <20080415085109.GA17802@karelia> <000401c89ed9$7b262b50$717281f0$@com> <20080415090406.GC17802@karelia> Message-ID: <001901c8fb63$791a9b20$6b4fd160$@com> The example xsd file is? But when I parse the xml file, the element sequence is not fixed. Maybe like this? A B AAAA So, when I use xsd to parse this file, it throw exception. How to solve this problem? Thanks a lot. From boris at codesynthesis.com Mon Aug 11 02:57:08 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Re: A Question about elements sequence Message-ID: <20080811065708.GB24690@tpad> Hi, lvkun writes: > The example xsd file is? > > > > > minOccurs= "1" maxOccurs= "unbounded"/> > > > > But when I parse the xml file, the element sequence is not fixed. Maybe like > this? > > > A > > > B > > > AAAA > > > So, when I use xsd to parse this file, it throw exception. How to solve this > problem? Your XML document is not valid per your schema since your schema says elements should be in the specified order. To solve this, you can either fix your XML document or change your schema. Boris From boris at codesynthesis.com Mon Aug 11 03:58:19 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] XSD 3.2.0 beta1 released In-Reply-To: <52E3C799-35EB-4493-BE08-939B67B5BB7D@mac.com> References: <20080808155541.GA3515@karelia> <52E3C799-35EB-4493-BE08-939B67B5BB7D@mac.com> Message-ID: <20080811075819.GD24690@tpad> Hi Michael, Michael Coulman writes: > How would one go about binding the DOM representation to the XSD object > model so modifications to the XSD object model are "live?" The only way is to do it manually which requires a lot of work. The DOM association was intended as a read-only mechanism since maintaining it during modifications would require quite a bit of complex code. > I'd like XPath queries to return values that reflect the modification to > the XSD object model, even though the XPath query runs against the DOM > representation. We are currently thinking about and investigating the possibility of running XPath (and XQuery) queries on the object models directly, without the use of the underlying DOM model. This will work with modifications to the object model. Would you be interested in something like this? Anybody else is interested? Boris From michael.coulman at mac.com Mon Aug 11 04:02:28 2008 From: michael.coulman at mac.com (Michael Coulman) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] XSD 3.2.0 beta1 released In-Reply-To: <20080811075819.GD24690@tpad> References: <20080808155541.GA3515@karelia> <52E3C799-35EB-4493-BE08-939B67B5BB7D@mac.com> <20080811075819.GD24690@tpad> Message-ID: <96C9595D-623D-49D9-B995-35F4E388EDAC@mac.com> On Aug 10, 2008, at 9:58 PM, Boris Kolpackov wrote: > We are currently thinking about and investigating the possibility of > running XPath (and XQuery) queries on the object models directly, > without the use of the underlying DOM model. This will work with > modifications to the object model. Would you be interested in > something like this? Very much so. XPath and XQuery integration would be a great enhancement for my use of the object model. -- Michael Coulman michael.coulman@mac.com From Raymond.Rizzuto at sig.com Tue Aug 19 18:21:01 2008 From: Raymond.Rizzuto at sig.com (Rizzuto, Raymond) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] wsdl support - slightly off-topic question In-Reply-To: <20080805184702.GA30536@karelia> References: <20080805184702.GA30536@karelia> Message-ID: Boris, My apologies for the long delay in responding. I have been trying to gauge the level of interest here at my company. It looks like the tool we are currently using is unlikely to be available on all of the environments we need to support (32 and 64 bit Linux at a minimum). For the short term, we have support only for 32 bit Linux. We are looking at alternatives, such as gSoap, XSD plus additional interface/service layer, etc. For my specific purpose, I only need client side support under Linux, but there may be broader interest than that. I'll let you know if we decide to pursue a XSD-based solution. Ray -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Tuesday, August 05, 2008 2:47 PM To: Rizzuto, Raymond Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] wsdl support - slightly off-topic question Hi Ray, Rizzuto, Raymond writes: > I was wondering if there is any way to use xsd to compile a wsdl file > into classes that can invoke remote method calls over soap. I know this > is a long shot, but since wsdl is xml-based, I though I might as well ask. No, there is no such support at the moment though we've been entertaining the idea of building a WSDL compiler on top of XSD along with a SOAP runtime for some time now. The main concern is whether we will be able to deliver a high-quality implementation seeing that the "WS" space is in quite a mess. Also there hasn't been any serious/commercial interest from the community. There are requests now and again but nobody seems to be interested enough to help define the product, beta-test, etc. So if you are interested we can definitely talk more about this. Boris IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses. From karlmutchlists at gmail.com Thu Aug 21 00:58:53 2008 From: karlmutchlists at gmail.com (Karl Mutch) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Using XSD to validate and process documents without namespaces specified in top level elements Message-ID: HI, I have an issue where I am trying to parse documents that are coming from a third party. These have none of the normal namespace attributes and I would like to parseinput sources in such a way as they can be validated using my own xsd files. I have tried a large number of approaches and am now running, or rather failing, with something similar to the following : namespace { std::string xml_get_next_lane_response_schema_data("\n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n"); xsd::cxx::xml::string inputGrammar(xml_get_next_lane_response_schema_data); bool Initialize() { // For performance reasons, we would like to initialize/terminate // Xerces-C++ ourselves once instead of letting API functions do // it potentially continously during processing. // xercesc::XMLPlatformUtils::Initialize (); return(true); } /* USED */ bool fInitialized = Initialize(); using namespace enterprise; class LocalResolver : public xercesc::DOMEntityResolver { public: xercesc::DOMInputSource *resolveEntity(const XMLCh* const publicId, const XMLCh* const systemId, const XMLCh* const baseURI) { return(new xercesc::Wrapper4InputSource (new xercesc::MemBufInputSource(reinterpret_cast(xml_get_next_lane_response_schema_data.c_str ()), xml_get_next_lane_response_schema_data.size (), "GetNextLaneResponse.xsd"))); } }; // Throws exceptions that are expected to be handled by callers ! std::auto_ptr ParseDocument(std::istream &inputStream) { using namespace xercesc; namespace xml = xsd::cxx::xml; namespace tree = xsd::cxx::tree; const XMLCh ls_id [] = {chLatin_L, chLatin_S, chNull}; // Get an implementation of the Load-Store (LS) interface. // DOMImplementation* impl ( DOMImplementationRegistry::getDOMImplementation (ls_id)); // Create a DOMBuilder. // xml::dom::auto_ptr parser ( impl->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0)); // Discard comment nodes in the document. // parser->setFeature (XMLUni::fgDOMComments, false); // Enable datatype normalization. // parser->setFeature (XMLUni::fgDOMDatatypeNormalization, true); // Do not create EntityReference nodes in the DOM tree. No // EntityReference nodes will be created, only the nodes // corresponding to their fully expanded substitution text // will be created. // parser->setFeature (XMLUni::fgDOMEntities, false); // Perform namespace processing. // parser->setFeature (XMLUni::fgDOMNamespaces, true); // Do not include ignorable whitespace in the DOM tree. // parser->setFeature (XMLUni::fgDOMWhitespaceInElementContent, false); // Enable validation. // parser->setFeature (XMLUni::fgDOMValidation, true); parser->setFeature (XMLUni::fgXercesSchema, true); parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); parser->setProperty (XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, const_cast ( static_cast ( xml::string ("GetNextLaneResponse.xsd").c_str ()))); parser->setProperty (XMLUni::fgXercesSchemaExternalSchemaLocation, const_cast ( static_cast ( xml::string ("http://www.enterprise.com/GetNextLaneResponseGetNextLaneResponse.xsd").c_str ()))); // Initialize the schema cache. // virtual Grammar* loadGrammar(const DOMInputSource& source, const short grammarType, const bool toCache = false) = 0; //std::istringstream input_grammar(xml_get_next_lane_response_schema_data); //xml::sax::std_input_source grammar_wrapper(input_grammar); //xml::string inputGrammar(xml_get_next_lane_response_schema_data); xercesc::MemBufInputSource grammar_wrapper (reinterpret_cast(xml_get_next_lane_response_schema_data.c_str ()), xml_get_next_lane_response_schema_data.size (), "GetNextLaneResponse.xsd"); xercesc::Wrapper4InputSource grammar_input_wrapper (&grammar_wrapper, false); parser->loadGrammar (grammar_input_wrapper, Grammar::SchemaGrammarType, true); parser->setFeature (XMLUni::fgXercesUseCachedGrammarInParse, true); parser->set // We will release the DOM document ourselves. // parser->setFeature (XMLUni::fgXercesUserAdoptsDOMDocument, true); // Set error handler. // tree::error_handler eh; xml::dom::bits::error_handler_proxy ehp (eh); parser->setErrorHandler (&ehp); // Set the entity resolver LocalResolver localResolver; parser->setEntityResolver(&localResolver); // Wrap the standard input stream. // xml::sax::std_input_source isrc(inputStream, "GetNextLaneResponse.xsd"); Wrapper4InputSource wrap (&isrc, false); wrap.setSystemId(xml::transcode_to_xmlch("GetNextLaneResponse.xsd")); // Parse XML to DOM. // xml::dom::auto_ptr doc (parser->parse (wrap)); eh.throw_if_failed > (); xml_schema::properties properties; properties.schema_location(" http://www.enterprise.com/GetNextLaneResponse", "GetNextLaneResponse.xsd"); properties.no_namespace_schema_location("GetNextLaneResponse.xsd"); // Parse DOM to the object model. // return(std::auto_ptr (enterprise::subsystem::GetNextLaneResponse::request_ ( *doc, xml_schema::flags::keep_dom | xml_schema::flags::own_dom, properties))); } // end of ... ParseDocument(std::istream &inputStream) }; more code and then I push the following through the parser : A Message It bails with the following Schema in GetNextLaneResponse.xsd has a different target namespace from the one specified in the instance document ." Obviously because I cannot force the target namespace. So I turned off NS Processing using parser->setFeature (XMLUni::fgDOMNamespaces, false); And get an "Unknown element" error for the request tag. If I absolutely know the schema that would work is there a way I can cause this to work and resolve my elements without mangling the input document ? Thanks karl P.S. I have read the following and don't seem to get any joy from them. http://www.codesynthesis.com/pipermail/xsd-users/2007-February/000796.html http://www.codesynthesis.com/pipermail/xsd-users/2006-September/000535.html My intent would be to use the code from http://wiki.codesynthesis.com/Tree/FAQ#How_do_I_specify_a_schema_location_other_than_in_an_XML_document.3Fto identify the correct schema in time. From boris at codesynthesis.com Thu Aug 21 14:56:19 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Using XSD to validate and process documents without namespaces specified in top level elements In-Reply-To: References: Message-ID: <20080821185619.GA9147@tpad> Hi Karl, Karl Mutch writes: > I have an issue where I am trying to parse documents that are coming from a > third party. These have none of the normal namespace attributes and I would > like to parseinput sources in such a way as they can be validated using my > own xsd files. There are two problems that you are trying to solve here. First is how to associate the schema with XML documents that don't contain the schema location attributes. The second problem is how to work around the absent namespace attributes in the XML documents. Let's consider each of these problems separately. For the first problem there are two solutions: you can either specify schema locations using the XercesSchemaExternalNoNameSpaceSchemaLocation and XercesSchemaExternalSchemaLocation Xerces-C++ properties (or use no_namespace_schema_location and schema_location in xml_schema::properties which are just shortcuts for the Xerces-C++ properties if you don't do your own XML-to-DOM parsing). Or you can pre-parse and cache the schemas using the loadGrammar function (see the 'caching' example in examples/cxx/tree/ for more information on how to do this). You can also use EntityResolver to intercept schema loading but you still need to trigger this loading with one of the above methods (or via the schema location attributes in the XML document). In your code you seem to be trying to use all these methods together which is not really necessary. If you are doing your own XML-to-DOM parsing then the loadGrammar approach is probably the best choice. The second problem (how to work around the absent namespace attributes) is quite a bit harder to solve. First, it is helpful to understand that an XML document without the namespace attributes is invalid per your schema. So the general approach to solving this is to either change the XML document to conform to the schema or change the schema to allow XML documents without the namespace. One variant of the changing XML document approach is to programmatically fix it up with the necessary namespace attributes before parsing it. If the document is small, you can probably load it first into a memory buffer or string and then change it there. If the document is large then it may make sense to provide your own InputSource implementation (see libxsd/xsd/cxx/xml/sax/std-input-source.hxx for an example) that does this on the fly as chunks of the document become available. The best way to fix the document depends on the kind of vocabulary you have. If all your elements are qualified (e.g., you have elementsFormDefaul="qualified" in your schema) then you can simply add the default namespace declaration to the start tag of the root element: A Message This will automatically make all elements under and including the root in the specified namespace. If only the root element is qualified (like in your case) then things are a bit more complex since you will need to rewrite the opening and closing tags of the root element, for example: A Message If you can make some assumptions about the content of your XML documents (e.g., that it cannot contain " Hi: I have recently upgraded a schema file, is it possible to use XSD tool to generate the new xml files (based on the new schema) from the old xml files (based on the old schema)? If so, any clues are appreciated. For example: Old schema file try.xsd: Added a new interger element try_2 before the element try_3 to the new schema file newtry.xsd I know I can use strictly only Xerces calls to insert the element try_2 with the default value before the element try_3, but was wondering is there a better way to handle the problem of multiple upgrades of a complicated schema file then convert the old xml files to the new schema format? Is it possible using XSD to do this, again, any clues are appreciated. Thanks and Best Regards, Anpao From boris at codesynthesis.com Fri Aug 22 16:30:58 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Is it possible using XSD to do this? In-Reply-To: <633013.14626.qm@web56306.mail.re3.yahoo.com> References: <633013.14626.qm@web56306.mail.re3.yahoo.com> Message-ID: <20080822203058.GA3502@tpad> Hi Anpao, Anpao Chou writes: > > > > > > > > > > > > > > Added a new interger element try_2 before the element try_3 to the > new schema file newtry.xsd There is no support for the general case of upgrading XML instances to conform to a new schema. I doubt such support can be implemented at all since the generated code has no knowledge of the values that should be used in new elements/attributes or their cardinalities. However, if you first change your schemas in a backwards-compatible way (that is, all new elements and attributes are made optional) then you can read the old XML documents with the new generated code, set values for the new elements/attributes using the object model, and serialize it back to XML in the new format. After you have migrated all your XML documents using this approach you can change the schema again to make the new elements and attributes non-optional. Boris From ac22750085 at yahoo.com Fri Aug 22 17:40:31 2008 From: ac22750085 at yahoo.com (Anpao Chou) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] Is it possible using XSD to do this? Message-ID: <713985.3444.qm@web56309.mail.re3.yahoo.com> Hi Boris: Thank you so much for the quick/smart way doing this, I appreciate it very much. Thanks Again and Best Regards, ----- Original Message ---- From: Boris Kolpackov To: Anpao Chou Cc: xsd-users@codesynthesis.com Sent: Friday, August 22, 2008 1:30:58 PM Subject: Re: [xsd-users] Is it possible using XSD to do this? Hi Anpao, Anpao Chou writes: > > > > > > > > > > > > > > Added a new interger element try_2 before the element try_3 to the > new schema file newtry.xsd There is no support for the general case of upgrading XML instances to conform to a new schema. I doubt such support can be implemented at all since the generated code has no knowledge of the values that should be used in new elements/attributes or their cardinalities. However, if you first change your schemas in a backwards-compatible way (that is, all new elements and attributes are made optional) then you can read the old XML documents with the new generated code, set values for the new elements/attributes using the object model, and serialize it back to XML in the new format. After you have migrated all your XML documents using this approach you can change the schema again to make the new elements and attributes non-optional. Boris From Raymond.Rizzuto at sig.com Wed Aug 27 18:26:54 2008 From: Raymond.Rizzuto at sig.com (Rizzuto, Raymond) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] comparison operation In-Reply-To: <20080714201916.GB4395@karelia> References: <20080714201916.GB4395@karelia> Message-ID: Boris, Is there a way to use the new 3.2.0 feature that address the precision of float/double to "fix" the representation issue? I.e. if my original double is rounded to XSD_CXX_TREE_DOUBLE_PRECISION places. If I take the rounded value, serialize and deserialize it via my XSD-generated library, would the deserialized value be guaranteed to compare equal to the rounded version I serialized? Ray -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Monday, July 14, 2008 4:19 PM To: Rizzuto, Raymond Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] comparison operation Hi Ray, Rizzuto, Raymond writes: > So, there are two effects going on here. One is that the serialization to > XML loses digits after microseconds. The other is conversion from a string > to a double can run into representation issues. Correct on both counts. > I am not sure if it is worth addressing the first issue - microseconds > may be sufficient for most purposes. In my code, I think I can limit > the value to 6 decimal places fairly easily. Yes, we have to pick some default value and microseconds seems like a reasonable compromise. You always have an option to customize the dateTime type and serialize the seconds component with your desired precision. > The representation issue isn't an issue for precision, but it certainly > affects any comparison of types that rely on doubles. I'm not sure if > there is a good answer here. I don't think there is a practical solution to this one since that's how floating point types work. So the only suggestion I can offer is to choose floating point values for your test so that they don't trigger this problem. Boris IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses. From boris at codesynthesis.com Thu Aug 28 16:19:44 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] comparison operation In-Reply-To: References: <20080714201916.GB4395@karelia> Message-ID: <20080828201944.GA24273@tpad> Hi Ray, Rizzuto, Raymond writes: > Is there a way to use the new 3.2.0 feature that address the precision > of float/double to "fix" the representation issue? > > I.e. if my original double is rounded to XSD_CXX_TREE_DOUBLE_PRECISION > places. If I take the rounded value, serialize and deserialize it via > my XSD-generated library, would the deserialized value be guaranteed to > compare equal to the rounded version I serialized? This is a tricky question. First, even if in your program the decimal representation of a floating point number is rounded to some number of digits, there is no guarantee that the actual binary representation will contain the same number of digits. Here is an example (taken from the paper mentioned below): float f = 3.1459; // the actual value stored in f is 3.1459001 I believe the way to achieve what you want is to serialize all potentially significant digits as explained in this paper: http://www2.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf You can achieve this in XSD 3.2.0 by defining the following macros when compiling your program: XSD_CXX_TREE_FLOAT_PRECISION_MAX XSD_CXX_TREE_DOUBLE_PRECISION_MAX XSD_CXX_TREE_DECIMAL_PRECISION_MAX There is, however, another potential problem: it does not seem to be guaranteed that the C++ runtime will always be able to preserve all the digits when reading a floating point number serialized with such a precision. I remember reading on some mailing list that the VC++ runtime is unable to round-trip without loss in some cases (I think it was one of the Boost mailing lists, if you would like, I can try to find those posts). One alternative would be to customize the float/double/decimal types and implement their parsing/serialization using floating point routines that are known to preserve all potentially significant digits during serialization and parsing. One such library seems to be netlib/fp though I haven't used it myself: http://www.netlib.org/fp/index.html The 'custom/double' example shows how to customize the double XML Schema built-in type. Boris From Raymond.Rizzuto at sig.com Fri Aug 29 12:16:29 2008 From: Raymond.Rizzuto at sig.com (Rizzuto, Raymond) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] comparison operation In-Reply-To: <20080828201944.GA24273@tpad> References: <20080714201916.GB4395@karelia> <20080828201944.GA24273@tpad> Message-ID: Boris, I can't access the first URL - I get an "Object not found!| Message when I try. I believe that is the same link as from your 3.2.0 beta1 release posting, and I did look at that 2 days ago, so maybe it will be back later. I'm hoping I can set the precision to 6 places so that timestamps will round trip at the microsecond range. I'd be interested in reading the post about VC++ and round-trip for floats if you can find it. I'm targeting Linux currently, but would like to understand the issue in case it can happen in other environments. Ray -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Thursday, August 28, 2008 4:20 PM To: Rizzuto, Raymond Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] comparison operation Hi Ray, Rizzuto, Raymond writes: > Is there a way to use the new 3.2.0 feature that address the precision > of float/double to "fix" the representation issue? > > I.e. if my original double is rounded to XSD_CXX_TREE_DOUBLE_PRECISION > places. If I take the rounded value, serialize and deserialize it via > my XSD-generated library, would the deserialized value be guaranteed to > compare equal to the rounded version I serialized? This is a tricky question. First, even if in your program the decimal representation of a floating point number is rounded to some number of digits, there is no guarantee that the actual binary representation will contain the same number of digits. Here is an example (taken from the paper mentioned below): float f = 3.1459; // the actual value stored in f is 3.1459001 I believe the way to achieve what you want is to serialize all potentially significant digits as explained in this paper: http://www2.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf You can achieve this in XSD 3.2.0 by defining the following macros when compiling your program: XSD_CXX_TREE_FLOAT_PRECISION_MAX XSD_CXX_TREE_DOUBLE_PRECISION_MAX XSD_CXX_TREE_DECIMAL_PRECISION_MAX There is, however, another potential problem: it does not seem to be guaranteed that the C++ runtime will always be able to preserve all the digits when reading a floating point number serialized with such a precision. I remember reading on some mailing list that the VC++ runtime is unable to round-trip without loss in some cases (I think it was one of the Boost mailing lists, if you would like, I can try to find those posts). One alternative would be to customize the float/double/decimal types and implement their parsing/serialization using floating point routines that are known to preserve all potentially significant digits during serialization and parsing. One such library seems to be netlib/fp though I haven't used it myself: http://www.netlib.org/fp/index.html The 'custom/double' example shows how to customize the double XML Schema built-in type. Boris IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses. From Raymond.Rizzuto at sig.com Fri Aug 29 12:36:44 2008 From: Raymond.Rizzuto at sig.com (Rizzuto, Raymond) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] comparison operation References: <20080714201916.GB4395@karelia> <20080828201944.GA24273@tpad> Message-ID: This link works: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf -----Original Message----- From: Rizzuto, Raymond Sent: Friday, August 29, 2008 12:16 PM To: 'Boris Kolpackov'; 'Rizzuto, Raymond' Cc: 'xsd-users@codesynthesis.com' Subject: RE: [xsd-users] comparison operation Boris, I can't access the first URL - I get an "Object not found!| Message when I try. I believe that is the same link as from your 3.2.0 beta1 release posting, and I did look at that 2 days ago, so maybe it will be back later. I'm hoping I can set the precision to 6 places so that timestamps will round trip at the microsecond range. I'd be interested in reading the post about VC++ and round-trip for floats if you can find it. I'm targeting Linux currently, but would like to understand the issue in case it can happen in other environments. Ray -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Thursday, August 28, 2008 4:20 PM To: Rizzuto, Raymond Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] comparison operation Hi Ray, Rizzuto, Raymond writes: > Is there a way to use the new 3.2.0 feature that address the precision > of float/double to "fix" the representation issue? > > I.e. if my original double is rounded to XSD_CXX_TREE_DOUBLE_PRECISION > places. If I take the rounded value, serialize and deserialize it via > my XSD-generated library, would the deserialized value be guaranteed to > compare equal to the rounded version I serialized? This is a tricky question. First, even if in your program the decimal representation of a floating point number is rounded to some number of digits, there is no guarantee that the actual binary representation will contain the same number of digits. Here is an example (taken from the paper mentioned below): float f = 3.1459; // the actual value stored in f is 3.1459001 I believe the way to achieve what you want is to serialize all potentially significant digits as explained in this paper: http://www2.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf You can achieve this in XSD 3.2.0 by defining the following macros when compiling your program: XSD_CXX_TREE_FLOAT_PRECISION_MAX XSD_CXX_TREE_DOUBLE_PRECISION_MAX XSD_CXX_TREE_DECIMAL_PRECISION_MAX There is, however, another potential problem: it does not seem to be guaranteed that the C++ runtime will always be able to preserve all the digits when reading a floating point number serialized with such a precision. I remember reading on some mailing list that the VC++ runtime is unable to round-trip without loss in some cases (I think it was one of the Boost mailing lists, if you would like, I can try to find those posts). One alternative would be to customize the float/double/decimal types and implement their parsing/serialization using floating point routines that are known to preserve all potentially significant digits during serialization and parsing. One such library seems to be netlib/fp though I haven't used it myself: http://www.netlib.org/fp/index.html The 'custom/double' example shows how to customize the double XML Schema built-in type. Boris IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses. From boris at codesynthesis.com Sun Aug 31 06:17:47 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:05 2009 Subject: [xsd-users] comparison operation In-Reply-To: References: <20080714201916.GB4395@karelia> <20080828201944.GA24273@tpad> Message-ID: <20080831101747.GA7719@tpad> Hi Ray, Rizzuto, Raymond writes: > I can't access the first URL - I get an "Object not found!| Message when > I try. I believe that is the same link as from your 3.2.0 beta1 release > posting, and I did look at that 2 days ago, so maybe it will be back later. Ok, I've removed 2 from www2 in all the places. > I'm hoping I can set the precision to 6 places so that timestamps will > round trip at the microsecond range. On the second thought, perhaps it can work if the numbers you are trying to serialize are also rounded to this precision (that is, the binary representation will have more digits but they will be the same). Another alternative would be to compare string representations. For example, you could defined the Timestamp type in XML Schema by deriving from double. You would then customize this type and provide your own comparison operator implementation which compares two Timestamps as strings with precision 6. This will be slower but will work on all platforms. > I'd be interested in reading the post about VC++ and round-trip for > floats if you can find it. It is this (long) thread on boost-devel: http://lists.boost.org/Archives/boost/2006/03/101988.php The posts of particular interest are: http://lists.boost.org/Archives/boost/2006/04/102744.php http://lists.boost.org/Archives/boost/2006/04/102833.php Boris