No announcement yet.

XML-INTO mapping an element with different attributes

  • Filter
  • Time
  • Show
Clear All
new posts

  • XML-INTO mapping an element with different attributes


    I have a problem trying to map an XML into a data structure using XML-INTO.

    There is an element in the message that can be a single value of can be an array containing multiple fields. I can create a data structure to EITHER retrieve the single value or a child-data structure to hold multiple fields. What I cannot do is a create a structure that will contain both.

    So before I create 2 data structures to hold the returned data (and run XML-INTO twice) can anyone define a data structure to work in a single pass?

    I am not good in working in abstract values to this is the part of the original XML that I am trying to map:
    <Description>number of VK loans</Description>
    <DisplayName> VK Loans</DisplayName>
    <FieldName>Number of VK Loans</FieldName>
    <Value i:type="b:int">0</Value>
    <Description>Amount and length of running loans</Description>
    <DisplayName>Running Loans</DisplayName>
    <FieldName>Running Agreements</FieldName>
    <GroupName>Running Loans</GroupName>
    <Value i:type="ArrayOfInterpretationRunningAgreement>

    and then multiple of the above fields ending with


    I can either define the <Value> as a sub-field of the InterpretationVariable data structure with a size attribute and the "0" will map. Or I can define <Value> as having a child data structure and that will map the array data into <InterpretationRunningAgreement>

    The problem is that both fields need to be defined as Value in the data structure:

    D InterpretationVariableDS DS Qualified
    D Value 10a


    D InterpretationVariableDS Qualified
    D Value LikeDS(ValuesDS)

    D ValueDS DS Qualified
    D InterpretationRunningAgreement LikeDS(InterpretationRunningAgreementDS) Dim(10)

    I do not want to move away from using XML-INTO as the XML contains a few thousand elements.

    Amy ideas?

    Thanks (and sorry for the spelling/spacing errors but I had to type all the values in as cut-and-paste was causing a 403 error)


  • #2
    It is difficult to be sure as there are errors in your XML but I _think_ that what you need is the datasubf option.

    I wrote about it here:

    You might also find the countprefix option useful for your nested arrays, or cases of optional elements. That is also described in the referenced article. You may be using that already but since you didn't post your XML-INTO code ...

    Assumedly you already have a namespace option in effect or you wouldn't be able to process the Value attributes at all.


    • #3
      Click image for larger version

Name:	tempsnip.jpg
Views:	33
Size:	197.0 KB
ID:	158173

      Hopefully the real XML makes more sense!

      The xml element <InterpretationVariable><Value> can either be a single value (0 or 111148 in this example) or can also contain a child data structure of <InterpretationVariable><Value><InterpretationRunn ingAgreement><Soort> etc.

      So, is there a way of defining a single data structure to hold both definitions or do I need a separate data structure for each definition?

      Datasubf would allow me to access the "i:type" data contained within the <Value> tag but would it solve this issue?




      • #4
        Click image for larger version

Name:	tempsnip.png
Views:	32
Size:	76.1 KB
ID:	158176
        Attached Files


        • #5
          Datasubf would allow me to access the "i:type" data contained within the <Value> tag but would it solve this issue?
          Did you read the piece? This is exactly what it is for.
          Dcl-ds value;
             type char(20);
             data_value whateverDefinition;
          That definition works for option { datasubf=data_} - if you don't like "data_" just change it to whatever makes sense to you.


          • #6
            I don't think it's possible to use datasubf (or any other option) to handle both a simple value like 11148 and a data structure like ArrayOfInterpretationRunningAgreement.


            • #7
              Hmmm - I was thinking of using nested DSs one for each possible array Barbara - but you are right that is not going to work.

              alex_rsa Can you supply the XML as text (attachment maybe) - the images you posted are pretty much useless in that I can't copy the text and "play" with the results. And I'm _not_ going to type it all in <grin> I _think_ I can see a way to d it by using multiple passes but ...
              Last edited by JonBoy; 4 days ago.


              • #8
                XML-SAX would handle it.