Examples of the doc option
Examples of the doc option
-
In the following example, the first parameter of %XML and %DATA is the name of a file. Option doc=file must be specified.
ifsfile1 = 'myfile.xml'; ifsfile2 = 'myfile.json'; ifsfile3 = 'myfile.csv'; opt = 'doc=file'; XML-INTO myfield %XML(ifsfile1 : opt); DATA-INTO myfield %DATA(ifsfile2 : opt) %PARSER('MYJSONPARS'); DATA-GEN myfield %DATA(ifsfile3 : opt) %GEN('MYCSVGEN'); -
In the following example, the first parameter of %XML and %DATA is a character variable containing an document for the XML-INTO or DATA-INTO operations, and a character variable to receive the document for the DATA-GEN operation. Since the doc option defaults to “string”, no options are necessary. However, option doc=string may be specified. In the following example, each pair of operations is equivalent.
xmldata = '<data><num>3</num></data>'; XML-INTO data %XML(xmldata); XML-INTO data %XML(xmldata : 'doc=string'); jsondata = '{"data":{"num":"3"}}'; DATA-INTO data %DATA(jsondata) %PARSER('MYJSONPARS'); DATA-INTO data %DATA(jsondata : 'doc=string') %PARSER('MYJSONPARS'); chain (id) custRec rec custDs; DATA-GEN custDs %DATA(custInfo) %GEN('MYCSVGEN'); DATA-GEN custDs %DATA(custInfo : 'doc=string') %GEN('MYCSVGEN');