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 2011/10/13 23:02:58 UTC

Schemagen ignoring -c option?

Hi all,

I just discovered the schemagen tool, and it looks incredibly useful
to me.  I've been experimenting for a while with the command line
options, and would now like to use a configuration file instead of
passing lots of command line arguments.  However, schemagen seems to
ignore configuration files specified with the -c argument.  For
instance, my Jena installation is in /usr/local/lib/Jena-2.6.4, so I'd
thought that the following test would work (where I'm using the sample
schemagen.rdf that comes with Jena):

$ JENAROOT=/usr/local/lib/Jena-2.6.4 /usr/local/lib/Jena-2.6.4/bin/schemagen \
    -c /usr/local/lib/Jena-2.6.4/lib-src/etc/schemagen.rdf \
    -i etc/ontologies/data.owl

The sample schemagen contains, e.g.,

<sgen:Config>
    <!-- specifies that the  source document uses OWL -->
    <sgen:owl rdf:datatype="&xsd;boolean">true</sgen:owl>
    <!-- specifies that we want the generated vocab to use OntClass,
OntProperty, etc, not Resource and Property -->
    <sgen:ontology rdf:datatype="&xsd;boolean">true</sgen:ontology>

so the resulting Java class should be use OntClass, OntProperty, and
so on, but that's not happening.  I just get the RDF level encoding
(where everything is a Resource).  If I use the --ontology command
line option, though, as in:

$ JENAROOT=/usr/local/lib/Jena-2.6.4 /usr/local/lib/Jena-2.6.4/bin/schemagen \
    -c /usr/local/lib/Jena-2.6.4/lib-src/etc/schemagen.rdf \
    -i etc/ontologies/data.owl \
    --ontology

I do get OntClasses, OntProperties, and so on.  Can anyone enlighten
me as to what I'm doing wrong?

Many thanks in advance,
//JT




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

Re: Schemagen ignoring -c option?

Posted by Ian Dickinson <ia...@epimorphics.com>.
Hi Joshua,

On 14/10/11 16:22, Joshua TAYLOR wrote:
> While I do eventually want to work with the latest version, for the
> moment, I'm trying to take the ant-based route.  I'm running into some
> issues with newlines in 'value' attributes on nested 'arg' element in
> the java task.  Particularly, I'm trying to add some declarations
> (really, a static initialization block) but newlines aren't being
> preserved.
This may help:

http://stackoverflow.com/questions/2004386/how-to-save-newlines-in-xml-attribute

Do let us know if you find a solution.

Ian

-- 
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
               Portishead, Bristol BS20 6PT, UK


Re: Schemagen ignoring -c option?

Posted by Joshua TAYLOR <jo...@gmail.com>.
On Fri, Oct 14, 2011 at 9:01 AM, Ian Dickinson <ia...@epimorphics.com> wrote:
> On 14/10/11 13:49, Joshua TAYLOR wrote:
>>
>> Thanks for the quick response!  Well, I'm not too worried about
>> rebuilding Jena from SVN, but I am already using ant.  When you say
>> "avoid the config file and use … to give a repeatable build step", you
>> just mean using something where the configuration can be specified as
>> command line options (without having to retype them every time),
>> right?
>
> Just so.
>
>> Since I'm already set up with ant on this project, I think
>> adding the command line options there will be the simplest option for
>> now.
>
> It is indeed a commonly-used pattern:
>
> http://incubator.apache.org/jena/documentation/tools/schemagen.html#using_schemagen_with_ant

While I do eventually want to work with the latest version, for the
moment, I'm trying to take the ant-based route.  I'm running into some
issues with newlines in 'value' attributes on nested 'arg' element in
the java task.  Particularly, I'm trying to add some declarations
(really, a static initialization block) but newlines aren't being
preserved.  My task looks like

	<target name="schemagen">
		<java classname="jena.schemagen"
					classpathref="cp"
					fork="yes">
			<arg value="-i" />
			<arg value="path-to-file" />
			<arg value="--declarations" />
			<arg value="
  static {
    // Do some stuff...
	}" />
		</java>
	</target>

But then the generated output contains:

   static {     // Do some stuff...  }

which obviously introduces some problems. The same problem arises in
other places too (trying to put comments in a header, &c.).  I'm not
up on my XML attribute value newline handling, but I thought they
should be preserved.  If I run schemagen from the command line and use
multiline strings there, they're preserved, so I think this might be
an ant issue, but I wasn't sure.

Is this an instance of something that can be done with a config file
that can't be done on the command line using ant?  I guess it's time
to move to some bash scripting?

Thanks for your patience,
//JT

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

Re: Schemagen ignoring -c option?

Posted by Ian Dickinson <ia...@epimorphics.com>.
On 14/10/11 13:49, Joshua TAYLOR wrote:
> Thanks for the quick response!  Well, I'm not too worried about
> rebuilding Jena from SVN, but I am already using ant.  When you say
> "avoid the config file and use … to give a repeatable build step", you
> just mean using something where the configuration can be specified as
> command line options (without having to retype them every time),
> right?
Just so.

> Since I'm already set up with ant on this project, I think
> adding the command line options there will be the simplest option for
> now.
It is indeed a commonly-used pattern:

http://incubator.apache.org/jena/documentation/tools/schemagen.html#using_schemagen_with_ant

> If I get some time later on, though, I'll look into rebuilding
> from SVN.
Thanks, it would be good to get confirmation that the fix has addressed 
your problem.

Ian

-- 
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
               Portishead, Bristol BS20 6PT, UK


Re: Schemagen ignoring -c option?

Posted by Paolo Castagna <ca...@googlemail.com>.

Joshua TAYLOR wrote:
> On Fri, Oct 14, 2011 at 6:18 AM, Ian Dickinson <ia...@epimorphics.com> wrote:
>> On 13/10/11 22:02, Joshua TAYLOR wrote:
>>> I just discovered the schemagen tool, and it looks incredibly useful
>>> to me.  I've been experimenting for a while with the command line
>>> options, and would now like to use a configuration file instead of
>>> passing lots of command line arguments.  However, schemagen seems to
>>> ignore configuration files specified with the -c argument.  For
>>> instance, my Jena installation is in /usr/local/lib/Jena-2.6.4, so I'd
>>> thought that the following test would work (where I'm using the sample
>>> schemagen.rdf that comes with Jena):
>> You are correct, there is a problem with schemagen processing the
>> configuration file. I think it was a regression that was introduced when I
>> started work on the schemagen maven plugin. I've fixed the bug in Apache svn
>> now. You have two slightly unfortunate choices, I'm afraid: either build
>> your own snapshot version of Jena from the svn, or avoid the config file and
>> use maven, ant or script files to give a repeatable build step for
>> schemagen.  Or, if you prefer, I could send you a patch file for you to
>> patch your local version of Jena with just the fix for your issue.
> 
> Thanks for the quick response!  Well, I'm not too worried about
> rebuilding Jena from SVN, but I am already using ant.  When you say
> "avoid the config file and use … to give a repeatable build step", you
> just mean using something where the configuration can be specified as
> command line options (without having to retype them every time),
> right?  Since I'm already set up with ant on this project, I think
> adding the command line options there will be the simplest option for
> now.  If I get some time later on, though, I'll look into rebuilding
> from SVN.

Hi Joshua,
if you know how to use Apache Maven you can checkout Jena, package it
yourself, here is what you can do:

  cd /tmp
  svn co https://svn.apache.org/repos/asf/incubator/jena/Jena2/jena/trunk/ jena
  cd jena
  mvn package

You'll find the Jena jars in the target directory:

  ls -la target/

I tried to publish a new SNAPSHOT in the old Jena repo-dev but I had problems.

I published a jena-core SNAPSHOT (new Apache stile) here:
https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-core/2.6.5-incubating-SNAPSHOT/

Be warned with SNAPSHOTs and SVN trunk... these are not software releases.
You can use/test them if you want, but be always aware of their "status".

If you find a problem with the new jena-core SNAPSHOT, please, let us know.

For those using Maven, you need to point to the Apache Maven snapshot
repository and use:

  <dependency>
    <groupId>org.apache.jena</groupId>
    <artifactId>jena-core</artifactId>
    <version>2.6.5-incubating-SNAPSHOT</version>
  </dependency>

See also:

 - http://incubator.apache.org/jena/download/maven.html

Feedback and help with the documentation is also appreciated!

Cheers,
Paolo

> 
>> Thanks for spotting and reporting the problem, and apologies for the
>> inconvenience!
> 
> Thanks again for the quick response, and any inconvenience is easily
> outweighed by the convenience of not having to create "schema classes"
> by hand!
> 

Re: Schemagen ignoring -c option?

Posted by Joshua TAYLOR <jo...@gmail.com>.
On Fri, Oct 14, 2011 at 6:18 AM, Ian Dickinson <ia...@epimorphics.com> wrote:
> On 13/10/11 22:02, Joshua TAYLOR wrote:
>>
>> I just discovered the schemagen tool, and it looks incredibly useful
>> to me.  I've been experimenting for a while with the command line
>> options, and would now like to use a configuration file instead of
>> passing lots of command line arguments.  However, schemagen seems to
>> ignore configuration files specified with the -c argument.  For
>> instance, my Jena installation is in /usr/local/lib/Jena-2.6.4, so I'd
>> thought that the following test would work (where I'm using the sample
>> schemagen.rdf that comes with Jena):
>
> You are correct, there is a problem with schemagen processing the
> configuration file. I think it was a regression that was introduced when I
> started work on the schemagen maven plugin. I've fixed the bug in Apache svn
> now. You have two slightly unfortunate choices, I'm afraid: either build
> your own snapshot version of Jena from the svn, or avoid the config file and
> use maven, ant or script files to give a repeatable build step for
> schemagen.  Or, if you prefer, I could send you a patch file for you to
> patch your local version of Jena with just the fix for your issue.

Thanks for the quick response!  Well, I'm not too worried about
rebuilding Jena from SVN, but I am already using ant.  When you say
"avoid the config file and use … to give a repeatable build step", you
just mean using something where the configuration can be specified as
command line options (without having to retype them every time),
right?  Since I'm already set up with ant on this project, I think
adding the command line options there will be the simplest option for
now.  If I get some time later on, though, I'll look into rebuilding
from SVN.

> Thanks for spotting and reporting the problem, and apologies for the
> inconvenience!

Thanks again for the quick response, and any inconvenience is easily
outweighed by the convenience of not having to create "schema classes"
by hand!

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

Re: Schemagen ignoring -c option?

Posted by Ian Dickinson <ia...@epimorphics.com>.
Hi Joshua,

On 13/10/11 22:02, Joshua TAYLOR wrote:
> I just discovered the schemagen tool, and it looks incredibly useful
> to me.  I've been experimenting for a while with the command line
> options, and would now like to use a configuration file instead of
> passing lots of command line arguments.  However, schemagen seems to
> ignore configuration files specified with the -c argument.  For
> instance, my Jena installation is in /usr/local/lib/Jena-2.6.4, so I'd
> thought that the following test would work (where I'm using the sample
> schemagen.rdf that comes with Jena):
You are correct, there is a problem with schemagen processing the 
configuration file. I think it was a regression that was introduced when 
I started work on the schemagen maven plugin. I've fixed the bug in 
Apache svn now. You have two slightly unfortunate choices, I'm afraid: 
either build your own snapshot version of Jena from the svn, or avoid 
the config file and use maven, ant or script files to give a repeatable 
build step for schemagen.  Or, if you prefer, I could send you a patch 
file for you to patch your local version of Jena with just the fix for 
your issue.

Thanks for spotting and reporting the problem, and apologies for the 
inconvenience!

Ian


-- 
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
               Portishead, Bristol BS20 6PT, UK