You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/07/11 17:05:19 UTC
git commit: less restrictive URI syntax in LDPath parser (fixes
MARMOTTA-270)
Updated Branches:
refs/heads/develop 0b7311e31 -> 839c83096
less restrictive URI syntax in LDPath parser (fixes MARMOTTA-270)
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/839c8309
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/839c8309
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/839c8309
Branch: refs/heads/develop
Commit: 839c83096d43f05d882a575cb78f99d0e0d8d6d6
Parents: 0b7311e
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Thu Jul 11 17:05:08 2013 +0200
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Thu Jul 11 17:05:08 2013 +0200
----------------------------------------------------------------------
.../main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj | 10 +++++-----
.../org/apache/marmotta/ldpath/parser/ParserTest.java | 4 ++++
.../src/test/resources/parse/namespaces.ldpath | 3 ++-
3 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/839c8309/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj b/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj
index ef8ca5d..0fd1c44 100644
--- a/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj
+++ b/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj
@@ -417,7 +417,7 @@ TOKEN : /* BRACKETS */
}
TOKEN :
{
- < URI: ["a"-"z","A"-"Z"](["a"-"z","A"-"Z","0"-"9","+","-","."])* "://" (["a"-"z","A"-"Z","0"-"9",";","/","?",":","@","&","=","+","$",".","-","_","!","~","*","'","%"])+ ("#" (["a"-"z","A"-"Z","0"-"9",";","/","?",":","@","&","=","+","$",".","-","_","!","~","*","'","%"])*)? | "#" (["a"-"z","A"-"Z","0"-"9",";","/","?",":","@","&","=","+","$",".","-","_","!","~","*","'","%"])+> |
+ < URI: "<" (~[ ">","<", "\"", "{", "}", "^", "\\", "|", "`", "\u0000"-"\u0020"])+ ">" > |
< IDENTIFIER: ["a"-"z","A"-"Z","0"-"9","_"](["a"-"z","A"-"Z","0"-"9","_","'","-", "."])* > |
< #URICHAR: ["a"-"z","A"-"Z","0"-"9",";","/","?",":","@","&","=","+","$",".","-","_","!","~","*","'","%"] >
}
@@ -445,9 +445,9 @@ Entry<String, String> Namespace() :
}
{
(
- <K_PREFIX> id = <IDENTIFIER> <COLON> <B_XO> uri = <URI> <B_XC> (<SCOLON> )? {
+ <K_PREFIX> id = <IDENTIFIER> <COLON> uri = <URI> (<SCOLON> )? {
}
- ) { return new Namespace(id.image, uri.image); }
+ ) { return new Namespace(id.image, uri.image.substring(1,uri.image.length()-1)); }
}
Program Program() :
@@ -605,8 +605,8 @@ String Uri() : {
}
{
- "<" uri = <URI> ">" {
- return uri.image;
+ uri = <URI> {
+ return uri.image.substring(1,uri.image.length()-1);
}
| prefix = <IDENTIFIER> ":" localName = <IDENTIFIER> {
return resolveNamespace(prefix.image)+localName.image;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/839c8309/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ParserTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ParserTest.java b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ParserTest.java
index 8c787e5..8d2c13f 100644
--- a/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ParserTest.java
+++ b/libraries/ldpath/ldpath-core/src/test/java/org/apache/marmotta/ldpath/parser/ParserTest.java
@@ -47,12 +47,14 @@ public class ParserTest {
private static NodeBackend<String> backend;
private static final String NS_TEST = "http://example.com/";
private static final String NS_FOO = "http://foo.com/some/path#";
+ private static final String NS_FOOBAR = "urn:uuid:1234";
private static final Map<String, String> NAMESPACES;
static {
Map<String, String> ns = new HashMap<String, String>();
ns.put("test", NS_TEST);
ns.put("foo", NS_FOO);
+ ns.put("foobar", NS_FOOBAR);
NAMESPACES = Collections.unmodifiableMap(ns);
}
@@ -101,8 +103,10 @@ public class ParserTest {
Map<String, String> prefixes = parser.parsePrefixes();
assertTrue(prefixes.containsKey("test"));
assertTrue(prefixes.containsKey("foo"));
+ assertTrue(prefixes.containsKey("foobar"));
assertEquals(NS_TEST, prefixes.get("test"));
assertEquals(NS_FOO, prefixes.get("foo"));
+ assertEquals(NS_FOOBAR, prefixes.get("foobar"));
} catch (ParseException e) {
assertFalse(e.getMessage(), true);
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/839c8309/libraries/ldpath/ldpath-core/src/test/resources/parse/namespaces.ldpath
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/resources/parse/namespaces.ldpath b/libraries/ldpath/ldpath-core/src/test/resources/parse/namespaces.ldpath
index 0f7c569..81a7def 100644
--- a/libraries/ldpath/ldpath-core/src/test/resources/parse/namespaces.ldpath
+++ b/libraries/ldpath/ldpath-core/src/test/resources/parse/namespaces.ldpath
@@ -17,4 +17,5 @@
@prefix foo: <http://foo.com/some/path#> ;
@prefix foaf: <http://xmlns.com/foaf/0.1/> ;
@prefix test: <http://example.com/>
-@prefix dcterms: <http://purl.org/dc/terms/> ;
\ No newline at end of file
+@prefix dcterms: <http://purl.org/dc/terms/> ;
+@prefix foobar: <urn:uuid:1234> ;