Reply To: Need to build an interface for XML to SQL Datadata

Reply To: Need to build an interface for XML to SQL Datadata

Home Forums NAACCR XML Standard Need to build an interface for XML to SQL Datadata Reply To: Need to build an interface for XML to SQL Datadata

#9661

Jeff, I’m getting confused.

I thought you were working with the functions to read the data file, but the declarations you just quoted are for reading the dictionary.

When reading the data file, you pass the callback parameters (owner, callback_func) to the XMLPlus_OpenXmlDataFile function. My thinking was that you’ll be calling the “XMLPlus_GetItemDataBy[NaaccrId or NaaccrNum]” function gazillions of times, so just post the callback once for the entire run. (There is some set-up involved with posting a callback in the DLL, not costly, but why waste cycles? Reasonable people can argue about my design choices…)

Looks like I have the problem using a pointer return variable to access the actual string.

The “GetItemDataBy” functions don’t retrieve the data value directly; instead, the DLL locates the value by the identifier, and then sends the “answer” back through the callback function. I have a very good reason for this design choice: If you expected the DLL to populate a reference variable supplied in your direct call, you would have to first ask how long that string value is so that you could size your string appropriately (otherwise, danger of buffer overflow!). But through the magic of pointers, the DLL is maintaining the contents of the requested item in its local memory long enough to stream it to your callback function, where you can capture it to a C# string and manage that memory yourself.

Take another look at the C++ sample, “Run EDITS on NAACCR XML Data File”, and look for XmlToFlatReadItemByNaaccrNum and XmlToFlatReadItemByNaaccrId. Particularly for preparing the EDITS buffer dynamically, you can see that more steps are required when you have to do the look-up by naaccrId, but it can be done.

Kathleen

Copyright © 2018 NAACCR, Inc. All Rights Reserved | naaccr-swoosh-only See NAACCR Partners and Sponsors