XMLPort - Import File Structure

I am currently trying to understand how XMLPorts work, and in particular the format of the XML file a dataport would expect. The following is a simplistic view of a file I am trying to import:

 - <case id="case_1">
  + <party id="party_1" type="1st Insured">
  + <party id="party_2" type="2nd Insured">
  + <factfind>
  + <adviser>
  + <party id="party_3" type="Solicitor" sequence_number="3">
  + <party id="party_4" type="Bank details" sequence_number="4">
  + <solution id="solution_1">

I have designed a dataport based on the above, and am assigning each element tagname to a variable i.e set SourceType to text, and assigning a unique DataSource for each. However when I try to run the port I get a message similar to "The element is expected by min occurs value: Once, Element received " However, from what I can gather from the limited documentation on this is that the XMLPort would expect liked named elements to be grouped together. i.e in the above example ‘factfind’ and ‘adviser’ need to be before or after the ‘party’ elements - but is this strictly the case, or is it possible to design a dataport in the way I am trying? Thank you in advance

It looks like your XML is not wellformed. Inside you have two instances of the party element, then you go to the factfind element, the adviser element and then back to the party element. Maybe you should consider: - + <parties + + + + + + + + + + + + + + + Then you can set your party element with minoccurs 1 and unlimited maxoccurs, as well as your solution element. Note that your id and type tags must be type attribute elements in the XMLPort designer. If the order of your elements it fixed, and you always have 2 parties, 1 factfind, 1 adviser, then 2 party elements, you have to give the party elements different names, like party1, party2, etc.

Thank you for your response Daniel, and I must admit this is the reply I expected really. I agree the layout you propose is more logical/sensible, but unfortunately I do not have much control over this. However, my preferred solution in this instance would be to rename the element tags for party_3 and party_4.

Regardless of what you call your elements, they must be defined in the XMLPort designer in the same order that they occur in the XML document. Maybe four ‘party’ elements will work after all I don’t know for sure. If you have optional elements though, you need to set the minoccurs property to Zero. That way you can leave out an element in your XML document without blowing up the XMLPort.

Yes I understand that the order must be the same. I have just been trying to get this to work with this particular order of elements. I have got a bit further with this and now get the error: The Element occurred more than once. which makes me think that it is not possible to have the four ‘party’ elements individually defined.

I think, you get the error message, when compiling… If you rename the DataSource of your second (and later) party element(s) into (and so on), but leave the Tag name as party, then it should work. Daniel

No, this was a runtime error. I had named the datasource in the way you described.

I didn’t think that would work. There are format restrictions to XML documents, you can find them here. In order for an XML parser to understand an XML document, it has to be wellformed, and I think having the same element name in the same level is not considered to be wellformed. So you can have this: nodevalue ±-nodevalue But not: nodevalue nodevalue