Skip to content

XML Parser should support OWL/XML #814

@jpmccu

Description

@jpmccu

The detection should be when the OWL namespace is declared instead of the RDF namespace. In fact, the namespace should be what triggers RDF as well, since RDF can be embedded in other non RDF/XML documents as well.

On a practical note, it can be difficult to tell if someone has published RDF/XML vs OWL/XML from just the file extension. This should successfully parse, after this is implemented:

import rdflib

ont_url = 'https://raw.githubusercontent.com/ISA-tools/stato/dev/releases/1.2/stato.owl'
file_format = rdflib.util.guess_format(ont_url)
g = rdflib.Graph()
g.parse(location=ont_url,format=file_format)

Currently, we get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/apps/satoru/venv/local/lib/python2.7/site-packages/rdflib/graph.py", line 1032, in parse
    parser.parse(source, self, **args)
  File "/apps/satoru/venv/local/lib/python2.7/site-packages/rdflib/plugins/parsers/rdfxml.py", line 579, in parse
    self._parser.parse(source)
  File "/usr/lib/python2.7/xml/sax/expatreader.py", line 107, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/usr/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
    self.feed(buffer)
  File "/usr/lib/python2.7/xml/sax/expatreader.py", line 210, in feed
    self._parser.Parse(data, isFinal)
  File "/usr/lib/python2.7/xml/sax/expatreader.py", line 352, in end_element_ns
    self._cont_handler.endElementNS(pair, None)
  File "/apps/satoru/venv/local/lib/python2.7/site-packages/rdflib/plugins/parsers/rdfxml.py", line 161, in endElementNS
    self.current.end(name, qname)
  File "/apps/satoru/venv/local/lib/python2.7/site-packages/rdflib/plugins/parsers/rdfxml.py", line 333, in node_element_end
    self.error("Repeat node-elements inside property elements: %s"%"".join(name))
  File "/apps/satoru/venv/local/lib/python2.7/site-packages/rdflib/plugins/parsers/rdfxml.py", line 187, in error
    raise ParserError(info + message)
rdflib.exceptions.ParserError: http://purl.obolibrary.org/obo/stato.owl:17:117: Repeat node-elements inside property elements: http://www.w3.org/2002/07/owl#Literal

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions