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



The DOC=file fixed the issue, ty.

as far as the countprefix logic, i need to wrap my brain around that. Im not sure how many elements repeat in the xml document. I will do some more reading/research on the syntax and incorporate it. If i have any issues, i will post the code and such.

I am saving the xml response/request files in the ifs for furture referense, thats why i am processing after the fact. I am using a java program to send and recieve the web service soap request. The program just saves the response to an xml file in the ifs. I may eventually do all the logic in the java program, but that will be when i have a better understanding of the xml process.

I will remove bother allowmissing and allowextra as you suggest. Im guessing if i mess up my DS definitions, it will bomb on me. It would be great if it gave more infomation rather then "tell programmer its broke". There might be some debug options i dont know about yet.

When im doing something for first time i always look for sample code. The code i had i felt was not worth posting since i know it wasnt even close. But i can post in the future.

I hope you work on the utility. If you need a testing environment i would be more then glad to assist.


On 3/4/2016 12:55 PM, Jon Paris wrote:
OK - to answer your question, you need to add the option doc=file. without this the compiler will assume that the variable xmlfile contains the XML. Since it actually contains the file name that is seen as invalid XML.

Do you always get 10 FamilyTreeMemberRole elements? You haven’t added the countprefix option that I suggested and without it any doc with less than 10 FamilyTreeMemberRole elements will cause an error.

I also can’t help but wonder though _why_ the XML is in a file since it appears to be a web service response you are parsing. Why bother writing it to the IFS ? Just process it when you receive it.

allowmissing=no is the default so you can remove that.

allowextra=yes I would remove unless you know you need it. With it in place if the supplier of the XML were to add elements that you do not cater for you would never know. If you leave it out you’ll get an error if the XML is ever incompatible with what you have coded for.

As to not including code - I do understand - but in most cases (not perhaps in the end in this one) it is a lot easier to get an idea of what someone does and does not understand by looking at their code.

I have been meaning to write that utility for a long time - perhaps you have just inspired me to do so!


On Mar 4, 2016, at 12:36 PM, tim <iseriesstuff@xxxxxxxxx> wrote:

Thanks Jon, i changed to allowmissing=no.

I didnt include my code since i wasnt even close. After seeing your code, that belief was confirmed. This is my first XML attemp, so mapping whats coming in to DS is a bit tricky. I wish there was a utiltiy our there that would create the DS templates based on the schema.

Another question if i may. I've been testing this process using a string variable. When i try to use a file located in the ifs, i get a "The XML parser detected error code 302".

Here is my code:
xmlfile = '/dandb/00000002_20160302_rsp_OrderProduct.xml';

options = 'path= soapenv:Envelope/+
soap-env:Body/+
fir:OrderProductResponse/+
OrderProductResponseDetail/+
product/+
Organization/+
OrganizationDetail +

case=any +
allowextra=yes +
allowmissing=no +
datasubf=data';

xml-into OrganizationDetail %XML(xmlfile:options);

On 3/4/2016 9:01 AM, Jon Paris wrote:
OK - it would have been nice to have seen that code.

Try to avoid using allowmissing=yes - it allows the entire XML doc to effectively be a completely different document and yet the XML-INTO will succeed. countprefix - as shown in my example - can be used on all V6 and later systems and allows for both missing repeating elements and also for optional elements and attributes. There really is hardly ever a case that needs “allowmissing" these days. See this article (and the others in the series) for more on its use: http://www.itjungle.com/fhg/fhg022316-story03.html




On Mar 3, 2016, at 10:34 PM, tim <iseriesstuff@xxxxxxxxx> wrote:

Thanks jon, i wil give it a try..i have code, but wasnt working.

D testds ds dim(10) qualified
d FamilyTreeMemberRoleText...
D 50
d DNBCodeValue...
D 50

options = 'path= OrganizationDetail/FamilyTreeMemberRole +
case=any allowextra=yes allowmissing=yes';

xml-into testds %XML(xml:options);


On 3/3/2016 10:26 PM, Jon Paris wrote:
Looks pretty straightforward. Something like this.


dcl-ds OrganizationDetail qualified;
FamilyTreeMemberRole LikeDS(FamilyTreeMemberRole_T) Dim(4); <— See note
StandaloneOrganizationIndicator char(nn);
ControlOwnershipDate char(nn);
ControlOwnershipTypeText LikeDS(ControlOwnershipTypeText_T);
end-ds;

dcl-ds FamilyTreeMemberRole_T qualified;
FamilyTreeMemberRoleText LikeDS FamilyTreeMemberRoleText_T;
end-ds;

dcl-ds FamilyTreeMemberRoleText_T;
DNBCodeValue char(nn);
data char(nn);
end-ds;

dcl-ds ControlOwnershipTypeText_T;
DNBCodeValue char(nn);
data char(nn); <— This is where "Privately owned” goes
end-ds;


XML-INTO will need options datsubf=data if using the names shown in my example.

If there are not always exactly 4 elements of FamilyTreeMemberRole then add count_ FamilyTreeMemberRole with a definition of (say) int(5) to the OrganizationDetail DS and add countprefix=count_ to the options.

Replace nn values with whatever lengths you need.


Note this has NOT been tested but it should be close enough for you to work it out.

P.S. It would have been nice to see you make an effort at coding the DS and _then_ come here for advice on any issues. But then I’ve spent way too much time stuck in traffic jams today so maybe I’m just being crabby.

On Mar 3, 2016, at 9:39 PM, tim <iseriesstuff@xxxxxxxxx> wrote:

Im working on xml files for the first time. I have the following xml snippet and need help with the syntax to read the info into our db.

Any help would be apprecited.

<OrganizationDetail>
<FamilyTreeMemberRole>
<FamilyTreeMemberRoleText DNBCodeValue="12775">Global Ultimate</FamilyTreeMemberRoleText>
</FamilyTreeMemberRole>
<FamilyTreeMemberRole>
<FamilyTreeMemberRoleText DNBCodeValue="12774">Domestic Ultimate</FamilyTreeMemberRoleText>
</FamilyTreeMemberRole>
<FamilyTreeMemberRole>
<FamilyTreeMemberRoleText DNBCodeValue="12773">Parent</FamilyTreeMemberRoleText>
</FamilyTreeMemberRole>
<FamilyTreeMemberRole>
<FamilyTreeMemberRoleText DNBCodeValue="12771">Headquarters</FamilyTreeMemberRoleText>
</FamilyTreeMemberRole>
<StandaloneOrganizationIndicator>false</StandaloneOrganizationIndicator>
<ControlOwnershipDate>1985</ControlOwnershipDate>
<ControlOwnershipTypeText DNBCodeValue="9058">Privately owned</ControlOwnershipTypeText>
</OrganizationDetail>
--
This is the RPG programming on the IBM i (AS/400 and 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.

Please contact support@xxxxxxxxxxxx for any subscription related questions.
Jon Paris

www.partner400.com
www.SystemiDeveloper.com

--
This is the RPG programming on the IBM i (AS/400 and 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.

Please contact support@xxxxxxxxxxxx for any subscription related questions.
Jon Paris

www.partner400.com
www.SystemiDeveloper.com

--
This is the RPG programming on the IBM i (AS/400 and 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.

Please contact support@xxxxxxxxxxxx for any subscription related questions.
Jon Paris

www.partner400.com
www.SystemiDeveloper.com



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.