You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Joshua TAYLOR <jo...@gmail.com> on 2012/07/24 22:09:38 UTC

rdfcat utility doesn't respect -n/-in N3 flag

[Edit, after some digging, but before sending the report:  I've looked
at the javadoc for rdfcat, which describes a somewhat different set of
command line options, along with some changes from past version.  Even
modulo these changes, it's still the case that the extension based
guessing seems to take precedence over the explicitly stated format
arguments.  So, e.g., "rdfcat -in N3 fields.rdf" has the same error
that "rdfcat -n fields.rdf" does.]

Hi all,  It seems that the rdfcat utility that's bundled with Jena
doesn't respect the -n flag that it describes.  According to the
output from 'rdfcat --help', specifying -n before some filenames
should cause Jena to expect that those documents are in N3 syntax:

$ JENAROOT=/usr/local/lib/apache-jena-2.7.2
/usr/local/lib/apache-jena-2.7.2/bin/rdfcat --help
Usage: java jena.rdfcat (option|input)*
Concatenates the contents of zero or more input RDF documents.
Options: -out N3 | N-TRIPLE | RDF/XML | RDF/XML-ABBREV
         -n  expect subsequent inputs in N3 syntax
         -x  expect subsequent inputs in RDF/XML syntax
         -t  expect subsequent inputs in N-TRIPLE syntax
         -[no]include  include rdfs:seeAlso and owl:imports
input can be filename, URL, or - for stdin
Recognised aliases for -n are: -n3 -ttl or -N3
Recognised aliases for -x are: -xml -rdf or -rdfxml
Recognised aliases for -t are: -ntriple
Output format aliases: x, xml or rdf for RDF/XML, n, n3 or ttl for N3,
t or ntriple for N-TRIPLE
See the Javadoc for jena.rdfcat for additional details.

I've got a file in N3 format:

$ head -11 fields.rdf
@prefix : <http://www.ainfosec.com/ontologies/cr2/cr2.owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:UPTIME
  a :AndroidField ;
  rdfs:label "UPTIME" ;
  rdfs:comment "uptime" .
:MEMORY_INFO
  a :AndroidField ;
  rdfs:label "MEMORY INFO" ;
  rdfs:comment "/proc/meminfo" .

When I ask rdfcat to process it with -n, or without any options, I get
RDFXML related errors.  If I rename the file with a .n3 extension,
then rdfcat has no errors without options, or with -n.  In fact, if I
use the file with an .n3 extension and specify -x (for RDF/XML), I
don't get an error either.

Error output (here with -n, but same with no flags):

$ JENAROOT=/usr/local/lib/apache-jena-2.7.2
/usr/local/lib/apache-jena-2.7.2/bin/rdfcat -n fields.rdf
15:16:23 ERROR RDFDefaultErrorHandler :: file:fields.rdf(line 1 column
1): Content is not allowed in prolog.
Exception in thread "main" com.hp.hpl.jena.shared.JenaException:
org.xml.sax.SAXParseException; systemId: file:fields.rdf; lineNumber:
1; columnNumber: 1; Content is not allowed in prolog.
        at com.hp.hpl.jena.rdf.model.impl.RDFDefaultErrorHandler.fatalError(RDFDefaultErrorHandler.java:60)

Non error output (here with -x, but same with -n and with no flags):

$ JENAROOT=/usr/local/lib/apache-jena-2.7.2
/usr/local/lib/apache-jena-2.7.2/bin/rdfcat -x fields.n3 | head
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
...




-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Re: rdfcat utility doesn't respect -n/-in N3 flag

Posted by Ian Dickinson <ia...@epimorphics.com>.
Thanks, Joshua. I've logged this as JENA-285 [1].

Ian

[1] https://issues.apache.org/jira/browse/JENA-285