com.nwalsh.xslt.saxon
Class RDFTwig

java.lang.Object
  |
  +--com.nwalsh.xslt.TwigJena
        |
        +--com.nwalsh.xslt.saxon.RDFTwig

public class RDFTwig
extends TwigJena

Saxon extensions to access portions of an RDF graph.

Copyright (C) 2002, 2003 Norman Walsh.

This class provides a Saxon extension to access nodes in an RDF graph.

The underlying RDF model is accessed with Jena.

Change Log:

1.0

Initial release.

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

Field Summary
 
Fields inherited from class com.nwalsh.xslt.TwigJena
defaultModel, loadedModel, quiet
 
Constructor Summary
RDFTwig()
           
 
Method Summary
static org.w3c.dom.Element branch(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource rsrc, int depth)
          Returns a tree representation of a resource from the model.
static org.w3c.dom.Element branch(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Resource rsrc, int depth)
          Convenience method using the default model.
static org.w3c.dom.Element dftwig(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource rsrc, int depth)
          Returns a tree representation of a resource from the model.
static org.w3c.dom.Element leaf(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Model model, com.icl.saxon.expr.NodeSetValue ns)
          Convenience method for building twigs of depth zero from a node set.
static org.w3c.dom.Element leaf(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource resource)
          Convenience method for building twigs of depth zero.
static org.w3c.dom.Element leaf(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Model model, java.lang.String resource)
          Convenience method for building twigs of depth zero.
static org.w3c.dom.Element leaf(com.icl.saxon.Context context, com.icl.saxon.expr.NodeSetValue ns)
          Convenience method for building twigs of depth zero from a node set with the default model.
static org.w3c.dom.Element leaf(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Resource resource)
          Convenience method for building twigs of depth zero with the default model.
static org.w3c.dom.Element leaf(com.icl.saxon.Context context, java.lang.String resource)
          Convenience method for building twigs of depth zero with the default model.
static com.hp.hpl.mesa.rdf.jena.model.Resource resource(com.hp.hpl.mesa.rdf.jena.model.Model model, com.icl.saxon.expr.NodeSetValue ns)
          Returns the RDF resource associated with a node.
static com.hp.hpl.mesa.rdf.jena.model.Resource resource(com.icl.saxon.expr.NodeSetValue ns)
          Convenience method using the default model.
static com.hp.hpl.mesa.rdf.jena.model.Resource resources(com.hp.hpl.mesa.rdf.jena.model.Model model, com.icl.saxon.expr.NodeSetValue ns)
          Returns the RDF resources associated with a set of nodes.
static com.hp.hpl.mesa.rdf.jena.model.Resource resources(com.icl.saxon.expr.NodeSetValue ns)
          Convenience method using the default model.
static org.w3c.dom.Element twig(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Model model, com.icl.saxon.expr.NodeSetValue ns)
          Convenience method for building twigs of infinite depth from a node set.
static org.w3c.dom.Element twig(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Model model, com.icl.saxon.expr.NodeSetValue ns, int depth)
          Convenience method for building twigs from a node set.
static org.w3c.dom.Element twig(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource resource)
          Convenience method for building twigs of infinite depth.
static org.w3c.dom.Element twig(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Model model, com.hp.hpl.mesa.rdf.jena.model.Resource rsrc, int depth)
          Returns a tree representation of a resource from the model.
static org.w3c.dom.Element twig(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Model model, java.lang.String resource)
          Convenience method for building twigs of infinite depth.
static org.w3c.dom.Element twig(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Model model, java.lang.String resource, int depth)
          Convenience method for building twigs.
static org.w3c.dom.Element twig(com.icl.saxon.Context context, com.icl.saxon.expr.NodeSetValue ns)
          Convenience method for building twigs of infinite depth from a node set with the default model.
static org.w3c.dom.Element twig(com.icl.saxon.Context context, com.icl.saxon.expr.NodeSetValue ns, int depth)
          Convenience method for building twigs from a node set with the default model.
static org.w3c.dom.Element twig(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Resource resource)
          Convenience method for building twigs of infinite depth with the default model.
static org.w3c.dom.Element twig(com.icl.saxon.Context context, com.hp.hpl.mesa.rdf.jena.model.Resource resource, int depth)
          Convenience method for building twigs with the default model.
static org.w3c.dom.Element twig(com.icl.saxon.Context context, java.lang.String resource)
          Convenience method for building twigs of infinite depth with the default model.
static org.w3c.dom.Element twig(com.icl.saxon.Context context, java.lang.String resource, int depth)
          Convenience method for building twigs with the default model.
 
Methods inherited from class com.nwalsh.xslt.TwigJena
defaultModelWarning, difference, difference, exceptionWarning, filter, filter, filter, filter, filterNot, filterNot, filterNot, filterNot, find, find, find, find, get, get, intersection, intersection, load, property, quiet, resource, resource, union, union
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RDFTwig

public RDFTwig()
Method Detail

