com.nwalsh.xslt
Class TwigJena

java.lang.Object
  |
  +--com.nwalsh.xslt.TwigJena
Direct Known Subclasses:
RDFTwig, RDFTwig

public class TwigJena
extends java.lang.Object

XSLT extensions to access portions of an RDF graph.

Copyright (C) 2002, 2003 Norman Walsh.

This class provides the core functions needed to access portions of an RDF graph with an XSLT processor. The actual binding to a particular XSLT processor is provided in another class.

The underlying RDF model is accessed with Jena.

WARNING: The resource() function will never return an anonymous resource. Jena doesn't really provide access to serialized anonymous resources very well. In practice, this means you can't use these functions with graphs that contain blank nodes.

Change Log:

1.0

Initial release.

Version:
$Id: TwigJena.java,v 1.1 2003/03/21 16:56:48 nwalsh Exp $
Author:
Norman Walsh ndw@nwalsh.com

Field Summary
static com.hp.hpl.mesa.rdf.jena.model.Model defaultModel
           
static boolean loadedModel
           
static boolean quiet
           
 
Constructor Summary
TwigJena()
           
 
Method Summary
protected static void defaultModelWarning()
          Warn the user if there's no default model.
static com.hp.hpl.mesa.rdf.jena.model.Resource difference(com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource results1, com.hp.hpl.mesa.rdf.jena.model.Resource results2)
          Returns the difference between the FindResuls in results1 and results2.
static com.hp.hpl.mesa.rdf.jena.model.Resource difference(com.hp.hpl.mesa.rdf.jena.model.Resource results1, com.hp.hpl.mesa.rdf.jena.model.Resource results2)
          Convenience method using the default model.
protected static void exceptionWarning(java.lang.Exception e)
          Tell the user about exceptions.
static com.hp.hpl.mesa.rdf.jena.model.Resource filter(com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource findResults, com.hp.hpl.mesa.rdf.jena.model.Property property, com.hp.hpl.mesa.rdf.jena.model.Resource rsrc)
          Find all the resources in the result set that have the specified resource as a value of the specified property.
static com.hp.hpl.mesa.rdf.jena.model.Resource filter(com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource findResults, com.hp.hpl.mesa.rdf.jena.model.Property property, java.lang.String literal)
          Find all the resources in the result set that have the specified literal as a value of the specified property.
static com.hp.hpl.mesa.rdf.jena.model.Resource filter(com.hp.hpl.mesa.rdf.jena.model.Resource findResults, com.hp.hpl.mesa.rdf.jena.model.Property property, com.hp.hpl.mesa.rdf.jena.model.Resource rsrc)
          Convenience method using the default model.
static com.hp.hpl.mesa.rdf.jena.model.Resource filter(com.hp.hpl.mesa.rdf.jena.model.Resource findResults, com.hp.hpl.mesa.rdf.jena.model.Property property, java.lang.String literal)
          Convenience method using the default model.
static com.hp.hpl.mesa.rdf.jena.model.Resource filterNot(com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource findResults, com.hp.hpl.mesa.rdf.jena.model.Property property, com.hp.hpl.mesa.rdf.jena.model.Resource rsrc)
          Find all the resources in the result set that do not have the specified resource as a value of the specified property.
static com.hp.hpl.mesa.rdf.jena.model.Resource filterNot(com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource findResults, com.hp.hpl.mesa.rdf.jena.model.Property property, java.lang.String literal)
          Find all the resources in the result set that do not have the specified literal as a value of the specified property.
static com.hp.hpl.mesa.rdf.jena.model.Resource filterNot(com.hp.hpl.mesa.rdf.jena.model.Resource findResults, com.hp.hpl.mesa.rdf.jena.model.Property property, com.hp.hpl.mesa.rdf.jena.model.Resource rsrc)
          Convenience method using the default model.
static com.hp.hpl.mesa.rdf.jena.model.Resource filterNot(com.hp.hpl.mesa.rdf.jena.model.Resource findResults, com.hp.hpl.mesa.rdf.jena.model.Property property, java.lang.String literal)
          Convenience method using the default model.
static com.hp.hpl.mesa.rdf.jena.model.Resource find(com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Property property, com.hp.hpl.mesa.rdf.jena.model.Resource rsrc)
          Find all the resources in the model that have the specified resource as a value of the specified property.
static com.hp.hpl.mesa.rdf.jena.model.Resource find(com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Property property, java.lang.String literal)
          Find all the resources in the model that have the specified literal as a value of the specified property.
