Comments (8)
There are a lot of warnings.
But it parses for me using riot
for both Jena 4.10.0 and Jena 5.1.0 - different RDF though.
RDF/XML documents don't have to have a rdf:RDF.
Would it be possible to have more concise examples of problems? It should only need a short example.
from jena.
What about this ?
String data = """
<?xml version="1.0"?>
<Ontology xmlns="http://www.w3.org/2002/07/owl#"
xml:base="http://www.w3.org/2002/07/owl#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
<Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
<Prefix name="xml" IRI="http://www.w3.org/XML/1998/namespace"/>
<Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
<Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
<Declaration>
<Class IRI="http://x#X"/>
</Declaration>
</Ontology>
""";
ModelFactory.createDefaultModel()
.read(new StringReader(data), null, "rdf/xml")
.setNsPrefixes(PrefixMapping.Standard).write(System.out, "ttl");
output
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
[ rdf:type owl:Ontology;
owl:Declaration [ rdf:type owl:Class ];
owl:Prefix ""
] .
To create such a document, OWLAPI or owlcs/ONTAPI can be used:
OWLOntologyManager m = OntManagers.createOWLAPIImplManager();
OWLOntology ont = m.createOntology();
ont.add(m.getOWLDataFactory().getOWLDeclarationAxiom(m.getOWLDataFactory().getOWLClass(IRI.create("http://x#X"))));
ont.saveOntology(new OWLXMLDocumentFormat(), System.out);
from jena.
I can't make Jena4 cause an error parsing; it does throw an exception when writing the model due to a relative IRI for a property.
Jena4 parsing issues warnings, as does Jena5.
There is a difference output between Jena4 and Jena5.
<?xml version="1.0"?>
<Ontology xmlns:p="http://example/ns#">
<Prefix p:name="rdf"/>
</Ontology>
with p:name
- no warnings. If the XML attribute is name=
(no namespace) there is a warning.
In Jena4, ARP issues a warning and outputs a relative URI property. It also generate an relative URI for Ontology
.
In Jena5, RRX issues a warning and skips the triple. It resolves the Ontology
against the base (and there is always a base which may be external).
This is by design. In writing RRX, I checked all the cases ARP supports. It was decided by the RDF 1.0 WG that bare attributes were not legal - they had been in the earlier design phases but that never made it to a spec. So in RRX it a warning and skipping, it is not a hard error due to legacy with ARP. Relative URIs will get into trouble later!
I'd be happy for that to become a error, not warning.
The fact that the doc parses as RDF/XML at all is because the root qname does not have to be rdf:RDF
, for a single top-level element, that can be omitted. This is the case Jena4 and Jena5, in ARP and RRX.
ARP (0 - the original; 1 - more integrated into RIOT error handling) is available in Jena5, at the moment, as lang name "arp0", "arp1" or as a file extension, and deprecated constant RRX.RDFXML_ARP0
Expect ARP0 to go away soon.
ARP1 was the RDF/XML parser from started in 4.7.0 to 4.10.0,
from jena.
As the distingushing RDF/XML from OWL/XML, it hard/impossible in the most general case. It would be better to read the input, snoop for the top level element and decide then reparse (all after checking MIME type and file extension if available).
File extension owl
was never registered and in the wild, you can find owl
for RDF/XML.
from jena.
I can't make Jena4 cause an error parsing; it does throw an exception when writing the model due to a relative IRI for a property.
It seems need to use the original ontology document https://github.com/owlcs/ont-api/blob/4.x.x/src/test/resources/owlapi/owlxml_anonloop.owx
from jena.
What's the error message, and is there a small extract that picks up the feature in error?
from jena.
<?xml version="1.0"?>
<Ontology xmlns="http://www.w3.org/2002/07/owl#"
xml:base="http://www.derivo.de/ontologies/examples/anonymous-individuals"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
ontologyIRI="http://www.derivo.de/ontologies/examples/anonymous-individuals">
<Prefix name="" IRI="http://www.derivo.de/ontologies/examples/anonymous-individuals#"/>
<Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
<Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
<Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
<Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
<ClassAssertion>
<Class IRI="#C"/>
<AnonymousIndividual nodeID="a"/>
</ClassAssertion>
</Ontology>
Exception in thread "main" org.apache.jena.riot.RiotException: [line: 16, col: 42] {E201} Multiple children of property element
at org.apache.jena.riot.system.ErrorHandlerFactory$ErrorHandlerStd.error(ErrorHandlerFactory.java:160)
at org.apache.jena.riot.lang.ReaderRIOTRDFXML$ErrorHandlerBridge.error(ReaderRIOTRDFXML.java:292)
at org.apache.jena.rdfxml.xmlinput.impl.ARPSaxErrorHandler.error(ARPSaxErrorHandler.java:37)
at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler.warning(XMLHandler.java:206)
at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler.warning(XMLHandler.java:183)
at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler.warning(XMLHandler.java:178)
at org.apache.jena.rdfxml.xmlinput.impl.ParserSupport.warning(ParserSupport.java:147)
at org.apache.jena.rdfxml.xmlinput.states.Frame.warning(Frame.java:57)
at org.apache.jena.rdfxml.xmlinput.states.WantLiteralValueOrDescription.startElement(WantLiteralValueOrDescription.java:38)
at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler.startElement(XMLHandler.java:121)
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:510)
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:183)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:351)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2710)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:534)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1216)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635)
at org.apache.jena.rdfxml.xmlinput.impl.RDFXMLParser.parse(RDFXMLParser.java:100)
at org.apache.jena.rdfxml.xmlinput.impl.RDFXMLParser.parse(RDFXMLParser.java:88)
at org.apache.jena.rdfxml.xmlinput.ARP.load(ARP.java:101)
at org.apache.jena.riot.lang.ReaderRIOTRDFXML.parse(ReaderRIOTRDFXML.java:173)
at org.apache.jena.riot.lang.ReaderRIOTRDFXML.read(ReaderRIOTRDFXML.java:72)
at org.apache.jena.riot.RDFParser.read(RDFParser.java:420)
at org.apache.jena.riot.RDFParser.parseNotUri(RDFParser.java:406)
at org.apache.jena.riot.RDFParser.parse(RDFParser.java:356)
at org.apache.jena.riot.RDFParserBuilder.parse(RDFParserBuilder.java:570)
at org.apache.jena.riot.RDFDataMgr.parseFromReader(RDFDataMgr.java:728)
at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:287)
at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:271)
at org.apache.jena.riot.adapters.RDFReaderRIOT.read(RDFReaderRIOT.java:62)
at org.apache.jena.rdf.model.impl.ModelCom.read(ModelCom.java:245)
from jena.
The error occurs because of two objects:
<Outer xmlns="http://BASE/">
<Prop>
<A/>
<B/>
</Prop>
</Outer>
Only the SAX based RRX parser is affected - the two StAX based ones, and ARP, detect this mistake.
Parsing OWLx (".owx") as RDF/XML and expecting an error isn't guaranteed. There are some simple documents that will pass.
from jena.
Related Issues (20)
- Titanium JSON-LD processor no longer supported HOT 1
- Move test log4j setting from log4j.properties to log4j2-test.properties
- Inconsistent default graph handling in RIOT writers HOT 3
- RDFLink: API for passing raw query strings to backend HOT 3
- java.lang.Error: Maximum lock count exceeded HOT 8
- SPARQL query round-trip serialization error HOT 1
- `jena-arq` module introduces a JUnit dependency into compile scope HOT 1
- Clean up AuthBearerFilter
- Align building of shared jars
- Upgrade to vitest v2.x
- org.apache.jena.fuseki.servlets.ActionErrorException: Cannot read field "succ" because "n" is null HOT 2
- Shiro 2.X doesn't allow plain text password in user section of shiro.ini HOT 2
- RDFXML: can't parse rdf:XMLLiteral when round-trip HOT 5
- is this well formed rdf xml? HOT 3
- DocumentGraphRepository: prevent double loading of the same graph
- RRX: Make unqualified class, unqualified properties and xml attributes an error.
- RRX: Make unqualified, unrecognized attributes an error.
- ontapi: cleanup javadocs - remove legacy model references
- Clean the build HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jena.