resource

public static com.hp.hpl.mesa.rdf.jena.model.Resource resource(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                               com.icl.saxon.expr.NodeSetValue ns)
Returns the RDF resource associated with a node.

Returns one of the following, in this order:

Parameters:
model - The external object containing the RDF model to use.
ns - A node set containing a node from some source tree.
Returns:
The resource as an external object.
See Also:
resources(Model,NodeSetValue)

resource

public static com.hp.hpl.mesa.rdf.jena.model.Resource resource(com.icl.saxon.expr.NodeSetValue ns)
Convenience method using the default model.

See Also:
resource(Model,NodeSetValue)

resources

public static com.hp.hpl.mesa.rdf.jena.model.Resource resources(com.hp.hpl.mesa.rdf.jena.model.Model model,
                                                                com.icl.saxon.expr.NodeSetValue ns)
Returns the RDF resources associated with a set of nodes.

Returns a set of resources (a FindResult) containing all of the resources identified by the nodes in the node set. For each node in the node set, one of the following is added to the result set:

Parameters:
model - The external object containing the RDF model to use.
ns - A node set containing a set of nodes from some source tree.
Returns:
The resource as an external object.
See Also:
resource(Model,NodeSetValue)

resources

public static com.hp.hpl.mesa.rdf.jena.model.Resource resources(com.icl.saxon.expr.NodeSetValue ns)
Convenience method using the default model.

See Also:
resources(Model,NodeSetValue)

twig

public static org.w3c.dom.Element twig(com.icl.saxon.Context context,
                                       com.hp.hpl.mesa.rdf.jena.model.Model model,
                                       com.hp.hpl.mesa.rdf.jena.model.Resource rsrc,
                                       int depth)
Returns a tree representation of a resource from the model.

This method builds a tree describing part of an RDF graph. The tree is constructed by performing a breadth-first search of the model, finding all of the resources and literals that can be reached by following properties from the starting resource.

The graph is turned into a tree by removing cycles. Cycles are removed by following the property of each resource only the first time it is encountered. If the same resource is encountered again, it is added to the tree as an empty node with an rdf:resource attribute.

If the depth is zero, no properties are followed, they will all be empty nodes with rdf:resource attributes. If the depth is greater than zero, the tree will be at most that deep. If the depth is less than zero, the depth is unbounded during construction.

Parameters:
context - The Saxon context object.
model - The model.
rsrc - The starting resource.
depth - The maximum depth of the tree.
Returns:
The root element (always an rdf:Description) of the tree.

branch

public static org.w3c.dom.Element branch(com.icl.saxon.Context context,
                                         com.hp.hpl.mesa.rdf.jena.model.Model model,
                                         com.hp.hpl.mesa.rdf.jena.model.Resource rsrc,
                                         int depth)
Returns a tree representation of a resource from the model.

This method builds a tree describing part of an RDF graph. The tree is constructed by performing a breadth-first search of the model, finding all of the resources and literals that can be reached by following properties from the starting resource.

The graph is turned into a tree by removing cycles. Unlike twig(), branch() will expand resources more than once. It only stops expanding when it encounters a cycle in a given branch. (In other words, it will avoid cyclic expansion but not duplicate expansion.) This can lead to much larger graphs.

If the depth is zero, no properties are followed, they will all be empty nodes with rdf:resource attributes. If the depth is greater than zero, the tree will be at most that deep. If the depth is less than zero, the depth is unbounded during construction.

Parameters:
context - The Saxon context object.
model - The model.
rsrc - The starting resource.
depth - The maximum depth of the tree.
Returns:
The root element (always an rdf:Description) of the tree.

branch

public static org.w3c.dom.Element branch(com.icl.saxon.Context context,
                                         com.hp.hpl.mesa.rdf.jena.model.Resource rsrc,
                                         int depth)
Convenience method using the default model.

See Also:
branch(Context,Model,Resource,int)

dftwig

public static org.w3c.dom.Element dftwig(com.icl.saxon.Context context,
                                         com.hp.hpl.mesa.rdf.jena.model.Model model,
                                         com.hp.hpl.mesa.rdf.jena.model.Resource rsrc,
                                         int depth)
Returns a tree representation of a resource from the model.

This method builds a tree describing part of an RDF graph. The tree is constructed by performing a depth-first search of the model, finding all of the resources and literals that can be reached by following properties from the starting resource.

The graph is turned into a tree by removing cycles. Cycles are removed by following the properties of each resource only the first time it is encountered. If the same resource is encountered again, it is added to the tree as an empty node with an rdf:resource attribute.

If the depth is zero, no properties are followed, they will all be empty nodes with rdf:resource attributes. If the depth is greater than zero, the tree will be at most that deep. If the depth is less than zero, the depth is unbounded during construction.

Note: there is no dfbranch() method as it would be the same as branch().

Parameters:
context - The Saxon context object.
model - The model.
rsrc - The starting resource.
depth - The maximum depth of the tree.
Returns:
The root element (always an rdf:Description) of the tree.