static com.hp.hpl.mesa.rdf.jena.model.Resource find(com.hp.hpl.mesa.rdf.jena.model.Property property, com.hp.hpl.mesa.rdf.jena.model.Resource rsrc)
          Convenience method using the default model.
static com.hp.hpl.mesa.rdf.jena.model.Resource find(com.hp.hpl.mesa.rdf.jena.model.Property property, java.lang.String literal)
          Convenience method using the default model.
static com.hp.hpl.mesa.rdf.jena.model.Resource get(com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource rsrc, com.hp.hpl.mesa.rdf.jena.model.Property property)
          Find all the nodes in the model that are the values of the specified property on the specified resrc.
static com.hp.hpl.mesa.rdf.jena.model.Resource get(com.hp.hpl.mesa.rdf.jena.model.Resource rsrc, com.hp.hpl.mesa.rdf.jena.model.Property property)
          Convenience method using the default model.
static com.hp.hpl.mesa.rdf.jena.model.Resource intersection(com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource results1, com.hp.hpl.mesa.rdf.jena.model.Resource results2)
          Returns the intersection of the FindResuls in results1 and results2.
static com.hp.hpl.mesa.rdf.jena.model.Resource intersection(com.hp.hpl.mesa.rdf.jena.model.Resource results1, com.hp.hpl.mesa.rdf.jena.model.Resource results2)
          Convenience method using the default model.
static com.hp.hpl.mesa.rdf.jena.model.Model load(java.lang.String filename)
          Load an RDF model.
static com.hp.hpl.mesa.rdf.jena.model.Property property(java.lang.String namespaceUri, java.lang.String localName)
          Constructs an RDF property.
static boolean quiet(boolean newQuiet)
          Toggle informative messages.
static com.hp.hpl.mesa.rdf.jena.model.Resource resource(com.hp.hpl.mesa.rdf.jena.model.Model model, java.lang.String resource)
          Constructs an RDF resource from a string.
static com.hp.hpl.mesa.rdf.jena.model.Resource resource(java.lang.String resource)
          Convenience method using the default model.
static com.hp.hpl.mesa.rdf.jena.model.Resource union(com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource results1, com.hp.hpl.mesa.rdf.jena.model.Resource results2)
          Returns the union of the FindResuls in results1 and results2.
static com.hp.hpl.mesa.rdf.jena.model.Resource union(com.hp.hpl.mesa.rdf.jena.model.Resource results1, com.hp.hpl.mesa.rdf.jena.model.Resource results2)
          Convenience method using the default model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

quiet

public static boolean quiet

loadedModel

public static boolean loadedModel

defaultModel

public static com.hp.hpl.mesa.rdf.jena.model.Model defaultModel
Constructor Detail

TwigJena

public TwigJena()
Method Detail

quiet

public static boolean quiet(boolean newQuiet)
Toggle informative messages.


load

public static com.hp.hpl.mesa.rdf.jena.model.Model load(java.lang.String filename)
Load an RDF model.

If only one model is loaded, it is used as the default and the model parameter can be omitted from other functions. If more than one model is loaded, you must store the model returned from this function and pass it to the other functions explicitly.

Parameters:
filename - The name of the file to load.
Returns:
The model as an external object.

defaultModelWarning

protected static void defaultModelWarning()
Warn the user if there's no default model.


exceptionWarning

protected static void exceptionWarning(java.lang.Exception e)
Tell the user about exceptions.


property

public static com.hp.hpl.mesa.rdf.jena.model.Property property(java.lang.String namespaceUri,
                                                               java.lang.String localName)
Constructs an RDF property.

Parameters:
namespaceUri - The namespace URI of the property.
localName - The local name of the property.
Returns:
The property as an external object.

resource

public static com.hp.hpl.mesa.rdf.jena.model.Resource resource(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                               java.lang.String resource)
Constructs an RDF resource from a string.

Parameters:
model - The external object containing the RDF model to use.
resource - The URI of a resource. If no such resource exists, it will be created.
Returns:
The resource as an external object.

resource

public static com.hp.hpl.mesa.rdf.jena.model.Resource resource(java.lang.String resource)
Convenience method using the default model.

See Also:
resource(Model,String)

find

public static com.hp.hpl.mesa.rdf.jena.model.Resource find(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                           com.hp.hpl.mesa.rdf.jena.model.Property property,
                                                           com.hp.hpl.mesa.rdf.jena.model.Resource rsrc)
Find all the resources in the model that have the specified resource as a value of the specified property.

