Skip to main content

Posts

Showing posts from March, 2016

Working with XML in RPGLE : XML-SAX

Working with XML in RPGLE : XML-SAX Working with XML has never been easier before IBM's introduction of XML-INTO and XML-SAX compatibility to RPGLE. My earlier post did contain detailed info about basics on XML with RPGLE and compatibility of XML-INTO with RPGLE along with its own advantages and disadvantages. If you haven't gone through them yet, Click on those links to have quick look. XML-SAX: Even though XML-INTO provides the greatest comfort to programmers by directly bringing the data to Respective variable/data structure. But, this doesn't help programmers when the XML elements/data has been inconsistent. XML-SAX is the best way of handling such XMLs. This will read the XML character by character and calls Handling Procedure when the even gets triggered. Syntax: Xml-Sax(e) %Handler(XMLHandler_Procedure : CommsArea_DataStructure ) %XML(wXmlString: 'doc=string') Below are some possible events that can occur while parsing XML.  This has been split by the phas

Working with XML in RPGLE - Contd.

Working with XML in RPGLE We have seen how to read XML in RPG by using XML-INTO in the previous post. If you have not gone through this yet,  Click Here to have quick look. Before we get started with XML-SAX here are some other key points to be noted about XML. Key Points to Remember: The XML documents can be in a character or UCS-2 RPG variable, or they can be in an Integrated File System file. This would give freedom to the programmer to choose the best suited form.  The parser is a SAX (Simple API for XML) parser. A SAX parser operates by reading the XML document character by character. Whenever it has located a fragment of the XML document, such as an element name, or an attribute value, it calls back to a handling procedure provided by the caller of the parser, passing it information about the fragment of XML that it has found. It'd be easier to understand with an example. E.g.: When the parser has found an XML element name, it calls the handling procedure indicating that th

Working with XML in RPGLE : XML-INTO

Working with XML in RPGLE XML has been one of the best format to pass a communication message between different Applications/Servers. This can be easily readable by both Humans & Machines. With the introduction of XML-INTO Opcode in RPGLE, Reading XML has become easier in RPG. XML-INTO: XML-INTO is an Opcode introduced for RPG programmers to retrieve XML data directly to RPG Variable. This Opcode need to be used in conjuction with %XML & %HANDLER. This can be used in both Free & Fixed Formats. Yet, There will be limitations for using in fixed format. One of the Main Reasons being the its limitation on Number of digits. XML-INTO parses an XML document extracting a single element directly into a variable (Or an array). Usually, This will be used to extract multiple elements and values will be populated to Data Structure. But, This approach would be better suited if number of items retrieved is known. The basic syntax of the basic variant of XML-INTO is: XML-INTO { (E H} } va