Solved

ODX cdata XML missing attribute

  • 12 February 2021
  • 6 replies
  • 89 views

I'm reading XML files from a folder using cdata XML provider. This is working fine and using incremental loading also works. The issue I'm having is that there is an attribute defined in my rsd file that is not always present in the XML files. When ODX starts reading the folder and the first file it parses doesn't have this field it skips the field for all following files. Similarly if the first file does have the attribute all the rest is parsed ok. Is this a bug or is there a setting I'm not aware of? Or maybe a definition in rds that could help?

icon

Best answer by Thomas Lind 23 January 2023, 10:52

View original

6 replies

Userlevel 5
Badge +5

Hi Johann

It happens as you mention when it hits a null value on an field.
It is one of the things that CData is really bad at working with.

I am not sure how much you can actually do about it.

What sort of things does you use the RSD file to do?

Hi Thomas, thank you for the reply.

In the RSD file I'm defining which fields I want from the XML. All other fields are working fine except this one field that isn't always present. I was hoping there was a simple solution to this that I was missing. I guess I'll need to find another way of importing these XML files. Even if I could read the whole XML into a XML or varchar column, that would do. But I haven't seen a solution for that either.

Userlevel 5
Badge +5

Hi Johann

I just thought maybe the use of RSD files weren't necessary.

I also had an idea, which is quick to add.
The field you use, can you add the following to one of the attribute rows?
<attr name="status" xs:type="string" readonly="true" default="empty" other:xPath="/json/data/status"/>

 

I had not tried that, but no it didn't work. I tried with both scenarios, having a XML file first with no attribute and having the first file with the attribute. But it only works with the latter.
I noticed that you are referencing a node. Here is my definition for the attribute:
<attr name="savings" xs:type="string" readonly="false" default="empty" other:xPath="/ARCHIVE_DATA/FLIGHT_PLAN/FORMATTED_TEXT/FlightPlan/Tankering/CostTankering@savings" />

I was wandering if there is a way for me to pull all the data from the Tankering node, because that node is always there but not the CostTankering one.

I have the similar issue..Not using any rsd file but my API throws off an Parsing Data type issue because its missing that attribute on some particular records. I tried using Data Type overrides and also Transformations but looks like it throwing me off at the source itself. 

How to try for a default value?

Userlevel 5
Badge +5

Hi

Sorry for the late answer.

I would be sure to add all the necessary fields that are used across all XML files.

Then in the call command of the RSD file, I would add the following.
 

<!-- The GET method corresponds to SELECT. Here you can override the default processing of the SELECT statement. The results of processing are pushed to the schema's output. See SELECT Execution for more information. -->
<api:script method="GET">
<api:set attr="method" value="GET"/>
<api:call op="xmlproviderGet" in=”callin” out=”callout”>
<api:set attr="out.country" value="[callout.country | allownull()]"/>
<api:set attr="out.id" value="[callout.id | allownull()]"/>
<api:set attr="out.field1" value="[callout.field1 | allownull()]"/>
<api:set attr="out.field2" value="[callout.field2 | allownull()]"/>
<api:set attr="out.name" value="[callout.name | allownull()]"/>
<api:push item="out"/>
</api:call>
</api:script>

Be sure all fields are mentioned in the call procedure and that they have the allownull() function. The callout that becomes a out is a way to reset the order, or you could experience that it puts the values in the wrong field.

An alternative method is to use the Metadata Discovery URI

You create a XML file that contains all the fields and one value of the type you want it to become. Then you point at this file in that field.

Reply