Parameters:
model - The external object containing the RDF model to use.
property - The external object containing the property
rsrc - The external object containing the resource. If the resource specified is the result of a previous find, then the function will return all the resources in the model that have any of the resources in the find results as a value of the specified property.
Returns:
A FindResults resource containing the resources found

find

public static com.hp.hpl.mesa.rdf.jena.model.Resource find(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                           com.hp.hpl.mesa.rdf.jena.model.Property property,
                                                           java.lang.String literal)
Find all the resources in the model that have the specified literal as a value of the specified property.

Parameters:
model - The external object containing the RDF model to use.
property - The external object containing the property
literal - The literal value for which to search
Returns:
A FindResults resource containing the resources found

find

public static com.hp.hpl.mesa.rdf.jena.model.Resource find(com.hp.hpl.mesa.rdf.jena.model.Property property,
                                                           com.hp.hpl.mesa.rdf.jena.model.Resource rsrc)
Convenience method using the default model.

See Also:
find(Model,Property,Resource)

find

public static com.hp.hpl.mesa.rdf.jena.model.Resource find(com.hp.hpl.mesa.rdf.jena.model.Property property,
                                                           java.lang.String literal)
Convenience method using the default model.

See Also:
find(Model,Property,String)

get

public static com.hp.hpl.mesa.rdf.jena.model.Resource get(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                          com.hp.hpl.mesa.rdf.jena.model.Resource rsrc,
                                                          com.hp.hpl.mesa.rdf.jena.model.Property property)
Find all the nodes in the model that are the values of the specified property on the specified resrc.

Parameters:
model - The external object containing the RDF model to use.
rsrc - The external object containing the resource.
property - The external object containing the property
Returns:
A FindResults resource containing the nodes that are the values of the 'property' on 'rsrc'.

get

public static com.hp.hpl.mesa.rdf.jena.model.Resource get(com.hp.hpl.mesa.rdf.jena.model.Resource rsrc,
                                                          com.hp.hpl.mesa.rdf.jena.model.Property property)
Convenience method using the default model.

See Also:
get(Model,Resource,Property)

filter

public static com.hp.hpl.mesa.rdf.jena.model.Resource filter(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                             com.hp.hpl.mesa.rdf.jena.model.Resource findResults,
                                                             com.hp.hpl.mesa.rdf.jena.model.Property property,
                                                             com.hp.hpl.mesa.rdf.jena.model.Resource rsrc)
Find all the resources in the result set that have the specified resource as a value of the specified property.

Parameters:
model - The external object containing the RDF model to use.
findResults - The external object containing the FindResults of a previous query
property - The external object containing the property
rsrc - The external object containing the resource. If the resource specified is the result of a previous find, then the function will return all the resources in the result set that have any of the resources in the find results as a value of the specified property.
Returns:
A FindResults resource containing the resources found

filter

public static com.hp.hpl.mesa.rdf.jena.model.Resource filter(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                             com.hp.hpl.mesa.rdf.jena.model.Resource findResults,
                                                             com.hp.hpl.mesa.rdf.jena.model.Property property,
                                                             java.lang.String literal)
Find all the resources in the result set that have the specified literal as a value of the specified property.

Parameters:
model - The external object containing the RDF model to use.
findResults - The external object containing the FindResults of a previous query
property - The external object containing the property
literal - The literal value for which to search
Returns:
A FindResults resource containing the resources found

filter

public static com.hp.hpl.mesa.rdf.jena.model.Resource filter(com.hp.hpl.mesa.rdf.jena.model.Resource findResults,
                                                             com.hp.hpl.mesa.rdf.jena.model.Property property,
                                                             com.hp.hpl.mesa.rdf.jena.model.Resource rsrc)
Convenience method using the default model.

See Also:
filter(Model,Resource,Property,Resource)

filter

public static com.hp.hpl.mesa.rdf.jena.model.Resource filter(com.hp.hpl.mesa.rdf.jena.model.Resource findResults,
                                                             com.hp.hpl.mesa.rdf.jena.model.Property property,
                                                             java.lang.String literal)
Convenience method using the default model.

See Also:
filter(Model,Resource,Property,String)

filterNot

public static com.hp.hpl.mesa.rdf.jena.model.Resource filterNot(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                                com.hp.hpl.mesa.rdf.jena.model.Resource findResults,
                                                                com.hp.hpl.mesa.rdf.jena.model.Property property,
                                                                com.hp.hpl.mesa.rdf.jena.model.Resource rsrc)
Find all the resources in the result set that do not have the specified resource as a value of the specified property. This is counter, in some senses, to the RDF world view which is purely additive. For the purpose of this function, you have to imagine that the model is a closed universe.

Parameters:
model - The external object containing the RDF model to use.
findResults - The external object containing the FindResults of a previous query
property - The external object containing the property
rsrc - The external object containing the resource.
Returns:
A FindResults resource containing the resources found

filterNot

public static com.hp.hpl.mesa.rdf.jena.model.Resource filterNot(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                                com.hp.hpl.mesa.rdf.jena.model.Resource findResults,
                                                                com.hp.hpl.mesa.rdf.jena.model.Property property,
                                                                java.lang.String literal)
Find all the resources in the result set that do not have the specified literal as a value of the specified property. This is counter, in some senses, to the RDF world view which is purely additive. For the purpose of this function, you have to imagine that the model is a closed universe.

Parameters:
model - The external object containing the RDF model to use.
findResults - The external object containing the FindResults of a previous query
property - The external object containing the property
literal - The literal value for which to search
Returns:
A FindResults resource containing the resources found

filterNot

public static com.hp.hpl.mesa.rdf.jena.model.Resource filterNot(com.hp.hpl.mesa.rdf.jena.model.Resource findResults,
                                                                com.hp.hpl.mesa.rdf.jena.model.Property property,
                                                                com.hp.hpl.mesa.rdf.jena.model.Resource rsrc)
Convenience method using the default model.

See Also:
filterNot(Model,Resource,Property,Resource)

filterNot

public static com.hp.hpl.mesa.rdf.jena.model.Resource filterNot(com.hp.hpl.mesa.rdf.jena.model.Resource findResults,
                                                                com.hp.hpl.mesa.rdf.jena.model.Property property,
                                                                java.lang.String literal)
Convenience method using the default model.

See Also:
filterNot(Model,Resource,Property,String)

union

public static com.hp.hpl.mesa.rdf.jena.model.Resource union(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                            com.hp.hpl.mesa.rdf.jena.model.Resource results1,
                                                            com.hp.hpl.mesa.rdf.jena.model.Resource results2)
Returns the union of the FindResuls in results1 and results2. Note that where results1 and results2 may contain duplicates, the union will not. Union is considered a set operation.

Parameters:
results1 - An external object containing a FindResults from a previous query
results2 - An external object containing a FindResults from a previous query
Returns:
A FindResults resource containing the union of the two sets.

union

public static com.hp.hpl.mesa.rdf.jena.model.Resource union(com.hp.hpl.mesa.rdf.jena.model.Resource results1,
                                                            com.hp.hpl.mesa.rdf.jena.model.Resource results2)
Convenience method using the default model.

See Also:
union(Model,Resource,Resource)

intersection

public static com.hp.hpl.mesa.rdf.jena.model.Resource intersection(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                                   com.hp.hpl.mesa.rdf.jena.model.Resource results1,
                                                                   com.hp.hpl.mesa.rdf.jena.model.Resource results2)
Returns the intersection of the FindResuls in results1 and results2. Note that where results1 and results2 may contain duplicates, the intersection will not. Intersection is considered a set operation.

Parameters:
results1 - An external object containing a FindResults from a previous query
results2 - An external object containing a FindResults from a previous query
Returns:
A FindResults resource containing the intersection of the two sets.

intersection

public static com.hp.hpl.mesa.rdf.jena.model.Resource intersection(com.hp.hpl.mesa.rdf.jena.model.Resource results1,
                                                                   com.hp.hpl.mesa.rdf.jena.model.Resource results2)
Convenience method using the default model.

See Also:
intersection(Model,Resource,Resource)

difference

public static com.hp.hpl.mesa.rdf.jena.model.Resource difference(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                                 com.hp.hpl.mesa.rdf.jena.model.Resource results1,
                                                                 com.hp.hpl.mesa.rdf.jena.model.Resource results2)
Returns the difference between the FindResuls in results1 and results2. Note that where results1 and results2 may contain duplicates, the difference will not. Difference is considered a set operation.

Parameters:
results1 - An external object containing a FindResults from a previous query
results2 - An external object containing a FindResults from a previous query
Returns:
A FindResults resource containing the difference between results1 and results2. That is, the results that are in results1 but are not in results2.

difference

public static com.hp.hpl.mesa.rdf.jena.model.Resource difference(com.hp.hpl.mesa.rdf.jena.model.Resource results1,
                                                                 com.hp.hpl.mesa.rdf.jena.model.Resource results2)
Convenience method using the default model.

See Also:
difference(Model,Resource,Resource)


Copyright ? 2002, 2003 Norman Walsh. All Rights Reserved.