-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix trix parser to allow lowercase
trix
, add tests (#1966)
Changed TriX parser to allow `trix` and `TriX` The RDFLib TriX parser currently only accepts TriX documents conforming to the the [Nokia-published XSD](https://web.archive.org/web/20040821093939/http://swdev.nokia.com/trix/trix-1.0.xsd) which specifies (the mixed-case) `TriX`, contradicting the [W3C-published XSD spec for TriX](https://www.w3.org/2004/03/trix/trix-1/trix-1.0.xsd) which specifies (the lower-case) `trix`. We should accept both. We were also a bit light on a TriX test suite for exercising the parser, so I recruited some TriX test fixtures from NG4J and Jena and fleshed out the TriX test suite, using the W3C "Manifest"-style approach.
- Loading branch information
Graham Higgins
authored
May 25, 2022
1 parent
685dec5
commit 8e24878
Showing
135 changed files
with
12,464 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
This README is adapted from the README of the W3C RDF Working Group's | ||
TriG test suite and modified for use with RDFLib's informally-assembled | ||
TrIX test suite. This test suite contains three kinds of tests: | ||
|
||
Evaluation (rdft:TestTrixEval) - a pair of an input trig file | ||
and reference ntriples file. | ||
|
||
Positive syntax (rdft:TestTrixPositiveSyntax) - an input trig | ||
file with no syntax errors. | ||
|
||
Negative syntax (rdft:TestTrixNegativeSyntax) - an input trig | ||
file with at least one syntax error. | ||
|
||
The manifest.ttl file in this directory lists all of the tests in the | ||
RDFLib TriX test suite. Each test is one of the above tests. All | ||
tests have a name (mf:name) and an input (mf:action). The Evaluation | ||
tests have an expected result (mf:result). | ||
|
||
• An implementation passes an Evaluation test if it parses the input | ||
into a graph, parses the expecte result into another graph, and | ||
those two graphs are isomorphic (see | ||
<http://www.w3.org/TR/rdf11-concepts/#graph-isomorphism>). | ||
|
||
• An implementation passes a positive syntax test if it parses the | ||
input. | ||
|
||
• An implementation passes a negative syntax test if it fails to parse | ||
the input. | ||
|
||
The IRI for the test suite is <https://rdflib.github.io/tests/trix/>. | ||
Per RFC 3986 section 5.1.3, the base IRI for parsing each file is the | ||
retrieval IRI for that file. For example, the tests trig-subm-01 and | ||
trig-subm-27 require relative IRI resolution against a base of | ||
<https://rdflib.github.io/tests/trix/trig-subm-01.trix> and | ||
<https://rdflib.github.io/tests/trix/strig-subm-27.trix> respectively. | ||
|
||
|
||
Adapted from https://github.com/w3c/rdf-tests/blob/main/trig/README, | ||
authors: | ||
|
||
Eric Prud'hommeaux <eric+turtle@w3.org> - 11 June 2013. | ||
Gregg Kellogg <gregg@greggkellogg.net> - 12 June 2013. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0"?> | ||
<!-- Replaces any XML document by a hard-coded TriX document containing | ||
one graph with one triple --> | ||
<xsl:stylesheet | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns="http://www.w3.org/2004/03/trix/trix-1/" | ||
xmlns:ex="http://example.com/#" | ||
version="2.0"> | ||
<xsl:template match="/"> | ||
<TriX> | ||
<graph> | ||
<triple> | ||
<qname>ex:a</qname> | ||
<qname>ex:b</qname> | ||
<qname>ex:c</qname> | ||
</triple> | ||
</graph> | ||
</TriX> | ||
</xsl:template> | ||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0"?> | ||
<!-- Expands <qname>ns:foo</qname> to <uri>.....foo</uri> using xmlns:ns --> | ||
<xsl:stylesheet | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns="http://www.w3.org/2004/03/trix/trix-1/" | ||
xmlns:trix="http://www.w3.org/2004/03/trix/trix-1/" | ||
xmlns:ex="http://example.com/#" | ||
version="2.0"> | ||
|
||
<!-- Expand qnames --> | ||
<xsl:template match="trix:qname"> | ||
<uri> | ||
<xsl:variable name="ns"> | ||
<xsl:value-of select="substring-before(text(),':')"/> | ||
</xsl:variable> | ||
<xsl:value-of select="namespace::*[local-name()=$ns]"/> | ||
<xsl:value-of select="substring-after(text(),':')"/> | ||
</uri> | ||
</xsl:template> | ||
|
||
<!-- Not necessary, but avoids namespace declarations scattered through | ||
the result document --> | ||
<xsl:template match="trix:TriX"> | ||
<TriX><xsl:apply-templates/></TriX> | ||
</xsl:template> | ||
|
||
<!-- This is a simple identity function --> | ||
<xsl:template match="@*|*|processing-instruction()|comment()" priority="-2"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="*|@*|text()|processing-instruction()|comment()"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
</xsl:stylesheet> |
Oops, something went wrong.