anyone ever see this SPARQL syntax error?

854 views
Skip to first unread message

donundeen

unread,
Oct 15, 2008, 4:01:07 PM10/15/08
to TopBraid Composer Users
'Encountered "<" at line 0, column 13. was expecting: <IRIref> ...'

I'm getting this error, and a greyed-out 'execute query' button in my
SPARQL query window.

this happens with any query, such as
CONSTRUCT{
?subj ?pred ?obj .
}
WHERE
{
?subj ?pred ?obj .
}


but this only happens with certain ontologies loaded.

any ideas?


thanks!
don

Scott Henninger

unread,
Oct 16, 2008, 11:59:12 AM10/16/08
to TopBraid Composer Users
Don; The SPARQL tab does not allow a blank line in the query. For
this query it would be "Encountered <EOF> at line 6..."
-- Scott

donundeen

unread,
Oct 16, 2008, 12:05:02 PM10/16/08
to TopBraid Composer Users
sorry, I don't know how that blank line slipped into my example, but
this error occurs with ANY otherwise-valid query I write, but only
with certain ontologies open.

and it's not an "Encounted EOF" error, it's:
'Encountered "<" at line 0, column 13. was expecting:
<IRIref> ...'

always line 0, column 13.

On Oct 16, 11:59 am, Scott Henninger <shennin...@topquadrant.com>
wrote:

Scott Henninger

unread,
Oct 16, 2008, 12:22:59 PM10/16/08
to TopBraid Composer Users
OK. An example would be helpfu. And if the issue only occurs for some
files, I'm guessing it has to do with URIs of resources. So an
example of an offending ontology would be helpful as well.
-- Scott

donundeen

unread,
Oct 16, 2008, 1:36:16 PM10/16/08
to TopBraid Composer Users
interesting, check this out.
Here's the top part of my ontology file:

<?xml version="1.0"?>
<rdf:RDF
xmlns:j.0="file:///MCNProject2/MediaBinSample.xml#PARAMObject_Sort
"
xmlns:sxml="http://topbraid.org/sxml#"
xmlns:j.1="http://metmuseum.org/ontologies/xmlHelp/"
xmlns:j.2="file:///MCNProject2/sargent.xml#marc:"
xmlns:j.4="file:///MCNProject2/MediaBinSample.xml#PARAMObject_Date
"
xmlns:j.3="file:///MCNProject2/sargent.xml#"
xmlns:j.5="file:///MCNProject2/MediaBinSample.xml#PARAMObject_TMS
"
xmlns:j.6="file:///MCNProject2/MediaBinSample.xml#PARAMImage
Rights_TMS Object Rights Entered "
xmlns:j.7="file:///MCNProject2/MediaBinSample.xml#PARAMOriginal
File "
xmlns:j.8="file:///MCNProject2/MediaBinSample.xml#PARAMLayer Setup
"
xmlns:j.9="file:///MCNProject2/MediaBinSample.xml#PARAMPhotoshop "
xmlns:j.10="file:///MCNProject2/
MediaBinSample.xml#PARAMObject_Credit "
xmlns:j.11="file:///MCNProject2/MediaBinSample.xml#PARAMAsset "
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:j.12="http://www.owl-ontologies.com/file1.owl#"
xmlns:j.13="file:///MCNProject2/
MediaBinSample.xml#PARAMObject_Composite "
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:composite="http://www.topbraid.org/2007/05/composite.owl#"
xmlns:j.14="file:///MCNProject2/MediaBinSample.xml#PARAMInsertion
"
xmlns:j.15="file:///MCNProject2/MediaBinSample.xml#"
xmlns="http://www.owl-ontologies.com/MCNProject2#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:j.16="file:///MCNProject2/MediaBinSample.xml#PARAMForward
Setup "
xmlns:j.17="file:///MCNProject2/
MediaBinSample.xml#PARAMImage_Archival CD "
xmlns:j.18="file:///MCNProject2/
MediaBinSample.xml#PARAMObject_Object "
xmlns:j.19="file:///MCNProject2/MediaBinSample.xml#PARAMObject_TMS
Object Package "
xml:base="http://www.owl-ontologies.com/MCNProject2" >

