Start of change

Examples of the allowextra option with unexpected non-text content for a scalar variable or subfield

The following definitions are used in the examples
D text            S            200A    VARYING

D order           DS                   QUALIFIED
D   part                        25A    VARYING
D   quantity                    10I 0
Assume that file txt.xml contains the following lines:
<?xml version='1.0' ?>
<text><word>Hello</word><word>World</word></text>
Assume that file ord.xml contains the following lines:
<?xml version='1.0' ?>
<order>
 <part>Jack in a box<discount>yes</discount></part>
 <quantity multiplier="10">2</quantity>
</order>
  1. RPG variable text is a standalone field. The XML file txt.xml has an element called text with two child elements called word. The XML-INTO operation fails with status 00353 because the text XML element has child elements, and the allowextra option defaults to no.
      xml-into(e) text %XML('txt.xml' : 'doc=file');
      // %error = *on
      // %status = 353
  2. Option allowextra=yes is specified. The child XML elements are ignored. The XML-INTO operation succeeds, but since the only content for the text XML element is the child XML elements, no data is available for RPG field text.
      xml-into text %XML('txt.xml' : 'allowextra=yes doc=file';
      text = '';
  3. RPG variable order is a data structure with two subfields which are not themselves data structures. The XML elements representing the subfields should not have child elements or attributes, but the part XML element does have one child, discount, and the quantity XML element has an attribute multiplier. Option allowextra=yes is specified, so the discount element and multiplier attribute are ignored.
      xml-into order %XML('ord.xml'
                        : 'doc=file allowextra=yes');
      // order.part = "Jack in a box"
      // order.quantity = 2
End of change