LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Map with variant data in XML Schema causes crash

Solved!
Go to solution

I'm attempting to use a map with variant data for a configuration database and tried using the LabVIEW XML Schema for simplicity, however the "Untlatten from XML" method seems to crash LabVIEW when using this data type. Is this a known issue? If so, is there a workaround?

map with variant data xml schema.png

Version 22.3.1f8 (32-bit)

0 Kudos
Message 1 of 8
(1,277 Views)

Have you considered flattening your data to a string and then mime encode it. That would be a little overhead but should be safe for XML and JSON. Not sure how XML deals with binary data which you will end up encountering using variants.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 8
(1,271 Views)

Not sure I follow. Are you suggesting to flatten the entire map of variants or to use a map of flattened strings? Also you lost me on mime encoding. The goal is to have a map of variants (using variant attributes) saved to a human-readable config file.

0 Kudos
Message 3 of 8
(1,265 Views)

A variant will not be human readable and will contain binary data. If you want it to be human readable your only real option is to have everything a string. You would need to convert your numeric data to ASCII and then save to file. Also, if you want to have humans read it JSON is easier to work with then XML in my opinion. However you will have the same problem there as well.

 

What I was suggesting was to replace your variant with a string. Then flatten your data to a string and then do a base64 encoding of that string. Neither XML or JSON deal with binary data very well not to mention that binary data is not very human readable.

 

If you want to stick with flatten to XML or flatten to JSON then I suggest you create a cluster definition for the data you want to store to file and then flatten that. 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 8
(1,254 Views)

Binary data will not be human readable, no. But all simple data types I will be using (numerics, strings, booleans, enums, arrays, etc.) work fine. Variant attributes seem to work fine with the XML schema as of LabVIEW 2020; I was hoping to leverage maps in addition to that.

0 Kudos
Message 5 of 8
(1,238 Views)

Then I would suggest converting your map to an array and then flatten the data.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 6 of 8
(1,223 Views)
Solution
Accepted by APolk@BW

An array seems to work fine.  Not sure why the Map has issues, but the following snippet serves mostly the same functionality and doesn't crash.

 

array with variant data xml schema.png

0 Kudos
Message 7 of 8
(1,201 Views)

Just curious why you marked your post as the solution when it was I that suggested it. At least give credit where credit is due.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 8 of 8
(1,193 Views)