From p.s.tilma at knid.nl Tue Feb 2 15:45:02 2021 From: p.s.tilma at knid.nl (p.s.tilma@knid.nl) Date: Wed Feb 3 04:24:34 2021 Subject: [xsd-users] Reading and writing sensor data from and to XML Message-ID: <4a586eda-0512-63df-276d-a4a0877ece16@knid.nl> Anjum, 2 february 2021 Hello everybody, I am busy with a project in which field sensor data has to be read from or written to a XML file. For my project I compiled all necessary XML schema files with xsdcxx cxx-tree. The generated *.cxx and *.hxx files are then added to my project. After compilation and linking I have a working application. In this application I have a button for parsing and (after modification) serialising to a xml file, and a button for creating an object model from scratch. Parsing and serialising seem to work, but there is a problem. When I print the output in a textbox I do not see the data *0,5 10,2 50,2 80,5 100,15* (see element below) in the generated XML. The relevant part of my XML file : ??????? ??????????? Measurement error vs. temperature ??????????? ????????????? ??????????????? 5 ????????????? ??????????? ??????????? ????????????? ??????????????? Error vs. Temperature ??????????????? ??????????????????? Temperature ??????????????????? ????????????????? ??????????????? ??????????????? ????????????????? ??????????????????? Relative Error ??????????????????? ????????????????? ??????????????? ????????????? ??????????? ??????????? ????????????? ??????????? ??????????? *0,5 10,2 50,2 80,5 100,15* ??????? So my first question is : how do I read or write the contents (sensor data) of element Another question : I am also trying to create an object model from scratch. But during serialising the application crashes. How can you display errors which occur during serialisation. Attached : swe-profile.xsd Hopefully you can give me some hints or tips. Kind regards from Pier Tilma Anjum The Netherlands -------------- next part -------------- A non-text attachment was scrubbed... Name: swe-profile.xsd Type: application/xml Size: 33756 bytes Desc: not available Url : https://codesynthesis.com/pipermail/xsd-users/attachments/20210202/8d0019c4/swe-profile.xml From boris at codesynthesis.com Mon Feb 8 06:33:22 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Feb 8 06:38:29 2021 Subject: [xsd-users] Reading and writing sensor data from and to XML In-Reply-To: <4a586eda-0512-63df-276d-a4a0877ece16@knid.nl> References: <4a586eda-0512-63df-276d-a4a0877ece16@knid.nl> Message-ID: p.s.tilma@knid.nl writes: > Parsing and serialising seem to work, but there is a problem. When I print > the output in a textbox I do not see the data *0,5 10,2 50,2 80,5 100,15* > (see element below) in the generated XML. Here is the type of this element: As you can see it has mixed content (meaning elements and be mixed with text in any order) and it derives from anyType (meaning that it can contain any nested elements). So, in effect, this element can contain anything. Naturally, there is no statically-typed mapping for something like this so you will have to deal with it yourself. There are several ways to do it as shown in the following examples (part of the XSD package): examples/cxx/tree/order/mixed/ examples/cxx/tree/custom/mixed/ examples/cxx/tree/mixed/ > Another question : I am also trying to create an object model from scratch. > But during serialising the application crashes. How can you display errors > which occur during serialisation. That depends on why it is crashing. If it's due to a C++ exception, then you can try to catch and print it to get more information (see "Error Handling" sections in the documentation for details). If it crashed for other reasons (e.g., access violation, etc), then you will need to use a debugger.