× 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.



OK - I think we're on the same page now.

Just FYI, this is what XML-INTO looks like with a handler - which is basically a call-back process. This is a very silly little example but ...

The Dim(x) on the prototype tells RPG how many elements are to be parsed before the results are handed off to the handler. It receives the data and does whatever with it. This was used a lot in the early days of XML-INTO when RPG was basically limited to 64K for a variable. Since V6 with the increase to 16Mb it is needed less often - but still useful when you want to process a large file in bits. e.g. A incoming group fo orders can be parsed out and validated and sent on for further processing without wanting for all elements to be parsed.

XML:

<Customers><Company> .... </Company> ... repeated ... </Customers>

Mainline:

Dcl-Pr HandleCompany Int(10);
commArea Int(10);
company Char(32) Dim(4) Const;
numElements Int(10) Value;
End-Pr;

Dcl-S count Int(10) Inz;

XML-INTO %Handler( HandleCompany: count )
%XML(XML_Input1: 'path=Customers/Company case=any' );

Dsply ('Processed ' + %char(count) + ' total elements');

Handler:

Dcl-Proc HandleCompany;

Dcl-Pi *N Int(10);
count Int(10);
company Char(32) Dim(4) Const;
numElements Int(10) Value;
End-Pi;

Dcl-S i Int(10);

for i = 1 to numElements;
dsply company(i);
endfor;

// add current count to total in Comm Area and display current count
count += numElements;
dsply ( %Char(numElements) + ' elements loaded on this call' );
return 0;

End-Proc;


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Feb 25, 2019, at 10:42 AM, John Yeung <gallium.arsenide@xxxxxxxxx> wrote:

I'm not familiar with XML-INTO, and I certainly don't know about
handlers. Row-by-row access doesn't make sense to my understanding of
what DOM is. I'm not doubting you at all; I imagine you've done this
yourself already many times.

Now you've confused me. You were talking about SAX being better for selectivity

I did not ever use the word "selectivity" and I am not really sure
what you mean by it. I explained what I understand DOM to be and what
I understand SAX to be. I was talking about SAX for (1) lower memory
requirements than DOM (other than for pathological cases), and (2) the
ability to metaphorically see a progress bar rather than a spinning
hourglass while the parser is doing its thing.

Maybe XML-INTO isn't strictly DOM?

XML-INTO isn't DOM at all. It is basically built on top of XML-SAX.

Well, that's the whole source of the misunderstanding, then. In one of
my earlier messages, I used the phrase

"DOM-style parsing (as exemplified by XML-INTO) needs to work with the
whole file basically as a unit"

Nobody batted an eye at that.

If you look at past discussions on these lists surrounding XML-INTO
vs. XML-SAX, everyone has basically said XML-INTO processes the whole
document at once; and XML-SAX is, obviously, SAX-based. I could have
sworn some people have even said explicitly that XML-INTO was DOM.

I don't use RPG to process XML, so I had no idea that there was this
"XML-INTO with handlers" thing. And outside of RPG, discussions about
XML parsing are always "DOM vs. SAX", so it's only natural to think
that whatever's "not obviously SAX" must surely be DOM. You're saying
that this isn't the case for XML-INTO vs. XML-SAX. OK, great.

I think one reason I often confuse you may be that you think I know
RPG better than I actually do. Which is kind of flattering, actually.
But I'm more like the foreigner who learned enough of the local
language to get around, but not really have deep conversations with.

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

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com


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.