openepcis / openepcis-models

EPCIS 2.0 Java Models
https://openepcis.io
Apache License 2.0
0 stars 2 forks source link

GEN-91:detect the default namespaces during the json deserialization … #43

Closed Aravinda93 closed 5 months ago

Aravinda93 commented 5 months ago

Background:

When the EPCIS JSON document includes extensions or ILMD based on the default context, such as "cbvmda": "urn:epcglobal:cbv:mda:" or "gs1": "https://gs1.org/voc/", these context URLs are not included within the JSON document's @context. During the JSON-to-XML conversion, these contexts cannot be identified and incorporated as namespaces.

The absence of these namespaces leads to failures in document or event conversion from JSON to XML due to missing namespaces. Providing all namespaces directly to the marshaller results in their inclusion in all documents or events, regardless of whether they contain extensions/ilmd based on the default context.

To address this issue, a class is required that can determine the presence of default context-based extensions or ILMD. If such extensions are found, the default contexts should be added to the DefaultJsonSchemaNamespaceURIResolver, enabling the marshaller to incorporate these namespaces into the generated XML. This approach prevents the unnecessary addition of namespaces to the XML and prevents exceptions related to missing namespaces during JSON-to-XML conversion for documents containing default context-based extensions.

@sboeckelmann kindly request you to review the changes and approve the PR.