those are the j.n prefixes I was talking about in another post.

when I load the file, I get the following error in the console:

WARNING: http://www.owl-ontologies.com/MCNProject2(line 30 column 57):
{W124} Non-ascii characters in a namespace URI may not be completely
portable: (file:///MCNProject2/MEdiaBinSample.xml#PARAMObject_TMS
Object Package >. Resulting RDF URI refences are legal.

Since I didn't want those prefixes anyways, I removed them and
reloaded the file.
No more warning messages, and I'm not getting the cryptic SPARQL error
messages either.

it's definitely odd that the above syntax problem would reveal itself
in the form of a SPARQL syntax error message. I'd rather the file fail
to load, with a relevant message, than load a file that leads to such
behaviour.


On Oct 16, 12:22 pm, Scott Henninger <shennin...@topquadrant.com>
wrote:

Holger Knublauch

unread,
Oct 16, 2008, 1:46:00 PM10/16/08
to topbraid-co...@googlegroups.com
Ah, this clarifies it. TBC will actually prepend the namespace prefix
declarations to your SPARQL queries so that you don't need to type
them in manually. Apparently this algorithm should be more tolerant
against the kind of namespaces that you have in your file. On the
other hand, the bug seems to be somewhere else, because the namespaces
end with a space character, which is invalid anyhow.

Holger

donundeen

unread,
Oct 16, 2008, 2:01:57 PM10/16/08
to TopBraid Composer Users
yes that is odd about the space at the end.

What I had done was, after importing the xml file, subdivided the
PARAM (created from the PARAM element in my xml) class into a bunch of
subclasses, based on the string value of a particular sub-element.
I used the buildURI function to create the new class names, so I would
assume all those constructed URIs would be valid. and seeing lines
like:
<rdf:type rdf:resource="file:///MCNProject2/
MediaBinSample.xml#PARAMObject_Credit Line"/>
in my rdf file implies they are (or are they? Am I allowed that space
before "Line" ? if not, why wouldn't buildURI fix it, or am I
misinterpreting that functions use?).
But when the namespaces were generated, the space appears.
> > WARNING:http://www.owl-ontologies.com/MCNProject2(line30 column 57):

Scott Henninger

unread,
Oct 16, 2008, 3:03:31 PM10/16/08
to TopBraid Composer Users
Don, spaces are not allowed in URIs. buildURI will replace spaces
with underscores:
LET (?aname := "file:///a name") .
LET (?auri := smf:buildURI ("{?1}", ?aname))

will create the string "file:///a_name". Maybe the URI is being
constructed elsewhere?
-- Scott
> > > WARNING:http://www.owl-ontologies.com/MCNProject2(line30column 57):

donundeen

unread,
Oct 16, 2008, 4:32:55 PM10/16/08
to TopBraid Composer Users
....

OOOOOOOHHH

now I see, buildURI only replaces space with underscores within the
templated vars, not string literals.

iow, THIS doesn't work:
LET (?aname := "file:///a name") .
LET (?auri := smf:buildURI (?aname))

I didn't realize that about buildURI



On Oct 16, 3:03 pm, Scott Henninger <shennin...@topquadrant.com>
wrote:

Scott Henninger

unread,
Oct 16, 2008, 11:58:35 PM10/16/08
to TopBraid Composer Users
Yes. In fact the vars are the only things that are changed by
buildURI. The rest is part of the string template. So in
LET (?auri := smf:buildURI ("Some stuff {?1} more stuff {?2}", ?
aname, ?bname))

...everything stays the same except for inside the args {?1} and {?
2}. This is the canonical pattern, by the way - that the first
argument is a template and the arguments that follow are used int he
template.

-- Scott

Smith, Tim

unread,
Oct 17, 2008, 9:37:35 AM10/17/08
to topbraid-co...@googlegroups.com
You can also use the variable names directly in the template instead of ?1, ?2, etc.

e.g. LET (?auri := smf:buildURI ("Some stuff {?aname} more stuff ?bname}"))

donundeen

unread,
Oct 17, 2008, 10:14:47 AM10/17/08
to TopBraid Composer Users
aah cool.
thanks!
Reply all
Reply to author
Forward
0 new messages