Class Index | File Index

## Classes

- _global_
- jQuery
- jQuery.rdf
- jQuery.rdf.blank
- jQuery.rdf.databank
- jQuery.rdf.literal
- jQuery.rdf.pattern
- jQuery.rdf.resource
- jQuery.rdf.rule
- jQuery.rdf.ruleset
- jQuery.rdf.triple
- jQuery.typedValue
- jQuery.uri

# Class jQuery.rdf.rule

A jQuery.rdf.rule object represents a rule that can be run over a jQuery.rdf.databank.
Defined in: jquery.rules.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| jQuery.rdf.rule(lhs, rhs, options) Creates a new jQuery.rdf.rule object.

Method Summary
Method Attributes | Method Name and Description
--- | ---
| run(data, options) Runs the rule on the data passed as the first argument.

Class Detail
jQuery.rdf.rule(lhs, rhs, options)

Creates a new jQuery.rdf.rule object. This should be invoked as a method rather than constructed using new.

    $.rdf.rule('?person a foaf:Person', '?person a foaf:Agent', { namespaces: ns });

    var rule = $.rdf.rule(
      ['?person a vcard:VCard',
       '?person vcard:fn ?name'],
      ['?person a foaf:Person',
       '?person foaf:name ?name'],
      { namespaces: ns }
    );

    var rule = $.rdf.rule(
      ['?person a foaf:Person',
       '?person foaf:firstName ?fn'],
      ['?person a vcard:VCard',
       '?person vcard:n _:name',
       '_:name a vcard:Name',
       '_:name vcard:given-name ?fn'],
      { namespaces: ns }
    );

    var rule = $.rdf.rule(
      ['?person foaf:name ?name',
       ['name', /^J.+/]],
     function () { name = this.name },
     { namespaces: ns });

Parameters:
{Object[]} lhs
  The left-hand side of the rule. This can be an array containing multiple conditions, or a single condition on its own. Each condition is one of:
  - A jQuery.rdf.pattern or a string which is interpreted as a jQuery.rdf.pattern, which is used to match triples as with the jQuery.rdf#where method.
  - A function which must return true for the rule to be satisfied. The arguments for the function are as described in the documentation for jQuery.rdf#filter.
  - An array of two items: a variable name and either a regular expression or a value that it matches against (as used in the two arguments to jQuery.rdf#filter).
{Function|String[]} rhs
  The right-hand side of the rule. This can be an array of strings which are interpreted as patterns and used to create new triples when the rule is fired. If the patterns contain references to blank nodes, new blank nodes are created each time the rule is fired. Alternatively, it can be a function which is executed when the rule is fired. The function needs to have the same signature as that used for jQuery.rdf#map.
{Object} options Optional
  Initialisation options for the rules.
{Object} options.namespaces Optional
  An object representing a set of namespace bindings which are stored and used whenever a CURIE is used within the left or right-hand sides of the rule.
{String|jQuery.uri} options.base Optional
  The base URI used to interpret any relative URIs used within the rule.

Returns:
  {jQuery.rdf.rule}

See:
  jQuery.rdf.rule

Method Detail
{jQuery.rdf.rule} run(data, options)
Runs the rule on the data passed as the first argument.

    $.rdf.rule('?person a foaf:Person', '?person a foaf:Agent', { namespaces: ns })
      .run(data);

Parameters:
{jQuery.rdf.databank} data
  A databank containing data to be reasoned over and added to.
{Object} options Optional
{Integer} options.limit Optional, Default: 50
  The rule isArray generally run over the jQuery.rdf.databank until it stops growing. In some situations, notably when creating blank nodes, this can lead to an infinite loop. The limit option indicates the maximum number of times the rule will be run before halting.

Returns:
  {jQuery.rdf.rule} Returns this rule.

See:
  jQuery.rdf.ruleset#run
  jQuery.rdf#reason
  jQuery.rdf.databank#reason

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Feb 04 2011 16:40:11 GMT+0100 (MEZ)