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



IMHO, what you're saying here doesn't make a lot of sense, Mark.

You seem to be saying that the XML tags are nested in exactly the same way as your data structure, but that the tag names can vary. This seems extremely unlikely, since nesting and repeating elements are extremely commonplace in XML, and they are almost always completely different from document to document. So the idea that it'd vary in tag names but have the same nesting/repeating structure as an array seems like a one-in-a-million chance to me.

Of course, the scenario you describe can already be done with XML-SAX, so IBM does provide support for what you're asking, even if it's not quite as easy as it would be with XML-INTO.

Finally, if you're really desperate, you could write a parser that would do it via DATA-INTO. So you've already got multiple options if you really wanted to do it sequentially.

-SK


On 3/25/18 2:25 PM, mlazarus wrote:
Jon,

 Sometimes we get data from external sources andwe have no control over the tag names.  They might be named terribly.  Or maybe in a foreign language that would make our programs more difficult to understand. Having an option to map it sequentially would be helpful, IMHO.

 For Eval-Corr I think it would be extremely helpful.  There are cases when I might be using an existing external DS that doesn't have the same field names as the target DS or even a /COPY that might be used throughout the system.

 -mark

On 3/25/2018 11:31 AM, Jon Paris wrote:
I cannot see how that would be terribly useful Mark - optional elements and attributes would pose an interesting problem - and how would you ever know if you'd got it right?

I wish someone could explain to me why the current method of name/structure mapping is apparently so problematic?  It seems to me the most intuitive and easy to understand - why make it harder?


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Mar 25, 2018, at 12:13 AM, mlazarus<mlazarus@xxxxxxxxxxxx>  wrote:

Jon,

How about by relative position?  I would like this as an option for the Eval-Corr keyword, too.

-mark

On 3/24/2018 12:46 PM, Jon Paris wrote:
Not wishing to be rude to anyone - but I have never understood why people have so many problems understanding this.  If there wasn't a requirement for the names/structure to match how on earth could it possibly work without some additional parameter providing a "this element goes in this field" mapping?


Jon Paris

www.partner400.com
www.SystemiDeveloper.com


On Mar 24, 2018, at 8:26 AM, Vernon Hamberg<vhamberg@xxxxxxxxxxxxxxx>   wrote:

I admit that sometimes IBM's documentation has to be read a few times to get what it means - saying that, here is something pretty far down the opening page for XML-INTO:


  * The XML data for an RPG data structure is expected to have an XML
    element with the same name as the data structure and child
    elements and/or attributes with the same names as the RPG subfields.


The key phrase, "same name", is the thing - and at first it doesn't seem to have the strength of the requirement we have here - but it does.

Anyhow, I have been a "victim" of this at the beginning of using this op-code, so you are not alone.

Regards
Vern

On 3/23/2018 10:51 AM, SCOURTNEY@xxxxxxxxxxx wrote:

Thanks a million Craig and Barbara ...

I read a load of documentation but nothing stated that I needed to use the original element tags  ..

Just tried it out and eureka ...

Thanks ...



-----Ursprüngliche Nachricht-----
Von: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im Auftrag von Craig Richards
Gesendet: Friday, 23 March 2018 16:48
An: RPG programming on the IBM i (AS/400 and iSeries)
Betreff: Re: RPGLE XML-INTO

Well ok, since I did most of it already - here is how you could do it in one xml-into:

    Dcl-S XMLDoc VarChar( 512 );

    Dcl-DS docID Qualified Template;
       ProprietaryDocumentIdentifier  Char( 26 );
    End-Ds;

    Dcl-DS genDate  Qualified Template;
       datetimestamp Char( 26 );
    End-Ds;

    Dcl-DS ASN Qualified;
       thisDocumentGenerationDateTime    LikeDS( genDate );
       thisDocumentIdentifier            LikeDS( docID );
    End-Ds;

    XMLDoc = '<ASN>'
           + '<thisDocumentGenerationDateTime>'
           + '<DateTimeStamp>19.03.2018 08:50:55</DateTimeStamp>'
           + '</thisDocumentGenerationDateTime>'
           + '<thisDocumentIdentifier>'
           + '<ProprietaryDocumentIdentifier>87323619.03.2018
08:50:55</ProprietaryDocumentIdentifier>'
           + '</thisDocumentIdentifier>'
           + '</ASN>';

    Xml-Into ASN
             %Xml( XMLDoc : 'path=ASN case=any allowmissing=yes' );

regards,

Craig

On 23 March 2018 at 15:32, Craig Richards<craig@xxxxxxxxxxxxxxxx>   wrote:


Sean,

You need to make sure at the level you path to that your xml elements
match the data structure subfield names.

here is an example using 2 separate xml-into with your data.

You could do it with one xml-into if you build a more nest
datastructure but you'd need to match more subfield names to the xml elements:

I'm not staying this is the best way to parse that document, I'm a bit
pressed for time but this example will show you something that works


    Dcl-S XMLDoc VarChar( 512 );

    Dcl-DS thisDocId_T;
       ProprietaryDocumentIdentifier  Char( 26 );
    End-Ds;

    Dcl-DS docGenDate_T;
       datetimestamp Char( 26 );
    End-Ds;

    Dcl-DS ASN Qualified;
       docGenDate    LikeDS( docGenDate_T );
       thisDocid     LikeDS( thisDocId_T );
    End-Ds;

    XMLDoc = '<ASN>'
           + '<thisDocumentGenerationDateTime>'
           + '<DateTimeStamp>19.03.2018 08:50:55</DateTimeStamp>'
           + '</thisDocumentGenerationDateTime>'
           + '<thisDocumentIdentifier>'
           + '<ProprietaryDocumentIdentifier>87323619.03.2018
08:50:55</
ProprietaryDocumentIdentifier>'
           + '</thisDocumentIdentifier>'
           + '</ASN>';

    Xml-Into ASN.docGenDate
             %Xml( XMLDoc : 'path=ASN/thisDocumentGenerationDateTime
case=any allowmissing=yes' );

    Xml-Into ASN.thisDocid
             %Xml( XMLDoc : 'path=ASN/thisDocumentIdentifier case=any
allowmissing=yes' );

regards,
Craig


On 23 March 2018 at 14:36,<SCOURTNEY@xxxxxxxxxxx>   wrote:


Hello all,



I am playing around with XML-INTO and for some reason cannot get this
example to work :

I keep getting : RNX0353 The XML document does not match the RPG
variable;



Example XML



<ASN>

           <thisDocumentGenerationDateTime>

                     <DateTimeStamp>19.03.2018
08:50:55</DateTimeStamp>

           </thisDocumentGenerationDateTime>

           <thisDocumentIdentifier>

<ProprietaryDocumentIdentifier>87323619.03.2018
08:50:55</ProprietaryDocumentIdentifier>

           </thisDocumentIdentifier>

</ASN>



RPG CODE





d ASN             ds                  qualified

d   docGenDate                   LikeDS(docGenDate_T)

d   thisDocid                         LikeDS(thisDocId_T )



*-----------------------------------------

* thisdocumentgenerationdatetime

  *-----------------------------------------

d docGenDate_T    ds

d datetimestamp                 26

  *-----------------------------------------

* thisdocumentidentifier

  *-----------------------------------------

d thisDocId_T     ds

  * proprietarydocumentidentifier

d docId                         26



XML-INTO ASN %XML(XML_Source: 'doc=file          +

                                case=any           +

                                allowmissing=yes');



Any help would be greatly appreciated.





Mit freundlichen Grüßen / Kind regards / Bien à vous,



Sean

--
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: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: http://amzn.to/2dEadiD


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.