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





Hello again, I am trying to understand the XML_CHARS functionality and still have a snag.

I have this code:


when event = *XML_CHARS;
eventval = event + 1;
if %subst(chars : eventval : stringLen) = 'DataArea';
pathvalue = pathvalue;
endif;

I look at chars at this point and it's value is this:




EVAL chars
CHARS =
....5...10...15...20...25...30...35...40...45...50...55...60
1 ' <DataArea> <storeNumber>7</storeNumber> <trans'
61 'Date>20081028</transDate> <localTransactionNumber>52221'
121 '433</localTransactionNumber> <centralTransactionNumber>'
181 '123457</centralTransactionNumber> <Status>I</Status> '
241 ' <AssociateID>2257752</AssociateID> <refundPolicy>D</'
301 'refundPolicy> <TotalCredit></TotalCredit> <Convers'
361 'ionCredit>44.50</ConversionCredit> <Customer> <C'
421 'ustomerID>1111333444</CustomerID> <FirstName>Mickey</'
481 'FirstName> <LastName>Mouse</LastName> </Customer'
541 '> <Item> <ItemStatus>R</ItemStatus> <SKU>'
601 '647182</SKU> <Quantity>1</Quantity> <CreditAmo'

The first '<' is actually at position 5, did not reproduce here exactly.

So when I get to my first hit on XML_CHARS, event has a value of 5, so I add one to get it to the beginning of my text I add one to it, so it should be on the 'D' of DataArea. My stringlen = 8, so I am figuring that I should get a hit on it equalling my If value of 'DataArea'. It does not.


Still don't have something correct with this.
What parameter of the procedure houses the actual value of the event?


Thanks

Sharon




From: sklosinski@xxxxxxxxxxx
To: rpg400-l@xxxxxxxxxxxx
Subject: RE: XML-SAX not quite right
Date: Wed, 12 Nov 2008 08:06:00 -0500


Hi Larry, yes I get this, I will take your advice as well as Jon's and give this another shot.

THANKS so much for your responses.

Sharon



From: larry_ducie@xxxxxxxxxxx
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: XML-SAX not quite right
Date: Tue, 11 Nov 2008 23:50:44 +0000


Hi Sharon,

This SAX parser works by reading through your xml document and firing a call to your handler procedure every time an event occurs.

You have code for some events, but you are missing a crucial one - *XML_CHARS.

Consider the following trivial example:

<?xml version="1.0" ?>
<root>
<SKU>PT0110</SKU>
</root>

you should get the following calls:

*XML_START_DOCUMENT
*XML_START_ELEMENT - value passed is 'root'
*XML_START_ELEMENT - value passed is 'SKU'
*XML_CHARS - value passed is 'PT0110'
*XML_END_ELEMENT - value passed is 'SKU'
*XML_ENDELEMENT - value passed is 'root'
*XML_END_DOCUMENT

You are not handling what happens when the *XML_CHARS event occurs.

Also, you will not know what element the *XML_CHARS relates to unless you hold a variable telling you what the last *XML_START_ELEMENT had as the value. I would suggest you define a static variable in your sub-proc and set it to the value of the element name during the *XML_START_ELEMENT event and clear it during the *XML_END_ELEMENT. This is not the best way to go for more complicated documents though.

If you are to do this in a robust manner you should have a static variable containing the full path to your current element and add elements to the path in *XML_START_ELEMENT and remove them in *XML_END_ELEMENT.

For the above list of events you would set your path to look like this:
*XML_START_DOCUMENT - path = '/'

*XML_START_ELEMENT - path = 'root'

*XML_START_ELEMENT - path = '/root/SKU'

*XML_CHARS - path is unchanged but you get the value of SKU here as you are in /root/SKU

*XML_END_ELEMENT - path = '/root'

*XML_END_ELEMENT - path = '/'

*XML_END_DOCUMENT path = ''

Thus you would store the value of the SKU when a *XML_CHARS event is fired and your path = '/root/SKU'.

Hope this makes sense.

Cheers

Larry Ducie



_________________________________________________________________
It's simple! Sell your car for just $40 at CarPoint.com.au
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT
--
This is the RPG programming on the AS400 / 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.


_________________________________________________________________
Color coding for safety: Windows Live Hotmail alerts you to suspicious email.
http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_safety_112008
--
This is the RPG programming on the AS400 / 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.


_________________________________________________________________
Windows Live Hotmail now works up to 70% faster.
http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_faster_112008

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.