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



Well, actually it will work. I'm controlling the XML, and it contains
search parameters, to build an SQL statement.
And rather than me checking for every possible parameter and it's value
passed, using multiple IF/ENDIFs,
I'll loop thru all the tags via XML-SAX, then the get the tag values,
using XML-INTO.

So, if my XML will look like this :

<params>
<parm_Filter_Item>ABC123</parm_Filter_Item>
<parm_Filter_Mfgr/>
<parm_Filter_Warehouse/>
<parm_Filter_Branch>CHA</parm_Filter_Branch>
<parm_Filter_Initials/>
</params>

Instead of having 5+ IF/ENDIF statements, for <parm/> tag, to build my
SQL,

- if (params.parm_Filter_Item <> *blanks);
- ~~~ append WHERE ~~~
- endif


I'll use the XML-SAX, and have one looping handler to build my WHERE
statement
- if (event == '*XML_START_ELEMENT');
- ~~~ append WHERE using XML-INTO to get the value~~~
- endif

It's working just fine. I was just hoping to avoid unnecassry looping.

Thanks
David




David L. Mosley, Jr.
Technical Solutions Architect
Dancik International, Ltd.
2000 CentreGreen Way, Suite 250
Cary, NC 27513

www.dancik.com



Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
12/23/2009 04:53 PM
Please respond to
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>


To
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
cc

Subject
Re: XML-SAX Event-Handler loop.






dmosley@xxxxxxxxxx wrote:

I don't really like the idea of looping thru the 'events' of the XML
string, to get values. It just seemed a bit....loose. Meaning, if I
wanted to loop thru all my <tags> and retrieve it's values, and do
something with them, then this loop process just appeared to be a bit
'old school'.

Okay, well that "old school" process is called 'SAX'. That's what SAX
is. Anywhere on any platform using any SAX API, you do that.

So, what I did instead was for every "*XML_START_ELEMENT" event, I
would take the <tag> name and execute an XML-INTO to get the tag's
value.

Uhhhhmmm.. that won't work, will it? What happens if you have the
same tag name more than once in your document?

Most XML documents that I work with have a structure similar to this (my
example is a little abstract... sorry about that)

<doc>
<transaction>
<struct>
<field1>value</field1>
<field2>value</field2>
</struct>
<field3>value</field3>
</transaction>
<transaction>
<struct>
<field1>value</field1>
<field2>value</field2>
</struct>
<field3>value</field3>
</transaction>
</doc>

If you get to the 'transaction' element and it fires the
*XML_START_ELEMENT event... then you call XML-SAX for doc/transaction,
right? For the first instance of the transaction element, that's no
problem. But when you get to the 2nd one, you'll get the value from the
first one, won't you?

If you want to avoid XML-SAX, why not use XML-INTO for the whole document?

If you can't use XML-INTO because there's an element or attribute name
you can't access with XML-INTO, then why not wrap the XML-SAX logic in a
service program? Yes, you may have to write code that you find
unpleasant, but you'd only have to do it once and could then reuse that
data over and over again -- you'll never have to do it again.

As far as I can tell, the way you're doing it now is not valid.

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.