XML.GENERATE Subroutine
Generates an XML document by inserting data from a dynamic array into an XML template.
Syntax
XML.GENERATE(errorMsg, result, template, array)
Syntax Elements
errorMsg A variable in which to return an error message, should an error occur. If the subroutine completes successfully, a null string is returned.
result A variable in which to return a string containing the resulting XML document. Attribute marks in template are replaced by new lines.
template A string containing an XML template in MultiValue format (lines must be separated by attribute marks). For information about how to write an XML template, refer to Writing an XML Template.
array A dynamic array containing input data.
Operation
The XML document is generated as follows:
-
Text with the form SVMattrNo{,valueNo{,subvalueNo}}SVM (where SVM represents a subvalue mark) in the template is replaced by the data from the dynamic array specified by attrNo, valueNo and subvalueNo.
-
Text enclosed in value marks is optional. If all substitutions evaluate to null, the enclosed text is omitted from the XML document (the text is also omitted if it contains no substitutions). Optional text cannot be nested.
-
Text enclosed in curly braces {…} can have valueNo replaced with +. This causes all relevant values to be exploded.
-
Text enclosed in double curly braces {{…}} can have subvalueNo replaced with +. This causes all relevant sub-values to be exploded.
Processing Options
The characters used to delimit substitutions, optional text and repeated text can be changed by including, as the first node in the template, an XML node with the following format:
<__nis_cont {paramDelim="string1"} {optionalDelim="string2"} {repeatDelim="string3"} {removeWhiteSpace="YES"}/>
where string1 and string2 are single characters or sequences of character that do not appear elsewhere in the template, and string3 is a pair of characters respectively used to delimit the start and end of a repeated section. The final processing option, if present, suppresses extraneous white space in the XML document.
Comments
Refer to XML Generation for details of how to use this subroutine.