Passage Lookup


Passage lookup

The bulk of the code is stored in the JSwordPassageServiceImpl and STEP's various stylesheets (e.g. default.xsl). The process can be broken down inot 3 layers:

  • Stylesheets
  • Java code
  • Client-side requests

Stylesheets

Stylesheets are invoked from Java with a given OSIS fragment. The Java code also passes in a certain number of parameters. These parameters can be simple flags to inform the stylesheets which display options are turned on (e.g. Red Letter). Parameters can also be Java objects that will help generate the output HTML. These helpers are standard Java objects.

There is currently much repetition in the stylesheet, mainly to support red-lettering. This should eventually be refactored into a simple stylesheet.

Using Java from a stylesheet

The interlinear and color coding options (as well as others) depend on external Java objects. For access to Java objects, a definition in the document root is required:

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:jsword="http://xml.apache.org/xalan/java"
xmlns:morph="xalan://com.tyndalehouse.step.core.service.impl.MorphologyServiceImpl"
xmlns:vocab="xalan://com.tyndalehouse.step.core.service.impl.VocabularyServiceImpl"
extension-element-prefixes="jsword morph vocab">

The above fragment creates a namespace for jsword that maps to the entire Java collection. The morph and vocab namespaces map to specific Java objects.

Static methods

In order to call a static method, one uses this namespace and the method name, separated by a colon:

jsword:com.tyndalehouse.step.core.utils.StringUtils.containsAlphaNumeric(normalize-space(.))


The above calls containsAlphaNumeric method from the StringUtils class.

Instance methods

For instance methods, the first argument is the java instance

jsword:getVersification($v11nf, $v11n)
jsword:getColorClass($colorCodingProvider, @morph)

In both cases above, the first argument is an instance of the object containing the method.

Instances of Java objects

Instances of Java objects can be created in the stylesheet itself as is the case for the Interlinear Provider (the Java code that obtains the various verse fragments from every version being interlineared).

<xsl:variable name="interlinearProvider" select="jsword:com.tyndalehouse.step.core.xsl.impl.MultiInterlinearProviderImpl.new(string($interlinearVersion), string($interlinearReference))" />


A Java instance can also be passed in. If the object is supposed to be a singleton such as a service with no state, this is preferred. This is the case of the Morphology Provider, Color Coding Provider, Vocab Provider, etc.

<xsl:param name="morphologyProvider" />
<xsl:param name="vocabProvider" />
<xsl:param name="colorCodingProvider" />

(Note: these are now parameter declarations not variable as in the previous example)

In JSwordPassageServiceImpl, prior to calling the stylesheet, these parameters are set. Specific examples can be found in:

  • setOptions()
  • setInterleavingOptions()
  • setInterlinearOptions()

The names of these parameters are often taken from the LookupOption.xsltParameterName field.