× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



This is elementary gents,

<MYXML>
<ESI_DATA_ENTRY>
<Data_Type/>
<Data_LEN/>
<DATA/>
</ESI_DATA_ENTRY>
<ESI_DATA_ENTRY>
<Data_Type/>
<Data_LEN>1234</Data_LEN>
<DATA/>
</ESI_DATA_ENTRY>
<ESI_DATA_ENTRY>
<Data_Type/>
<Data_LEN/>
<DATA/>
</ESI_DATA_ENTRY>
</MYXML>

results in ...

DSPLY 0
DSPLY 1234
DSPLY 0

With this powerEXT code ...

xmlFromStmf('/myxml.xml');
xmlReaderInz(xmlAddr():xmlSize());
dow xmlReader = 0;
select;
when xmlGetNode = 'Data_LEN' and xmlGetAttr = '';
num = xmlGetDataNum;
dsp = %char(num);
dsply dsp;
endsl;
enddo;


On Thu, Mar 7, 2013 at 4:43 PM, Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:


On Thu, 7 Mar 2013, at 00:46:47, Joep Beckeringh <
joep.beckeringh@xxxxxxxxxx> wrote:

But I'm still not convinced: I don't see your point about a missing
letter, what has that got to do with allow missing/allowextra? It would
just be bad data; a customer ID of 'on Paris' would certainly be rejected
by the check after the parsing. And a malformed numeric could cause an
exception when the target field was numeric; if I had defined the field
alpha, it would not pass the check either.

What I'm trying to point out is that your approach only deals with one
scenario:

It deals with this: <quantity></quantity> but not with this
<quantity>None</quantity> or <quantity>10CR</quantity>. So using numerics
in the DS always runs the risk of the parser failing completely. That's all
I'm trying to point out. If you are guaranteed that won't happen then fine.

But if I deal with quantity as alpha I can do the conversion with %Dec
wrapped in a MONITOR. Not only can I then provide a default value but
(perhaps more importantly) I can report easily on exactly which element was
in error and what the value encountered was. Requires a bit more coding but
no speed penalty because under the covers that is what RPG is doing anyway.

You're right that I'm assuming documents that will fit into memory. I
admit I haven't really explored the nuances of using XML-INTO with a
handler; if I needed a handler anyway, I would be inclined to use XML-SAX.

I don't understand why you would switch to -SAX for that. The logic is
only marginally different to use -INTO with a handler and has the advantage
that you can deal with the document in pieces if desirable. e.g. Trigger a
process as each element group is processed as opposed to waiting until the
end of the XML-INTO. -SAX requires a lot more work.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com




--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.