[XML Records] Error trying to Generate XML: Sequence contains no matching element

Forge Component
(42)
Published on 25 Nov (3 weeks ago) by Afonso Carvalho
42 votes
Published on 25 Nov (3 weeks ago) by Afonso Carvalho

Hi All

We are using XML Records to generate a XML file (SEPA). We are trying to generate a file that contains lists inside lists and we have records that appear in multiple structures.

We are getting this error: Sequence contains no matching element

  at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)

  at OutSystems.NssXmlRecords.TypeMapper.GetSimpleRecordInfo(IRecord rec, String& recName, ISimpleRecord& structValue, FieldInfo& recordTypeSubfield)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.CssXmlRecords.MssRecordToXml(Object ssRecord, RLRecordXmlConfigRecordList ssXmlConfig, RCDefaultXmlConfigRecord ssDefaultConfig, String& ssXml)

[2:39 PM]

Has anyone got something similar?

Hi Pedro,

I could replicate the error you mention while using the latest version of the XmlRecords extension (1.6.1). The problem has to do with the fact that the extension assumes that the Record type is only being used to wrap structure/entity types. Apparently, you are passing a Record containing only attributes with simple types (e.g. Text, Integer). Instead of using the Record type, define a structure instead and add to it all the attributes that you have in the record. Then set the type of the attribute to this new structure instead of the Record type. This should solve the problem.


Note:

In previous versions of this extension, every structure/entity type had to be wrapped within a Record in order to be able to transform it into xml. This is no longer the case, though. You can safely pass structures/entities to have the corresponding xml generated. The extension only supports the Record wrapper construction for backwards compatibility.


greetings,

pedro

Pedro Saraiva wrote:

Hi All

We are using XML Records to generate a XML file (SEPA). We are trying to generate a file that contains lists inside lists and we have records that appear in multiple structures.

We are getting this error: Sequence contains no matching element

  at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)

  at OutSystems.NssXmlRecords.TypeMapper.GetSimpleRecordInfo(IRecord rec, String& recName, ISimpleRecord& structValue, FieldInfo& recordTypeSubfield)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.RecordXmlSerializer.Serialize(IRecord rec, String parentHierarchy, Boolean excludeRecordDefinition, StringBuilder parentSB)

  at OutSystems.NssXmlRecords.CssXmlRecords.MssRecordToXml(Object ssRecord, RLRecordXmlConfigRecordList ssXmlConfig, RCDefaultXmlConfigRecord ssDefaultConfig, String& ssXml)

[2:39 PM]

Has anyone got something similar?

Hi,

I am facing the same issue . Could you please tell me if have solved the problem? Thank  you in advance.


regards,

Amreen


Can you post the XML you're trying to convert? And also which method/Action you're using?

Thank you.

Amreen Shaikh wrote:

Pedro Saraiva wrote:

Hi All

We are using XML Records to generate a XML file (SEPA). We are trying to generate a file that contains lists inside lists and we have records that appear in multiple structures.

<SNIP>

[2:39 PM]

Has anyone got something similar?

Hi,

I am facing the same issue . Could you please tell me if have solved the problem? Thank  you in advance.


regards,

Amreen


Ill try to clarify what Pedro is telling you. You need to build the XML structure. This means you need to create a new structure for each unique node within the XML. Than build it up from the outer-most node. 

I've got some pictures which will make it easier to follow. Consider the following XML:

This can be mapped using the following structure. Read the input structure requestedCompany from the level of creditAdviceData. Disregard the higher-level structures. Im reusing a picture. 

The XML is defined in structures as follows:

- creditAdviceData has a structure within it of type creditAdvice

- creditAdvice has a simple type of amount and a structure of historyAdvisedCreditLimit within it. 

- historyAdvisedCreditLimit has a simple type of type and a structure List of type value within it. 

- Finally value has three simple types within it of type year, month and value


Hopefully now you can solve your problem!


Note: Make sure you have a recent version of XMLRecords if you want to access data points like year and month in the node value