twig

public static org.w3c.dom.Element twig(com.icl.saxon.Context context,
                                       com.hp.hpl.mesa.rdf.jena.model.Model model,
                                       java.lang.String resource,
                                       int depth)
Convenience method for building twigs.

See Also:
twig(Context,Model,Resource,int)

twig

public static org.w3c.dom.Element twig(com.icl.saxon.Context context,
                                       com.hp.hpl.mesa.rdf.jena.model.Resource resource,
                                       int depth)
Convenience method for building twigs with the default model.

See Also:
twig(Context,Model,Resource,int)

twig

public static org.w3c.dom.Element twig(com.icl.saxon.Context context,
                                       java.lang.String resource,
                                       int depth)
Convenience method for building twigs with the default model.

See Also:
twig(Context,Model,Resource,int)

twig

public static org.w3c.dom.Element twig(com.icl.saxon.Context context,
                                       com.hp.hpl.mesa.rdf.jena.model.Model model,
                                       com.hp.hpl.mesa.rdf.jena.model.Resource resource)
Convenience method for building twigs of infinite depth.

See Also:
twig(Context,Model,Resource,int)

twig

public static org.w3c.dom.Element twig(com.icl.saxon.Context context,
                                       com.hp.hpl.mesa.rdf.jena.model.Model model,
                                       java.lang.String resource)
Convenience method for building twigs of infinite depth.

See Also:
twig(Context,Model,Resource,int)

leaf

public static org.w3c.dom.Element leaf(com.icl.saxon.Context context,
                                       com.hp.hpl.mesa.rdf.jena.model.Model model,
                                       com.hp.hpl.mesa.rdf.jena.model.Resource resource)
Convenience method for building twigs of depth zero.

See Also:
twig(Context,Model,Resource,int)

leaf

public static org.w3c.dom.Element leaf(com.icl.saxon.Context context,
                                       com.hp.hpl.mesa.rdf.jena.model.Model model,
                                       java.lang.String resource)
Convenience method for building twigs of depth zero.

See Also:
twig(Context,Model,Resource,int)

leaf

public static org.w3c.dom.Element leaf(com.icl.saxon.Context context,
                                       com.hp.hpl.mesa.rdf.jena.model.Resource resource)
Convenience method for building twigs of depth zero with the default model.

See Also:
twig(Context,Model,Resource,int)

leaf

public static org.w3c.dom.Element leaf(com.icl.saxon.Context context,
                                       java.lang.String resource)
Convenience method for building twigs of depth zero with the default model.

See Also:
twig(Context,Model,Resource,int)

leaf

public static org.w3c.dom.Element leaf(com.icl.saxon.Context context,
                                       com.icl.saxon.expr.NodeSetValue ns)
Convenience method for building twigs of depth zero from a node set with the default model.

See Also:
twig(Context,Model,Resource,int)

leaf

public static org.w3c.dom.Element leaf(com.icl.saxon.Context context,
                                       com.hp.hpl.mesa.rdf.jena.model.Model model,
                                       com.icl.saxon.expr.NodeSetValue ns)
Convenience method for building twigs of depth zero from a node set.

See Also:
twig(Context,Model,Resource,int)

twig

public static org.w3c.dom.Element twig(com.icl.saxon.Context context,
                                       com.icl.saxon.expr.NodeSetValue ns)
Convenience method for building twigs of infinite depth from a node set with the default model.

See Also:
twig(Context,Model,Resource,int)

twig

public static org.w3c.dom.Element twig(com.icl.saxon.Context context,
                                       com.hp.hpl.mesa.rdf.jena.model.Resource resource)
Convenience method for building twigs of infinite depth with the default model.

See Also:
twig(Context,Model,Resource,int)

twig

public static org.w3c.dom.Element twig(com.icl.saxon.Context context,
                                       java.lang.String resource)
Convenience method for building twigs of infinite depth with the default model.

See Also:
twig(Context,Model,Resource,int)

twig

public static org.w3c.dom.Element twig(com.icl.saxon.Context context,
                                       com.icl.saxon.expr.NodeSetValue ns,
                                       int depth)
Convenience method for building twigs from a node set with the default model.

See Also:
twig(Context,Model,Resource,int)

twig

public static org.w3c.dom.Element twig(com.icl.saxon.Context context,
                                       com.hp.hpl.mesa.rdf.jena.model.Model model,
                                       com.icl.saxon.expr.NodeSetValue ns)
Convenience method for building twigs of infinite depth from a node set.

See Also:
twig(Context,Model,Resource,int)

twig

public static org.w3c.dom.Element twig(com.icl.saxon.Context context,
                                       com.hp.hpl.mesa.rdf.jena.model.Model model,
                                       com.icl.saxon.expr.NodeSetValue ns,
                                       int depth)
Convenience method for building twigs from a node set.

See Also:
twig(Context,Model,Resource,int)


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