[xsd-users] unable to write new fields to XML file

Aciel Eshky aciel.eshky at gmail.com
Mon Dec 28 06:40:27 EST 2015


Hi Boris,

Thanks for your response. I was able to resolve the problem by removing the
namespace from the xsd file. I am now able to write the results to an
output xml file (which looks like the input but with the results appended
to it).

If possible, I'd still like to understand why it wasn't working properly
before. In my xsd options, I was previously using the namespace mapping and
it was working properly as far as input xml files are concered. Perhaps I
was missing something similar for the output?

Here is my c++ code.

xml_schema::namespace_infomap map;
map[""].name = "ourwebsite";
map[""].schema = "ourschemaname.xsd";

char* ptr_xml_file_out = "output_with_results.xml";
std::ofstream ofs(ptr_xml_file_out);

QBAS_(ofs, *q, map);

Any useful insights would be appreciated.

Thanks!
Aciel

On 17 December 2015 at 14:34, Boris Kolpackov <boris at codesynthesis.com>
wrote:

> Hi Aciel,
>
> Aciel Eshky <aciel.eshky at gmail.com> writes:
>
> > Some of the xml tags in the schema are optional, and specify the results
> of
> > computations that we carry out on the contents of the input xml file. The
> > input xml file has none of these results fields, but the output xml file
> > should have them. We are able to populate these filed in the c++ object
> > representing the xml file, but when we print the object to a file none of
> > the results fields are printed. Any idea what the issue could be?
>
> My first guess is that you are making copies of the model nodes instaed of
> using references. As result, when you then modify them, you are modifying
> copies, not the original object model.
>
> See Section 4.3, "Modifying the Object Model" for more details on this
> issue:
>
> http://codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#4.3
>
> Boris
>



-- 
Aciel


More information about the xsd-users mailing list