RDFLib / pyLODE

An OWL ontology documentation tool using Python and templating, based on LODE
BSD 3-Clause "New" or "Revised" License
169 stars 70 forks source link

complex restrictions are added to both table and context #188

Open keski opened 1 year ago

keski commented 1 year ago

In version 3.x, complex restrictions are added to the target table and the context (i.e.doc or body). To reproduce the issue, generate documentation with a restriction of the form:

rdfs:subClassOf [ owl:intersectionOf (
    [ a owl:Restriction ; owl:onProperty ssn:isPropertyOf ; owl:allValuesFrom ex:Class1 ]
    [ a owl:Restriction ; owl:onProperty ssn:isPropertyOf ; owl:allValuesFrom ex:Class2 ]  ) ] ;  

This will list the constraints both within the relevant table, as well as immediately following it. The reason is the list comprehension and string join in _setclass_html in utils.py:

return raw(joining_word.join([mem.render() for mem in class_set]))

Since the elements in class_set are rendered and added only as text to raw they are never actually added to any element and will be added to the context when it closes. From the dominate docs:

When the context is closed, any nodes that were not already added to something get added to the current context.