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



Thanks to all I got it working.


On Fri, Mar 10, 2023 at 4:04 PM Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:

If you want to fully understand this check out my article on the subject (
https://authory.com/JonParisAndSusanGantner/XML-INTO-Revisited <
https://authory.com/JonParisAndSusanGantner/XML-INTO-Revisited>) the
relevant portion that you need is titled: Problem 1: Data and Attributes at
the Same Level.

I suspect that since, unlike JSON, XML doesn't have a notion of null and
so the designers of this rather strange schema have elected to use an
attribute to indicate a null value (as opposed to a zero value). Most XML I
have seen in the past achieves this by simply omitting the element - why
your designers went this odd route who knows?

I'm guessing that they never send data like this:

<element nil="false"> 1234 </element>

but rather simply send:

<element> 1234 </element>

Attributes are treated hierarchically the same as children of the element
which means the parent has to be a DS - but that causes issues when there
is data as well as attributes as the article explains. Now in your case,
it looks as if you probably have _either_ an attribute _or_ data - but
XML-INTO can't know that. So you have to build the DS as if both data and
attributes can be present.

As with any "missing" element, the default values of the DS fields will
not be changed. So ...

<element> 1234 </element> would result in element.data containing the
value 1234 and element.nil containing its initial value.

<element nil="true"/> or <element nil="true"></element> (which are
basically the same thing) element.data will have its initial value and
element.nil will contain the value true.

Hope this helps


Jon P

On Mar 10, 2023, at 3:35 PM, K Crawford <kscx3ksc@xxxxxxxxx> wrote:

Jon.
In the example what would come back in 'AverageDailyBalance' if it were
null?
I will give this a try.

On Fri, Mar 10, 2023 at 8:48 AM Jon Paris <jon.paris@xxxxxxxxxxxxxx>
wrote:

You have two problems here.

As Vern has pointed out there are namespaces being used which you are
not
handling. In this case adding the option ns=remove will handle that.

But the specific problem you described is caused by an incorrect data
definition. Elements such as AverageDailyBalance that contain an
attribute
such as nil="true" require that they be defined as a DS as "nil" is a
child
of AverageDailyBalance. But you also seem to expect the element to
sometimes contain a value so you also need to add the datasubf option. I
have assumed datasubf=data in the minimum definition shown here:
Changes
in bold spacing probably not accurate.

dcl-ds Balance qualified;
Type varchar(50);
OpeningBalance zoned(24:4) inz(0);
ClosingBalance zoned(24:4) inz(0);
dcl-ds AverageDailyBalance;
nil char(4);
data zoned(24:4) inz(0);
end-ds;
dcl-ds AnnulPercentageYield;
nil char(4);
data zoned(24:4) inz(0);
end-ds;
BalanceAsOf varchar(50);
End-Ds Balance;

A word of advice - don't use allowextra=yes and allowmissing=yes unless
you actually need them. Particularly when testing they will tend to mask
the real problems as I suspect they did here.


Jon P.

P.S. I'm going to ignore Vern's outrageous remarks about SQL <grin>

On Mar 9, 2023, at 5:11 PM, K Crawford <kscx3ksc@xxxxxxxxx> wrote:

I have a program that is using XML-INTO The XML has a null value. How
do I
handle that?
I searched the archive and everything there is over 10 years old and...

This is the error I get:
The XML document does not match the RPG variable; reason code 8.
Message ID . . . . . . : RNX0353 Severity . . . . . . . : 50

Message type . . . . . : Escape

Date sent . . . . . . : 03/09/23 Time sent . . . . . . :
15:07:01
Message . . . . : The XML document does not match the RPG variable;
reason code 8.

example code:
dcl-s XmlDocument varchar(1000);
dcl-c xmlinto_options
const('case=any doc=file countprefix=ArrCnt_ +
allowmissing=yes allowextra=yes');
dcl-ds Balance;
Type varchar(50);
OpeningBalance zoned(24:4) inz(0);
ClosingBalance zoned(24:4) inz(0);
AverageDailyBalance zoned(24:4) inz(0);
AnnulPercentageYield zoned(24:4) inz(0);
BalanceAsOf varchar(50);
End-Ds Balance;

This is the line of code that the error is issued on.
xml-into GetFundedAccountStatementDetailsResponse %xml(Xmldocument:
xmlinto_options);

This is the XML:
<Balance>
<Type>Total Balance</Type>
<OpeningBalance>2904.5100</OpeningBalance>
<ClosingBalance>3854.9800</ClosingBalance>
<AverageDailyBalance i:nil="true" />
<AnnualPercentageYield i:nil="true" />
<BalanceAsOf>2023-01-31T00:00:00</BalanceAsOf>
</Balance>

Thanks for your help.
--
KCrawford
--
This is the RPG programming on IBM i (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@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.


--
This is the RPG programming on IBM i (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@xxxxxxxxxxxxxxxxxxxx for any subscription
related
questions.



--
KCrawford
--
This is the RPG programming on IBM i (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@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.


--
This is the RPG programming on IBM i (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@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.




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.