Strings not escaped when saving as rdf/xml

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Strings not escaped when saving as rdf/xml

cseanor
Hi, I'm using Owlready2 to make an ontology where the data for creating instances comes from a CSV of strings. Some of these strings have quotes in them, or curly brackets. This causes problems when saving to RDF/XML because the strings are not escaped. Here's a minimal example so you can see what I mean: import owlready2 as owl if __name__ == "__main__": onto = owl.get_ontology("example") with onto: class Name(owl.Thing): pass instance = Name('John "The Nickname" Doe') onto.save(file="example.owl", format="rdfxml") I can't embed the full example output because Nabble destroys it but the important part is that it produces a Name tag with rdf:about="#John "The Nickname" Doe" as an attribute, which isn't valid. I can get around this by escaping my own strings but ideally I think this would be done as part of the saving process. Thanks :)
Reply | Threaded
Open this post in threaded view
|

Re: Strings not escaped when saving as rdf/xml

cseanor
Aaaand the line breaks in the python are gone, too. It looks like you get them back if you use the "quote" feature though.
Reply | Threaded
Open this post in threaded view
|

Re: Strings not escaped when saving as rdf/xml

Jiba
Administrator
Hi,

The name of entity is part of the entity IRI, and many characters are forbidden in IRI, including " and breakline (however, ' is permitted).

If you want to store names with special characters, I recommend to use e.g. the label annotation, and not the name of the entity.

Jiba