Commit 805183d5 authored by Katia Saurfelt's avatar Katia Saurfelt
Browse files

feat: schema validation, add choice + zeroOrMore for DataObjectGroup (closes #35)

--HG--
branch : seda21
parent adfb3d67f7f2
Pipeline #89861 failed with stages
in 1 minute and 18 seconds
......@@ -765,9 +765,12 @@ class SEDA22RelaxNGExport(SEDA2RelaxNGExport):
if nodes or opt_nodes:
# insert after definition of dop's id attribute
for node in chain(nodes, opt_nodes):
zeroormore = self.element("rng:zeroOrMore")
choice = self.element("rng:choice", zeroormore)
dop[0].addnext(zeroormore)
# insert DataObjectGroup with id from [Physical|Binary]DataObject if found
group = self.element(
"rng:element", attributes={"name": "DataObjectGroup"}
"rng:element", choice, attributes={"name": "DataObjectGroup"}
)
node_id = node.xpath(
'rng:attribute[@name="id"]/@xml:id[1]', namespaces=namespaces
......@@ -778,7 +781,6 @@ class SEDA22RelaxNGExport(SEDA2RelaxNGExport):
)
attr_element.attrib[self.qname("xml:id")] = f"g{node_id[0]}"
self.element("rng:data", attr_element, {"type": "ID"})
dop[0].addnext(group)
group.append(node)
def postprocess_dataobjectsreference(self, root, namespaces):
......
......@@ -537,7 +537,8 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
len(
self.xpath(
dop,
'./rng:element[@name="DataObjectGroup"]/rng:element[@name="BinaryDataObject"]', # noqa
'./rng:zeroOrMore/rng:choice/rng:element[@name="DataObjectGroup"]/'
'rng:element[@name="BinaryDataObject"]',
)
),
2,
......@@ -546,7 +547,8 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
len(
self.xpath(
dop,
'./rng:element[@name="DataObjectGroup"]/rng:element[@name="PhysicalDataObject"]', # noqa
'./rng:zeroOrMore/rng:choice/rng:element[@name="DataObjectGroup"]'
'/rng:element[@name="PhysicalDataObject"]',
)
),
1,
......@@ -560,7 +562,8 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
len(
self.xpath(
dop,
'./rng:element[@name="DataObjectGroup"]/rng:element[@name="BinaryDataObject"]', # noqa
'./rng:zeroOrMore/rng:choice/rng:element[@name="DataObjectGroup"]'
'/rng:element[@name="BinaryDataObject"]',
)
),
2,
......@@ -569,7 +572,8 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
len(
self.xpath(
dop,
'./rng:element[@name="DataObjectGroup"]/rng:element[@name="PhysicalDataObject"]', # noqa
'./rng:zeroOrMore/rng:choice/rng:element[@name="DataObjectGroup"]'
'/rng:element[@name="PhysicalDataObject"]',
)
),
1,
......
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