LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to compile cvixml.fp after modifying cvixml.c

I need to modify the below line in cvixml.c

#define XML_PROC_INSTR_DATA "version=\"1.0\""

to this:

#define XML_PROC_INSTR_DATA "version=\"1.0\"encoding=\"ISO-8859-1\""

 

After opening the cvixml.fp file and creating a project I can then modify the cvixml.c file.  Then when I try to compile I get a "An unspecified error has occurred, probably due to corrupted data".

 

How do I fix this?  I just want to have my xml files start with the below tag.

<?xml version="1.0" encoding="ISO-8859-1"?>

 

If ther is a better solution to do this please let me know.  Thanks.

0 Kudos
Message 1 of 6
(4,572 Views)

Trquinn,

 

If you're attempting to modify cvixml.fp then I assume you're trying to set it up so that all the XML files you create with these functions use the ISO-8859-1 encoding. Rather than modify CVI functions, you're much better off just using the CVIXMLAddAttribute to include the "encoding" property by specifying a name and value to associate with the root element.

Kirk L. | Applications Engineer | National Instruments
0 Kudos
Message 2 of 6
(4,521 Views)

Thanks for the reply.  That may be an option.  I need to find out.  I have never worked with XML files before.  I was given an example file and asked to create test records similar to it. The example file had "<?xml version="1.0" encoding="ISO-8859-1"?>" at the top of it.  I was just trying to reproduce that.  Thanks.

0 Kudos
Message 3 of 6
(4,513 Views)

Trquinn,

 

I took another look at this issue; as it turns out, the xml prolog (<?xml version="1.0" encoding="ISO-8859-1"?>) is a special case where "version" and "encoding" do not count as standard attributes, so the the cvi functions won't be able to set that attribute, because it is technically not an attribute.

 

You could try parsing this file and replacing the string in the prolog with your encoding, but that might get messy.

Kirk L. | Applications Engineer | National Instruments
0 Kudos
Message 4 of 6
(4,501 Views)

Thanks.  I did submit a help ticket and they were able to tell me how to create a new cvixml.obj file.  That worked.  I can now create a file with this header. 

0 Kudos
Message 5 of 6
(4,498 Views)

For clarification, the modification which made adding this information to the XML file header was done in the source file for the cvixml function panel, cvixml.c. See the bold line in the following snippet from cvixml.c

 

//-----------------------------------------------------------------------------
// Constants and macros
//-----------------------------------------------------------------------------
#define TMP_PREFIX "CVI"
#define TAG_OPEN '<'
#define TAG_CLOSE '>'
#define TAG_END '/'
#define NEWLINE '\n'
#define XML_PROC_INSTR_TARG "xml"
#define XML_PROC_INSTR_DATA "version=\"1.0\" encoding=\"ISO-8859-1\""
#define eofChk(fcall) if (error = (fcall), error == EOF) goto Error;
#define libErrChk(fcall) if (error = (fcall), error < 0) {__result = E_UNEXPECTED; goto Error;} else
#define LOCK(l, c) {libErrChk(CmtGetLock(l)); c++;}
#define UNLOCK(l, c) {while(c--) CmtReleaseLock(l);} 

The XML_PROC_INSTR_DATA macro is used in CVIXMLNewDocument for creating the header information.

Daniel Dorroh
National Instruments
0 Kudos
Message 6 of 6
(4,455 Views)