| symbol | The name of a template variable that has not been previously declared. |
| data | The name of a field, RECORD structure, or dataset. |
The #EXPORTXML statement produces the same XML as #EXPORT from the specified data and places it in the symbol, then does a LOADXML(symbol, 'label') on the data.
Example:
NamesRecord := RECORD
STRING10 first;
STRING20 last;
END;
r := RECORD
UNSIGNED4 dg_parentid;
STRING10 dg_firstname;
STRING dg_lastname;
UNSIGNED1 dg_prange;
IFBLOCK(SELF.dg_prange % 2 = 0)
STRING20 extrafield;
END;
NamesRecord namerec;
DATASET(NamesRecord) childNames;
END;
ds := DATASET('~RTTEST::OUT::ds', r, THOR);
//This example produces the same result as the example for #EXPORT.
//Notice the lack of #DECLARE and LOADXML in this version:
#EXPORTXML(Fred,r);
#FOR (Fred)
#FOR (Field)
#IF (%'{@isEnd}'% <> '')
OUTPUT('END');
#ELSE
OUTPUT(%'{@type}'%
#IF (%'{@size}'% <> '-15' AND
%'{@isRecord}'%='' AND
%'{@isDataset}'%='')
+ %'{@size}'%
#END
+ ' ' + %'{@label}'% + ';');
#END
#END
#END
OUTPUT('Done');
//**********************************************************
//These examples show some other possible uses of #EXPORTXML:
//This could be greatly simplified as
// (%'{IsAStringMetaInfo/Field[1]/@type}'%='string')
isAString(inputField) := MACRO
#EXPORTXML(IsAStringMetaInfo, inputField);
#IF (%'IsAString'%='')
#DECLARE(IsAString);
#END;
#SET(IsAString, false);
#FOR (IsAStringMetaInfo)
#FOR (Field)
#IF (%'{@type}'% = 'string')
#SET (IsAString, true);
#END
#BREAK
#END
#END
%IsAString%
ENDMACRO;
getFieldName(inputField) := MACRO
#EXPORTXML(GetFieldNameMetaInfo, inputField);
%'{GetFieldNameMetaInfo/Field[1]/@name}'%
ENDMACRO;
displayIsAString(inputField) := MACRO
OUTPUT(getFieldName(inputField)
+ TRIM(IF(isAString(inputField), ' is', ' is not'))
+ ' a string.')
ENDMACRO;
SIZEOF(r.dg_firstname);
isAString(r.dg_firstname);
getFieldName(r.dg_firstname);
OUTPUT('ds.dg_firstname isAString? '
+ (STRING)isAString(ds.dg_firstname));
isAString(ds.namerec);
displayIsAString(ds.namerec);
displayIsAString(r.dg_firstname);