On 02/09/13 16:34, Charles Li wrote
Thanks Andy!

I managed to narrow down to the following SPAQL query issue (the
model was in TDB loaded from file "C:/temp/myrdf.xml". Jena 2.10.1)

When I run the following query:

select ?s  ?p  ?o WHERE { <file:///C:/temp/myrdf.xml#ROOT>  ?p   ?o
. }

I was able to get the correct triples (the logical tree structure
root is modeled in the RDF file with a node whose RdfId is literally
"ROOT")  .

However, when I plug in the RdfId with the following query:

select ?s  ?p  ?o WHERE { <file:///C:/temp/myrdf.xml#
_{27900499-0D9D-4287-8F4D-E4C13BCB3C8D}>  ?p   ?o . }

I got an error:

Encountered " "<" "< "" ......

{ and } are illegal in IRIs.  Ideally, your data would not use them.
You may run into other problems if you continue to use bad IRIs.

You probably got a warning when loading data.


So I think it may be due to the special characters in the RdfID, and
I tried the following query:

select ?s  ?p  ?o WHERE {


URI(ENCODE_FOR_URI("file:///C:/temp/myrdf.xml#_{27900499-0D9D-4287-8F4D-E4C13BCB3C8D}"))
?p  ?o  .
}

Encoding is not escaping.

If you encode { as %7B then the characters in the IRI are %-7-B, it's not a way like \n to get the raw character into IRI.

You can try: CONTAINS(STR(...)) as you had before but on the correct variable now we've established it is in the subject position.

SELECT * {
  ?s ?p ?o
  FILTER( CONTAINS(STR(?s), "27900499-0D9D-4287-8F4D-E4C13BCB3C8D")
}

or
FILTER( STR(?s) = "file:///C:/temp/myrdf.xml#_{0E43691F-0B64-42AF-AFCF-19BCC28ACBA3}")

This is not a fast query - it's a scan of the entire database - but you could use it to convert your data using SPARQL Update.

You can also use initial bindings (see QueryExecutionFactory) on a query to inject values after the parse stage.


But still syntax error.

which is unrelated to the URI issue.  You need to look at the spec or a
book like "Learning SPARQL" or one of the many online introductions.
Guessing at syntax is going to take you a long time.


How should I compose the SPARQL query string to specify the RdfID in
place correctly?


Thanks a lot!

- Charles

        Andy

Reply via email to