Slide 18
Slide 18 text
need for XDI XDI specification XDI implementation
Validation
Example code in C
1 #include "xdifile.h"
XDIFile *xdifile;
int ret;
4
xdifile = malloc(sizeof(XDIFile));
ret = XDI_readfile (xdifile , "mydata.xdi");
7 /* test return code ‘ret ’ for errors */
/* test for required metadata */
10 j = XDI_required_metadata (xdifile);
if (j != 0 ) {
printf("\n# ( requirement code %ld):\n%s\n",
13 j, xdifile -> error_message );
}
/* test for recommended metadata */
16 j = XDI_recommended_metadata (xdifile);
if (j != 0 ) {
printf("\n# ( recommendation code %ld):\n%s\n",
19 j, xdifile -> error_message );
}
/* examine each individual metadata item */
22 for (i=0; i < xdifile ->nmetadata; i++) {
j = XDI_validate_item (xdifile ,
xdifile -> meta_families [i],
25 xdifile -> meta_keywords [i],
xdifile -> meta_values [i]);
/* test return value ‘j’ */
28 }
/* ************************ */
/* do stuff with the data */
31 /* ************************ */
XDI_cleanup(xdifile , ret);
free(xdifile);
1 Read the XDI file. Without
obvious errors (inconsistent
number of data columns,
non-numbers in data table,
etc.), file content stored in a
struct. (Lines 1-6)
2 Test if required metadata items
are present. (Lines 10-14)
3 Test if recommended metadata
items are present.
(Lines 16-20)
4 Validate individual items
against the dictionary.
(Lines 22-28)
Steps 2-4 are optional
7 / 10
XAS Data Interchange