Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

QIF document addition removes XML nodes #270

Closed
MatthewPowley opened this issue May 24, 2023 · 3 comments · Fixed by #271
Closed

QIF document addition removes XML nodes #270

MatthewPowley opened this issue May 24, 2023 · 3 comments · Fixed by #271

Comments

@MatthewPowley
Copy link
Collaborator

Need help pointing me to how I can fix this issue.
When adding a XML QIF Results document, nodes with the same name in the document are not stored.

In QIF a file multiple child nodes exist with the same name. In the excerpt below, there are multiple 'CircleFeatureDefinition' nodes, each with different child nodes and attributes.

<Features>
  <FeatureDefinitions n="2">
    <CircleFeatureDefinition id="4">
      <Attributes n="4">
        <AttributeQPId name="AP242:PersistentFeature:UUID" value="be620693-2cd7-49b8-998d-e098a46a163a" />
        <AttributeI1 name="Renishaw:DataCollector:FeatureId" value="1" />
        <AttributeI1 name="Renishaw:DataCollector:FeatureType" value="103" />
        <AttributeStr name="Renishaw:DataCollector:FeatureTypeDescription" value="InspectionPlus Bore (3Pt)" />
      </Attributes>
      <InternalExternal>INTERNAL</InternalExternal>
      <Diameter>5.000000</Diameter>
    </CircleFeatureDefinition>
    <CircleFeatureDefinition id="20">
      <Attributes n="4">
        <AttributeQPId name="AP242:PersistentFeature:UUID" value="6f6e0701-e6ad-4c46-afcb-f77084e1d42d" />
        <AttributeI1 name="Renishaw:DataCollector:FeatureId" value="2" />
        <AttributeI1 name="Renishaw:DataCollector:FeatureType" value="103" />
        <AttributeStr name="Renishaw:DataCollector:FeatureTypeDescription" value="InspectionPlus Bore (3Pt)" />
      </Attributes>
      <InternalExternal>INTERNAL</InternalExternal>
      <Diameter>5.000000</Diameter>
     </CircleFeatureDefinition>
  </FeatureDefinitions>
</Features>

When the data is sent to the agent through a multi-line SHDR all data is present. When processing however each of the nodes is turned into a property of the QifDocumentWrapper entity. This property collection is a map and so it can only have 1 child property value with the same name.

So any XML that has the form:

<Parent>
  <Child name="Child1"/>
  <Child name="Child2"/>
  <Child name="Child3"/>
</Parent>

Will end up with only one 'Child' property and will have an attribute 'name' with the value 'Child1'.

How best to modify the data parsing pipeline to retain the structure?

@wsobel
Copy link
Member

wsobel commented May 24, 2023 via email

@wsobel
Copy link
Member

wsobel commented May 24, 2023

Hi Matt,

Do you have the complete QIF document? I'm trying to build a unit test around this and need to have a sample.

I think the parser treats the content like a property set instead of a list. I use a generic entity mapper to create the QIF document; I don't have a complete internal model for QIF–maybe sometime in the future–to do validation. Therefore it is probably makeign some poor assumptions.

There are some other areas this pattern is used, like extended schema, so I need to verify I can differentiate behavior.

A complete example would be very helpful.

Thanks,
W

@MatthewPowley
Copy link
Collaborator Author

@wsobel - I will catch up with you in person next week.
I understand why it has been implemented this way, to separate the model of the data from its representation (XML, JSON, YAML...). Building a model for QIF might be quite complex but can be done and maybe should be done outside of MTConnect, which the agent can then utilise.
We will discuss a plan of what to do next and then I will add a few demonstration documents and build some tests.

@wsobel wsobel linked a pull request May 28, 2023 that will close this issue
wsobel added a commit that referenced this issue Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants