Commit 1e9de927 authored by Katia Saurfelt's avatar Katia Saurfelt
Browse files

feat: if wrap_dataobject is True in SEDAArchiveTransf, replace...

feat: if wrap_dataobject is True in SEDAArchiveTransf, replace DataObjectReferenceId with DataObjectGroupReferenceId

--HG--
branch : seda21
parent 694f94bda6b8
Pipeline #89860 failed with stages
in 1 minute and 20 seconds
...@@ -490,6 +490,7 @@ class SEDA2RelaxNGExport(RNGMixin, SEDA2ExportAdapter): ...@@ -490,6 +490,7 @@ class SEDA2RelaxNGExport(RNGMixin, SEDA2ExportAdapter):
self.element("rng:text", element) self.element("rng:text", element)
self.postprocess_dataobjects(root, namespaces) self.postprocess_dataobjects(root, namespaces)
self.postprocess_dataobjectsreference(root, namespaces)
return root return root
def postprocess_dataobjects(self, root, namespaces): def postprocess_dataobjects(self, root, namespaces):
...@@ -499,6 +500,12 @@ class SEDA2RelaxNGExport(RNGMixin, SEDA2ExportAdapter): ...@@ -499,6 +500,12 @@ class SEDA2RelaxNGExport(RNGMixin, SEDA2ExportAdapter):
""" """
raise NotImplementedError() raise NotImplementedError()
def postprocess_dataobjectsreference(self, root, namespaces):
"""transform DataObjectReferenceId into DataObjectGroupReferenceId
if wrap_dataobjects
"""
return
def init_transfer_element(self, xselement, root, entity): def init_transfer_element(self, xselement, root, entity):
transfer_element = self.element( transfer_element = self.element(
"rng:element", "rng:element",
...@@ -774,6 +781,22 @@ class SEDA22RelaxNGExport(SEDA2RelaxNGExport): ...@@ -774,6 +781,22 @@ class SEDA22RelaxNGExport(SEDA2RelaxNGExport):
dop[0].addnext(group) dop[0].addnext(group)
group.append(node) group.append(node)
def postprocess_dataobjectsreference(self, root, namespaces):
"""transform DataObjectReferenceId into DataObjectGroupReferenceId
if wrap_dataobjects
"""
# DataObjectReferenceId into DataObjectGroupReferenceId
reference_nodes = root.xpath(
"/rng:grammar/rng:start/rng:element/"
'/rng:element[@name="DataObjectReferenceId"]',
namespaces=namespaces,
)
for reference_node in reference_nodes:
reference_node.attrib["name"] = "DataObjectGroupReferenceId"
node_id = reference_node.xpath('@a:defaultValue[1]', namespaces=namespaces)
# change defaultValue from BinaryDataObject xml:id to DataObjectGroup xml:id
reference_node.attrib[f"{{{namespaces['a']}}}defaultValue"] = f"g{node_id[0]}"
class SEDA21RelaxNGExport(SEDA2RelaxNGExport): class SEDA21RelaxNGExport(SEDA2RelaxNGExport):
__select__ = SEDA2RelaxNGExport.__select__ & ~wrap_dataobjects() __select__ = SEDA2RelaxNGExport.__select__ & ~wrap_dataobjects()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment