The output is very similar: you can see the output of vocab2jena here:
https://gist.github.com/TreeRex/6464149
The main difference is that I use use the ResourceFactory methods instead
of creating the static Model. And I don't use the * wildcard on the imports.
So... I guess it would have behoved me to look at schemagen before I spent
a couple of hours writing my utility: it would have saved me the bother. I
saw the name in the docs and didn't connect it to what I needed. I should
have figured you guys would have done this already. :-/
-tree
On Fri, Sep 6, 2013 at 11:49 AM, Joshua TAYLOR <[email protected]>wrote:
> On Fri, Sep 6, 2013 at 11:44 AM, Joshua TAYLOR <[email protected]>
> wrote:
> > On Fri, Sep 6, 2013 at 10:49 AM, Tom Emerson <[email protected]>
> wrote:
> >> I am working with SKOS in Jena and needed to create a utility class
> >> containing the properties and resources defined in the vocabulary (just
> >> like those in com.hp.hpl.jena.vocabulary). Instead of creating these
> >> manually, I did the normal engineer thing and wrote a program to
> generate
> >> them for me. It works for SKOS: I haven't tried it with other
> vocabularies.
> >>
> >> The code is available if you want to try it out.
> Suggestions/improvements
> >> are welcome.
> >>
> >> https://github.com/TreeRex/vocab2jena
> >
> > Code-generation is always interesting. Can you give a quick overview
> > of how it compares with Jena's schemagen [1]?
> >
> > [1] http://jena.apache.org/documentation/tools/schemagen.html
>
> For comparison purposes, here's what Jena's schemagen produces for SKOS:
>
> $ schemagen -i http://www.w3.org/TR/skos-reference/skos.rdf
>
> /* CVS $Id: $ */
>
> import com.hp.hpl.jena.rdf.model.*;
>
> /**
> * Vocabulary definitions from
> http://www.w3.org/TR/skos-reference/skos.rdf
> * @author Auto-generated by schemagen on 06 Sep 2013 11:47
> */
> public class Skos {
> /** <p>The RDF model that holds the vocabulary terms</p> */
> private static Model m_model = ModelFactory.createDefaultModel();
>
> /** <p>The namespace of the vocabulary as a string</p> */
> public static final String NS = "http://www.w3.org/2004/02/skos/core#
> ";
>
> /** <p>The namespace of the vocabulary as a string</p>
> * @see #NS */
> public static String getURI() {return NS;}
>
> /** <p>The namespace of the vocabulary as a resource</p> */
> public static final Resource NAMESPACE = m_model.createResource( NS );
>
> /** <p>The range of skos:altLabel is the class of RDF plain
> literals.skos:prefLabel,
> * skos:altLabel and skos:hiddenLabel are pairwise disjoint
> properties.</p>
> */
> public static final Property altLabel = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#altLabel" );
>
> public static final Property broadMatch = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#broadMatch" );
>
> /** <p>Broader concepts are typically rendered as parents in a
> concept hierarchy
> * (tree).</p>
> */
> public static final Property broader = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#broader" );
>
> public static final Property broaderTransitive =
> m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#broaderTransitive" );
>
> public static final Property changeNote = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#changeNote" );
>
> public static final Property closeMatch = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#closeMatch" );
>
> public static final Property definition = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#definition" );
>
> public static final Property editorialNote =
> m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#editorialNote" );
>
> /** <p>skos:exactMatch is disjoint with each of the properties
> skos:broadMatch and
> * skos:relatedMatch.</p>
> */
> public static final Property exactMatch = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#exactMatch" );
>
> public static final Property example = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#example" );
>
> public static final Property hasTopConcept =
> m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#hasTopConcept" );
>
> /** <p>The range of skos:hiddenLabel is the class of RDF plain
> literals.skos:prefLabel,
> * skos:altLabel and skos:hiddenLabel are pairwise disjoint
> properties.</p>
> */
> public static final Property hiddenLabel = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#hiddenLabel" );
>
> public static final Property historyNote = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#historyNote" );
>
> public static final Property inScheme = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#inScheme" );
>
> /** <p>These concept mapping relations mirror semantic relations,
> and the data model
> * defined below is similar (with the exception of
> skos:exactMatch) to the data
> * model defined for semantic relations. A distinct vocabulary is
> provided for
> * concept mapping relations, to provide a convenient way to
> differentiate links
> * within a concept scheme from links between concept schemes.
> However, this
> * pattern of usage is not a formal requirement of the SKOS data
> model, and relies
> * on informal definitions of best practice.</p>
> */
> public static final Property mappingRelation =
> m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#mappingRelation" );
>
> public static final Property member = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#member" );
>
> /** <p>For any resource, every item in the list given as the value
> of the skos:memberList
> * property is also a value of the skos:member property.</p>
> */
> public static final Property memberList = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#memberList" );
>
> public static final Property narrowMatch = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#narrowMatch" );
>
> /** <p>Narrower concepts are typically rendered as children in a
> concept hierarchy
> * (tree).</p>
> */
> public static final Property narrower = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#narrower" );
>
> public static final Property narrowerTransitive =
> m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#narrowerTransitive" );
>
> public static final Property notation = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#notation" );
>
> public static final Property note = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#note" );
>
> /** <p>skos:prefLabel, skos:altLabel and skos:hiddenLabel are
> pairwise disjoint properties.A
> * resource has no more than one value of skos:prefLabel per
> language tag, and
> * no more than one value of skos:prefLabel without language
> tag.The range of
> * skos:prefLabel is the class of RDF plain literals.</p>
> */
> public static final Property prefLabel = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#prefLabel" );
>
> /** <p>skos:related is disjoint with skos:broaderTransitive</p> */
> public static final Property related = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#related" );
>
> public static final Property relatedMatch =
> m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#relatedMatch" );
>
> public static final Property scopeNote = m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#scopeNote" );
>
> public static final Property semanticRelation =
> m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#semanticRelation" );
>
> public static final Property topConceptOf =
> m_model.createProperty(
> "http://www.w3.org/2004/02/skos/core#topConceptOf" );
>
> public static final Resource Collection = m_model.createResource(
> "http://www.w3.org/2004/02/skos/core#Collection" );
>
> public static final Resource Concept = m_model.createResource(
> "http://www.w3.org/2004/02/skos/core#Concept" );
>
> public static final Resource ConceptScheme =
> m_model.createResource(
> "http://www.w3.org/2004/02/skos/core#ConceptScheme" );
>
> public static final Resource OrderedCollection =
> m_model.createResource(
> "http://www.w3.org/2004/02/skos/core#OrderedCollection" );
>
> }
>
> --
> Joshua Taylor, http://www.cs.rpi.edu/~tayloj/
>
--
Tom Emerson
[email protected]
http://www.dreamersrealm.net/tree