I'm trying to validate an XML file with an XSD file, which doesn't work and I don't know why.
I figured out that we could do it on terminal with that example :
xmllint --noout --schema owl2-xml.xsd camera.owl
But it produces an error, which I particularly don't understand.
regexp error : failed to compile: expecting a branch after |
owl2-xml.xsd:30: element pattern: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}pattern': The value '([A-Z]|[a-z]|[À-Ö]|[Ø-ö]|[ø-˿]|[Ͱ-ͽ]|[Ϳ-]|[-]|[⁰-]|[Ⰰ-]|[、-]|[豈-﷏]|[ﷰ-�]|[
xmllint's regular-expression parser appears to be in error. As the error message makes clear, it's expecting that the branch separator
|
will be followed by some non-empty branch; the XSD spec, however, is clear that the empty string counts as a branch. If you want to validate your XML against this XSD schema, you will need to use a validator with a more reliable implementation of XSD.The validator on mowl-power validates a file as an owl 2 ontology, not as XML. DTD and xsd resolution is usually switched off for the OWLAPI parsers it uses, I believe.
You can use http://pythonhosted.org/Owlready/ to read and parse owl file before your code
There are a number of ways that you can serialize an OWL ontology. One of them is to serialize it as RDF. RDF can also be serialized in a number of different formats, one of which is RDF/XML. Many of the files that you see online with a
.owl
extension are the RDF/XML serialization of the RDF representation of an OWL ontology. There's going to be lots of variation in the possibilities there, because the same RDF graph can be serialized in many different ways in the RDF/XML serialization. See my answer to How to access OWL documents using XPath in Java? for more about that issue.Another way to serialize OWL ontologies is using the OWL/XML serialization, which is also XML based, but is not an RDF-based serialization. I'm assuming that you got the XSD file that you're using from 3.4 The XML Schema from OWL 2 Web Ontology Language XML Serialization (Second Edition). That serialization is a direct serialization of an OWL ontology in XML that doesn't take the OWL → RDF → RDF/XML route. That is, the XSD is for the OWL/XML format, not for RDF/XML.
So, I suspect that what's happening, regardless of whether or not your validator is handling the XSD correctly, is that you're attempting to validate an RDF/XML file using an XSD for OWL/XML. You didn't show any of the content of the OWL file that you're trying to validate though, so we can't be sure.
As a very simple example, here's a small OWL ontology in the OWL/XML serialization, generated though Protégé. This is what you get if you save the ontology using the OWL/XML format:
If you save the same ontology as RDF/XML, you get this:
They're both XML-based serializations of the ontology, but they're not the same, and only the OWL/XML representation would be validated by the XSD that you're using. Both could be validated using an OWL validator, though, because they're both legitimate serializations of an OWL ontology.