Skip to content

Commit 94cd33e

Browse files
Fix EPC content types and schema versions
Adjust how schemaVersion and EPC content types are generated and fix minor issues across codebase. - AbstractObject: add documentation for EML schemaVersion handling and compute gsoapProxy2_3->schemaVersion from the XML namespace (last two chars) instead of using getXmlNamespaceVersion(). - EpcDocument: introduce getEpcContentType(...) to produce EPC content-type strings in the form "application/x-<ns>+xml;version=X.Y;type=<tag>" and use it when adding package content types. - PropertySet: ensure null-check throw is properly braced to avoid control-flow ambiguity. - GitHub Actions workflow: correct comment typo referencing the fetpapi wheel. These changes ensure EPC content types follow the expected two-digit dot-delimited version format and clarify schema version behavior for different Energistics schema versions.
1 parent b0621a9 commit 94cd33e

5 files changed

Lines changed: 31 additions & 5 deletions

File tree

.github/workflows/github-actions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ jobs:
166166
# https://github.com/pypa/cibuildwheel/issues/1139
167167
run: touch python/setup.py
168168
- name: Build wheels
169-
# Cannot use a more recent version than v2.22.0 because of fetappi wheel which uses AVRO which cannot be built with GNU 14.
169+
# Cannot use a more recent version than v2.22.0 because of fetpapi wheel which uses AVRO which cannot be built with GNU 14.
170170
uses: pypa/cibuildwheel@v2.22.0
171171
env:
172172
CIBW_BUILD: cp38-manylinux_* cp39-manylinux_* cp310-manylinux_* cp311-manylinux_* cp312-manylinux_* cp313-manylinux_*

src/common/AbstractObject.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,21 @@ void AbstractObject::initMandatoryMetadata()
497497
cannotBePartial();
498498

499499
if (gsoapProxy2_0_1 != nullptr) {
500+
/* From EML2.0 Abstract.xsd, schemaVersion documentation :
501+
* The specific version of a schema from which this object is derived.
502+
* This string should be exactly equivalent to the version attribute of the root element of the associated XSD schema file
503+
*/
500504
gsoapProxy2_0_1->schemaVersion = getXmlNamespaceVersion();
501505
gsoapProxy2_0_1->Citation = gsoap_resqml2_0_1::soap_new_eml20__Citation(gsoapProxy2_0_1->soap);
502506
}
503507
else if (gsoapProxy2_3 != nullptr) {
504-
gsoapProxy2_3->schemaVersion = getXmlNamespaceVersion();
508+
/* From EML2.3 Abstract.xsd, schemaVersion documentation :
509+
* The version of the Energistics schema used for a data object. The schema version is the first 2 digits of an ML version. EXAMPLES:
510+
* - For WITSML v2.0 the schema version is 20
511+
* - For RESQML v2.0.1 the schema version is 20
512+
*/
513+
const std::string& xmlNs = getXmlNamespace();
514+
gsoapProxy2_3->schemaVersion = xmlNs.substr(xmlNs.size()-2);
505515
gsoapProxy2_3->Citation = gsoap_eml2_3::soap_new_eml23__Citation(gsoapProxy2_3->soap);
506516
}
507517

src/common/AbstractObject.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,9 @@ namespace COMMON_NS
471471
DLL_IMPORT_OR_EXPORT virtual std::string getXmlNamespaceVersion() const;
472472

473473
/**
474-
* Gets the content type of this instance according to EPC recommendation
474+
* Gets the content type of this instance according to Energistics Identifier Specification v4.0
475+
* https://docs.energistics.org/#EID/EID_TOPICS/EID-000-007-0-C-sv4000.html
476+
* Example here : https://docs.energistics.org/#EID/EID_TOPICS/EID-000-009-0-C-sv4000.html
475477
*
476478
* @returns The content type of this instance.
477479
*/

src/common/EpcDocument.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,19 @@ namespace {
235235
}
236236
}
237237

238+
namespace {
239+
/**
240+
* The version in the EPC content type is just two digits delimited by a dot : https://docs.energistics.org/#EPC/EPC_TOPICS/EPC-000-023-0-C-sv1000.html
241+
*/
242+
std::string getEpcContentType(const COMMON_NS::AbstractObject& dataobject) {
243+
const std::string& xmlNs = dataobject.getXmlNamespace();
244+
const size_t xmlNsSize = xmlNs.size();
245+
const std::string& xmlTag = dataobject.getXmlTag();
246+
return "application/x-" + xmlNs.substr(0, xmlNsSize - 2) + "+xml;version=" + xmlNs[xmlNsSize - 2] + '.' + xmlNs[xmlNsSize - 1] +
247+
";type=" + (xmlNs == "resqml20" || xmlNs == "eml20" ? "obj_" + xmlTag : xmlTag);
248+
}
249+
}
250+
238251
void EpcDocument::serializeFrom(DataObjectRepository& repo)
239252
{
240253
addFakePropertyToEmptyPropertySet(repo);
@@ -256,7 +269,7 @@ void EpcDocument::serializeFrom(DataObjectRepository& repo)
256269
}
257270

258271
// Content Type entry
259-
package->addContentType(epc::ContentType(false, dataobject->getContentType(), dataobject->getPartNameInEpcDocument()));
272+
package->addContentType(epc::ContentType(false, getEpcContentType(*dataobject), dataobject->getPartNameInEpcDocument()));
260273
}
261274
}
262275
}

src/resqml2_0_1/PropertySet.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ PropertySet* PropertySet::getChildren(uint64_t index) const
7272

7373
void PropertySet::pushBackProperty(RESQML2_NS::AbstractProperty * prop)
7474
{
75-
if (prop == nullptr)
75+
if (prop == nullptr) {
7676
throw invalid_argument("The property to push cannot be null.");
77+
}
7778

7879
pushBackXmlProperty(prop);
7980

0 commit comments

Comments
 (0)