openepcis / openepcis-document-converter

Convert GS1 EPCIS events from JSON-LD to XML format and vice versa.
https://openepcis.io
Apache License 2.0
2 stars 1 forks source link

TransformationEvent type unknown #22

Closed F-Node-Karlsruhe closed 2 months ago

F-Node-Karlsruhe commented 2 months ago

When trying to convert a Transformation Event the tool claims, that this type does not exist. Even after a lot of trial and error we could not find the root issue. Our minimal document appears perfectly fine.

Document:

<epcis:EPCISDocument
        xmlns:epcis="urn:epcglobal:epcis:xsd:1"
        xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance"](http://www.w3.org/2001/XMLSchema-instance%22)
                     creationDate="2005-07-11T11:30:47.0Z"
                     schemaVersion="1.2"
                     xmlns:eecc="[http://ns.eecc.info/epcis">](http://ns.eecc.info/epcis%22%3E)
    <EPCISBody>
        <EventList>
            <epcis:TransformationEvent>
    <eventTime>2021-04-08T16:00:00+02:00</eventTime>
    <recordTime>2022-04-22T15:20:26.515Z</recordTime>
    <eventTimeZoneOffset>+02:00</eventTimeZoneOffset>

</epcis:TransformationEvent>

        </EventList>
    </EPCISBody>
</epcis:EPCISDocument>

Error:

[{  "type": "required",  "line": "9",  "location": "40",  "message": "Invalid content was found starting with element '{\"urn:epcglobal:epcis:xsd:1\":TransformationEvent}'. One of '{ObjectEvent, AggregationEvent, QuantityEvent, TransactionEvent, extension}' is expected."}]
Aravinda93 commented 2 months ago

@F-Node-Karlsruhe

Thanks for reaching out to us with the issue.

Since you are using the XML 1.2 version and as per the XML 1.2 XSD the TransformationEvent has to be wrapped within the <extension>. Reference XSD: https://ref.gs1.org/standards/epcis/1.2.0/EPCglobal-epcis-1_2.xsd.

We have modified the XML that you provided as it contained some invalid characters (maybe as it was a sample XML):

<epcis:EPCISDocument xmlns:epcis="urn:epcglobal:epcis:xsd:1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDate="2005-07-11T11:30:47.0Z" schemaVersion="1.2" xmlns:eecc="http://ns.eecc.info/epcis">
  <EPCISBody>
    <EventList>
      <extension>
        <TransformationEvent>
        <eventTime>2021-04-08T16:00:00+02:00</eventTime>
        <recordTime>2022-04-22T15:20:26.515Z</recordTime>
        <eventTimeZoneOffset>+02:00</eventTimeZoneOffset>
      </TransformationEvent>
      </extension>
    </EventList>
  </EPCISBody>
</epcis:EPCISDocument>

Following is converted JSON 2.0:

{
  "@context": [
    "https://ref.gs1.org/standards/epcis/2.0.0/epcis-context.jsonld",
    {
      "eecc": "http://ns.eecc.info/epcis"
    }
  ],
  "type": "EPCISDocument",
  "schemaVersion": "2.0",
  "creationDate": "2005-07-11T11:30:47.0Z",
  "epcisBody": {
    "eventList": [
      {
        "type": "TransformationEvent",
        "eventTime": "2021-04-08T16:00:00+02:00",
        "recordTime": "2022-04-22T15:20:26.515Z",
        "eventTimeZoneOffset": "+02:00"
      }
    ]
  }
}

Let us know if it's still not working or facing any other issues associated with the tools.

Screenshot 2024-07-16 at 15 53 45
Aravinda93 commented 2 months ago

@F-Node-Karlsruhe

We hope the issue has been resolved now. Closing this issue as we haven't received any response. If you have any doubts or need further clarification feel free to open/create the issue.