-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data types are not being written on serialization #381
Comments
Hi, |
SBOL 2.3.0 section 13.1.1 is pretty convincing that data types should NOT be included. It says:
And then gives the following example, which does not have data type specified:
It sounds like the behavior we have now, which is not including the datatype, is the specified syntax, and including it may be a bug. Additionally, all examples of |
Here is a candidate fix in case we want it in the future: diff --git a/sbol2/SBOL2Serialize.py b/sbol2/SBOL2Serialize.py
index c012d7d..2300f3d 100644
--- a/sbol2/SBOL2Serialize.py
+++ b/sbol2/SBOL2Serialize.py
@@ -111,7 +111,11 @@ def serialize_sboll2(g):
QName(rdfNS, 'resource'): obj.toPython()
})
elif isinstance(obj, Literal):
- elem = etree.SubElement(element, prefixify(predicate, prefixes, True))
+ attrib = None
+ if obj.datatype:
+ attrib = {QName(rdfNS, 'datatype'): obj.datatype.toPython()}
+ elem = etree.SubElement(element, prefixify(predicate, prefixes, True),
+ attrib=attrib)
elem.text = obj
else:
raise Exception() |
I would not infer from the lack of datatype in the serialization that it is not allowed. This is indeed one of the problems with including serialization examples in the document, which we no longer do in SBOL3. I would interpret the lack of mention is not that is disallowed, but that it does not say if is or is not required. Namely, it is optional. I think though it is good to include as it is more precise. |
When dateTime types are written to RDF/XML the data type is not included. This probably happens on other types besides dateTime but I don't have specific examples.
We need to modify SBOL2Serialize.py to include the data type of Literals when it is present.
This is one of those issues that is going to pop up because SBOL 2 requires a special serialization and we cannot use the default provided by RDFLib. SBOL 3 fixes this issue.
The text was updated successfully, but these errors were encountered: