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



If you are on IBM i 6.1, there's a PTF that might help you. It lets you specify a "countprefix" option that will give you the count of elements filled in for an array. If there are 0 elements provided by the caller, it'll be set to 0. Might be what you're looking for.

http://www-949.ibm.com/software/rational/cafe/docs/DOC-2975


Peter Connell wrote:
The XML-INTO handler some things for which I am most grateful which are
clearly documented at Boulder.
It loads the data structure I give it with the required number of
occurrences of an element (and children) capped at the number of
dimensions in the array I give it so that it fires only when that cap is
reached.

It does not fail if there are elements defined in my structure that are
missing in the xml document.
It does not fail if there are elements not defined in my structure that
present in the xml document.
It tells me how many elements it loaded into my array.

I tell my handler to use data I expect to find in each element in the
structure I have defined.

Because it does not tell me which elements were missing then my handler
cannot know this.
It is a reasonable assumption that these would simply be unpopulated
since I don't recall any documentation that indicates this is "bad"
data.

Because the DTD does not rigidly constrain users of the originating web
service that all elements must be supplied, even if unpopulated, then my
handler can only process elements based on their content. Because missing elements have gone "bad" then examining their content to
make I required decision is meaningless.

What I have not seen is any advice that the handler will fail to supply
correct data (or supply corrupt data) if supplied with an xml document
that has missing elements when the associated array has a dimension
greater than 1.

Since our DTD has existed for years, there can be no thought of now
restricting it.
If I had known about this "bad" data limitation I would have stuck to a
good old SAX technique.
Apart from that, what the compiler does with an XML-INTO operation is
simply divine.
So for the moment I shall tolerate the overhead of having the handler
fire for every iteration of a multi-occurrence element.

Peter




-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Saturday, 1 August 2009 5:22 a.m.
To: RPG programming on the IBM i / System i
Subject: Re: XML-INTO woes

Hi Peter,

XML-INTO will fill in only the elements that it found in the XML document. The remaining elements in your array are undefined (point to

adjacent memory) and you should not use them. Using them would be
"bad."

The number of elements that are passed to your %HANDLER is given to you in the 3rd parameter to your procedure.



Peter Connell wrote:
HELP.


I have a major deadline to meet and have now discovered that my
%XML-INTO handler routine is not working as expected.


The handler has been defined to process a DIM(40) array.

This appears to have been working until now when an investigation of a
decimal data error reveals that the data structure that the data
structure passed to the handler is corrupted when subsequent elements
in
the xml document are missing.

For example, a person-name element may contain 1st 2nd an last names
in
one occurrence but on the next may only contain the last name.

The missing name elements get populated with whatever might be found
in
some other element.

This is disastrous , since fields are then presented to the code in
the
handler containing rubbish.


Of course, I have compile the XML-INTO with the XmlOptions parameter
to
allow for missing elements as follows.

D XmlOptions C 'allowmissing=yes allowextra=yes
-
D doc=file
case=any
path='

This issue must surely have arisen before on this forum but I can't
find
it.

I have just been advised that a workaround is to set the array to
DIM(1)
so that the handler is call for each element of a multiple element xml
structure.


Regards,

Peter




Visit our website www.vedaadvantage.com. It has a new design with
improved navigation and search capabilities; and customer friendly
interface with more relevant insights and solutions to help you make
informed decisions.

########################################################################
#############
This correspondence is for the named person's use only. It may contain
confidential
or legally privileged information, or both. No confidentiality or
privilege is waived
or lost by any mistransmission. If you receive this correspondence in
error, please
immediately delete it from your system and notify the sender. You must
not disclose,
copy or rely on any part of this correspondence if you are not the
intended recipient.
Any views expressed in this message are those of the individual
sender, except where
the sender expressly, and with authority, states them to be the views
of Veda Advantage.
If you need assistance, please contact Veda Advantage on either :-
Australia 1300-921-621 or New Zealand +64 9 367 6200



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.