Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Table of Contents

XsltCrosswalk.zip  

Configurable XSLT-driven Crosswalk

This page describes a powerful crosswalk plugin which is part of
the of the Crosswalk Plugins family. The code was added in DSpace 1.4.

The XSLT Crosswalk classes let you can create many different crosswalks between
DSpace between DSpace internal data and any XML format. Just add another XSLT (XSL
transformationXSL transformation) stylesheet to the configuration to create a new crosswalk.
Each  Each stylesheet appears as a new plugin name, although they all
share all share the same plugin implementation class.

The XML transformation must produce (for submission) or expect (for
disseminationfor dissemination) a document in DIM - DSpace Intermediate Metadata format.
See  See DSpace Intermediate Metadata for details.

...

A submission crosswalk is described by a DSpace configuration key like:

...

Code Block
crosswalk.submission.
'''pluginName'''
<pluginName>.stylesheet = 
'''path'''
<path>

The

...

pluginName

...

is the plugin name given to the Plugin Manager,
and the

Code Block
'''path'''

 and the path value is the pathname (relative to

Code Block
$\{dspace.dir\}/config

)
of to [dspace]/config/) of the crosswalk stylesheet, e.g.

...

 "mycrosswalk.xslt".

For example, this configures a crosswalk named "LOM" using a stylesheetstylesheet in in

Code Block
[dspace]/config/crosswalks/s-lom.xsl

(under the DSpace "home" directory):

Panel
Code Block
crosswalk.submission.LOM.stylesheet = crosswalks/s-lom.xsl

Configuring a Dissemination Crosswalk

A dissemination crosswalk is described by a DSpace configuration key like

Panel
Code Block
crosswalk.dissemination.
'''pluginName'''
<pluginName>.stylesheet = 
'''path'''
<path>

The pluginName is the plugin name given to the Plugin Manager,
and  and the pathvalue is the pathname (relative to

Code Block
$\{dspace.dir\}/config

)
of to [dspace]/config/) of the crosswalk stylesheet, e.g. "

...

mycrosswalk.xslt

...

"

The disseminator also needs to be configured with all of the XML Namespaces
that Namespaces that might appear in its output, including the prefix and URI for each one.
It also needs a value to include in the

...

the schemaLocation

...

attribute.
These  These are configured on additional properties in the DSpace Configuration, i.e.:

Code Block

 crosswalk.dissemination.'''pluginName'''<pluginName>.namespace.'''prefix'''<prefix> = '''namespace-URI'''
 <namespace-URI>
crosswalk.dissemination.'''pluginName'''<pluginName>.schemaLocation = '''Schema<Schema Location string'''string>
 crosswalk.dissemination.'''pluginName'''<pluginName>.preferList = '''boolean'''<boolean>
Code Block

preferList

...

indicates  indicates whether the output should be a list of elements
elements (like the Dublin Core XML formats) or a single element. All it does is
change is change the value returned by the plugin's

...

preferList()

...

method.
The  The default, which is correct in most cases, is

...

is false

...

.

For example, a plugin named

...

named MODS

...

:

Code Block

 crosswalk.dissemination.MODS.stylesheet = crosswalks/mods_out.xsl
 crosswalk.dissemination.MODS.namespace.mods = <nowiki>httphttp://www.loc.gov/mods/v3</nowiki>v3
 crosswalk.dissemination.MODS.schemaLocation = <nowiki>httphttp://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd</nowiki>xsd

You can configure two (or more) names to point to the same crosswalk,
just  just add two configuration entries with the same path, e.g.

Code Block

 crosswalk.submission.MyFormat.stylesheet = crosswalks/myformat.xslt
 crosswalk.submission.almost_DC.stylesheet = crosswalks/myformat.xslt

Testing

...

Dissemination Crosswalks

With DSpace up to version 1.8.2 you You can test dissemination stylesheets very easily by configuring an
OAIan OAI-PMH output format in the OAI configuration file, named the same as
your as your dissemination plugin and implemented by

...

by org.dspace.app.oai.PluginCrosswalk

...

. Then just request a document's
metadata s metadata in the given format to see what the disseminator produces.

The new OAI in DSpace 3.0 uses the "xoai" format as input so stylesheets expecting the "DIM" format do not apply. From DSpace 3.1 on it is possible to test dissemination crosswalks by using a command line utility. To invoke the dissemination crosswalk tester, run the class XSLTDisseminationCrosswalk as follows:

Code Block
[dspace]/bin/dspace dsrun org.dspace.content.crosswalk.XSLTDisseminationCrosswalk <plugin name> <handle> [output-file]

For example, you can test the marc plugin on the handle 123456789/3 with:

Code Block
[dspace]/bin/dspace dsrun org.dspace.content.crosswalk.XSLTDisseminationCrosswalk marc 12345678/3

Informations from the script will be printed to stderr while the XML output of the dissemination crosswalk will be printed to stdout. You can give a third parameter containing a filename to write the output into a file, but be careful: the file will be overwritten if it exists.

Testing Ingestion Crosswalks

To help you test submission stylesheets, the To help you
test submission stylesheets,
the XSLT ingestion crosswalk includes a command-line utility,
since  since otherwise you would have to try
ingesting try ingesting a new Item for each test. The utility transforms a metadata
document you supply in a file and returns the resulting DIM.

To invoke the crosswalk tester, run the class as follows:

Code Block

 [dspace]/bin/dspace dsrun org.dspace.content.crosswalk.XSLTIngestionCrosswalk '''plugin input-file'''<plugin name> <input-file>

For example, you can test the

...

LOM

...

plugin  plugin on the file

...

file test.xml

...

with:

Code Block

 [dspace]/bin/dspace dsrun org.dspace.content.crosswalk.XSLTIngestionCrosswalk LOM test.xml

Add the

...

-l

...

option  option to pass the submission stylesheet a list of elements
instead elements instead of a whole document, as if the List form of the

...

the ingest()

...

method
had  method had been called, e.g.:

Code Block

 [dspace]/bin/dspace dsrun org.dspace.content.crosswalk.XSLTIngestionCrosswalk -l LOM test.xml

In any case, the output will be prettyprinted XML of the DIM document
returned document returned by the stylesheet.

Usage

You must use the

...

PluginManager

...

to instantiate an XSLT crosswalk plugin, e.g.

Code Block

 IngestionCrosswalk xwalk = PluginManager.getPlugin(IngestionCrosswalk.class, "LOM");

Since there is significant overhead in reading the properties file to
configure to configure the crosswalk, and a crosswalk instance may be used any number
of number of times, we recommend caching one instance of the crosswalk for each
alias each alias and simply reusing those instances. The

Code Block
PluginManager

The PluginManager does this automatically.

Auto-reloading

Code Block
PluginManager

This plugin will automatically reload any XSL stylesheet that
was that was modified since it was last loaded. This lets you edit and test
stylesheets test stylesheets without restarting DSpace.