My experience is that, xml input to RPGLE need not be complicated (output is a bit of a no-brainer).
Long before we could use java effectively on OS/400, before Scott migrated Expat, before CGIDEV2 had yet to become more than a idea in Mal's head just like powerExt, it was necessary to write code yourself if you wanted to parse xml within RPG. When xml was invented one of the intentions was that it should be easy for any developer worth there salt to write a parser in any language. In fact it was not that difficult given that RPGLE already supported call-back procedures way back then. It's not necessary to write a fully blown world class parser but just one that delivers the functionality for your needs. So I wrote a sax parser which is still deployed by our core processes that have yet to be rewritten.
Nowadays, thanks to Barbara and her colleagues, we have an RPGLE compiler where XML-INTO delivers xml into pre-defined data structures so that developers need only dwell on processing the data structures.
But many people forget that they also did a wonderful with XML-SAX which means it's easy to rapidly parse an entire document using a single procedure as a handler that need only contain subroutines to process just the elements you choose. Of course it's easy to blow any procedure into something that's too complex if you want the whole world to use it, but it's quite likely that your needs are simple and if you try XML-SAX you may be pleasantly surprised that all the 3rd party trappings are unnecessary.
Cheers, Peter
-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Henrik Rützou
Sent: Thursday, 23 June 2011 7:03 AM
To: Web Enabling the AS400 / iSeries
Subject: Re: [WEB400] XMLSERVICE, where can it be found?
Hi Thorbjørn,
as I read the tread, it is more about processing XML rather than writing
XML. This without
using a java based reader.
You have native RPGLE/XML-INTO, you can use the C-based EXPAT that Scoot
uses or
you can use the build in RPGLE based xmlReader in powerEXT Core and there
may be
other free tools out there. But if your main language (BL) is RPGLE why try
to include
java classes into RPGLE, reading XML isn't rocket science and no java
classes is
to my best knowledge able to offer you inline RPGLE routines to manage stmf
in/outs,
HTTP in/outs, xml generation/reading/manipulation in one coherent class and
most
javaclasses will be OO-oriented where your BL will be procedural.
IMHO mixing OO and procedural programming in most cases dosn't make the best
of
two worlds, it just complicate things and OO programming isn't very suitable
in most IBM i
business apps where the main purpose is to convert hirachical (such as XML)
data back and
forth into datastructures such as headers, details and totals in RDBMS
databases.
What Jon overlooked in his article is that powerEXT Core is based on CGIDEV2
so it also has
template support as XMLi - just as a general support feature.
Also powerEXT Core has its own easy to use and flexible XML reader where you
do not have
to build datastructures as in RPGLE/XML-INTO to read elements in a
xml-structure.
Because powerEXT Core is build on top of CGIDEV2 you can migrate any CGIDEV2
program
to a powerEXT program by just replacing the CGIDEV2 library with the
powerEXT library
and recompile the program. If you then want to add eg. XML or JSON support
to an existing
CGIDEV2 program it is just to add this line to the program:
* powerEXT API Connectors
/copy qsrc,pxapicgicn Basic HTTP connecter & Productivity Services
powerEXT Core has 85 subprocedures making it more a "all in one" concept and
it also runs
with HTTPAPI thus covering both HTTP server and client programs and
online/batch programs.
Here is a little example of some of the XML functionality:
/free
// Clear Service Program & Responce Object
clearSrvPgm();
setContent('*none');
// Node Support (Jon's example)
xmlNode( 'root' );
xmlNode( 'Element1' : '' : elementValue1 );
xmlNode( 'Element2' : '' : elementValue2 );
xmlEndNode();
// Template Support (same result as Jon's example)
// <!--#tag="root"-->
// <root>
// <Element1><% parm1 %></Element1>
// <Element2><% parm2 %></Element2>
// </root>
setExtVar('parm1':encodeXML('element1data'));
setExtVar('parm2':encodeXML('element2data'));
echoAsp('/myxmltemplate.xml':'root');
// Output to stmf and/or http client
echoToStmf( '/Partner400/powerExtTest.xml': 1208 );
echoToClient();
// Read XML from buffer just created:
xmlReaderInz(bufAddr:bufSize);
// Read XML from HTTP Input:
xmlStore = getExtInputRaw();
xmlReaderInz(storeAddr(xmlStore):storeSize(xmlStore));
storeFree(xmlStore);
// Read the XML file into memory with xmlFromStmf method
xmlFromStmf('/Partner400/powerExtTest.xml');
xmlReaderInz(xmlAddr:xmlSize);
// Set Case of Element And Attribute Names
xmlReaderCase('L');
// Read the XML
dow xmlReader = 0;
select;
// Reading Data in Elements
when xmlGetNode = 'element1' and xmlGetAttr = '';
myElement1 = xmlGetData;
when xmlGetNode = 'element2' and xmlGetAttr = '';
myElement2 = xmlGetData;
// Saving a part of the XML document to a stmf
// (saves a single <root>...</root> section)
when xmlGetNode = '/root';
xmlToStmf('/rootset0001.xml':xmlOuterAddr():xmlOuterSize():1208);
endsl;
enddo;
// Free XML storage
xmlFree();
return;
On Wed, Jun 22, 2011 at 8:35 PM, Thorbjoern Ravn Andersen
<ravn@xxxxxxxxxx>wrote:
Den 22/06/11 19.09, Richard Schoen skrev:
I don't know why you wouldn't use Java.
The 32-Bit JVM smokes.
It still takes a serious effort to get up and running, but you got a
point. We only upgraded to 6.1 recently and I have not yet had time to
look at the J9 one.
What I am looking for is more things that work well when in an ILE
world, and not inside a JVM.
You are after all @runjva.com :-)
True. For some reason nobody else wanted it :)
--
Thorbjørn Ravn Andersen "...plus... Tubular Bells!"
--
This is the Web Enabling the AS400 / iSeries (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.
As an Amazon Associate we earn from qualifying purchases.