|
1 |
| -# bibframe2marc |
| 1 | +# bibframe2marc-xsl |
2 | 2 |
|
3 |
| -Conversion from [BIBFRAME 2.0](http://www.loc.gov/bibframe/) to [MARC21](http://www.loc.gov/marc/). |
| 3 | +XSLT 1.0 conversion from RDF/XML [BIBFRAME 2.0](http://www.loc.gov/bibframe/) to [MARCXML](http://www.loc.gov/marcxml/). |
4 | 4 |
|
5 |
| -## Background: What goes into a MARC record |
| 5 | +## Introduction |
6 | 6 |
|
7 |
| -MARC21 bibliographic records can be constructed from an RDF graph with the following characteristics: |
| 7 | +_bibframe2marc-xsl_ consists of an [XSLT 1.0 stylesheet](src/compile.xsl) that takes a set of [XML rules](rules) and compiles them into another stylesheet (bibframe2marc.xsl). The conversion stylesheet takes an RDF/XML document representing a single BIBFRAME 2.0 description and converts it to a MARCXML document. The bibframe2marc.xsl stylesheet can be used as part of a conversion pipeline, as for example with the [Biblio::BF2MARC](https://github.com/lcnetdev/Biblio-BF2MARC) perl library. |
8 | 8 |
|
9 |
| -* One or more `bf:Instance` subjects with one or more `bf:instanceOf` predicates with a `bf:Work` object. |
10 |
| - * The `bf:instanceOf` predicate can also be calculated as the inverse of a `bf:hasInstance` predicate of a `bf:Work` subject. |
11 |
| - * Each `bf:Instance` to `bf:Work` relationship can generate a new MARC record. |
12 |
| - * A single `bf:Work` can be related to multiple `bf:Instance` nodes. The combination of the predicates of the `bf:Work` and each of the `bf:Instance` nodes can be used to construct multiple unique MARC21 bibliographic records. |
13 |
| - * Series and linking relationships (e.g. `bf:otherPhysicalFormat`, `bf:reproductionOf`) can be used to infer whether or not a unique MARC21 bibliographic record should be constructed. |
14 |
| - * A single `bf:Instance` can be related to multiple `bf:Work` nodes, but in general this _should not_ result in the construction of multiple unique MARC21 bibliographic records. |
15 |
| - * Series and linking relationships should be used to infer which `bf:Work` node should be used in the construction of the record. |
16 |
| - * If a "primary" `bf:Work` node can not be inferred, multiple records will be constructed. |
| 9 | +## Dependencies |
17 | 10 |
|
18 |
| -An RDF graph with these characteristics is referred to as a BIBFRAME "description" for simplicity's sake. |
| 11 | +### Build dependencies |
19 | 12 |
|
20 |
| -This converter takes BIBFRAME descriptions and transforms them into MARC21 records. |
| 13 | +* [libxslt](http://xmlsoft.org/XSLT) -- specifically `xsltproc` -- is used by the root level `Makefile` to construct the `bibframe2marc.xsl` conversion stylesheet from the rules in the [rules](rules) subdirectory. Any XSLT 1.0 processor should be able to build the conversion stylesheet. |
21 | 14 |
|
22 |
| -## Notes on design |
| 15 | +* [XSpec](https://github.com/xspec/xspec) is the test framework for both the rules compiler and the conversion spreadsheet. It is used by the root level `Makefile` for the `test` targets. |
23 | 16 |
|
24 |
| -### Conversion wrapper |
| 17 | +* A Java JRE and the Saxon XSLT and XQuery processor are required by XSpec. For more information, see the installation pages on the [XSpec wiki](https://github.com/xspec/xspec/wiki). |
25 | 18 |
|
26 |
| -* The wrapper script takes an RDF graph of BIBFRAME descriptions and attempts to coerce it into a set of RDF/XML documents with 2 nodes: |
27 |
| - * `<bf:Instance>` |
28 |
| - * `<bf:Work>` |
29 |
| -* These nodes refer to each other through the `bf:instanceOf` and `bf:hasInstance` predicates. |
30 |
| -* Objects are dereferenced, so that all the required data is in the RDF/XML documents |
31 |
| -* The wrapper script passes the RDF/XML documents to an XSLT stylesheet for transformation to MARCXML (one at a time). |
32 |
| -* The wrapper script returns a MARC21 collection of bibliographic records in MARCXML. |
| 19 | +## Usage |
33 | 20 |
|
34 |
| -### XSLT conversion |
| 21 | +### Building |
35 | 22 |
|
36 |
| -* The XSLT conversion consists of a rules file (in a custom XML format), a stylesheet to transform the rules file into an XSLT stylesheet for use in the wrapper script, and a set of [Xspec](https://github.com/xspec) tests to describe and validate the conversion. |
| 23 | +`make` in the root level of the working directory will create the `bibframe2marc.xsl` conversion stylesheet from the rules in the `rules` subdirectory. |
| 24 | + |
| 25 | +### Using the generated conversion stylesheet (bibframe2marc.xsl) |
| 26 | + |
| 27 | +The `bibframe2marc.xsl` conversion stylesheet is an XSLT 1.0 application that converts a striped RDF/XML document containing a single BIBFRAME 2.0 "description" (defined as an RDF graph composed of two top level nodes that refer to each other, one `bf:Instance` node and one `bf:Work` node) into a MARCXML document. It can be invoked as a standalone application using an XSLT 1.0 processor such as `xsltproc`, or it can be embedded in another application using a library such as `libxslt` for processing, as with the [Biblio::BF2MARC](https://github.com/lcnetdev/Biblio-BF2MARC) perl library. |
| 28 | + |
| 29 | +For more information about what consitutes a BIBFRAME description, see the [design notes](doc/design.md). |
| 30 | + |
| 31 | +The converions stylesheet takes the following parameters: |
| 32 | + |
| 33 | +* `pRecordId` -- an internal system record ID for use (for example) in a MARC 001 control field. If `pRecordId` is not provided, the conversion will use the `generate-id()` function to generate a record ID. |
| 34 | + |
| 35 | +* `pGenerationTimestamp` -- a timestamp for the conversion. If it is not provided, and if the `date:date-time()` function is available, it will be created from the value of `date:date-time()`. |
| 36 | + |
| 37 | +### Using the compiler stylesheet (src/compile.xsl) |
| 38 | + |
| 39 | +The conversion stylesheet is generated from the rules in the `rules` subdirectory by the compiler stylesheet `src/compile.xsl`. You can adapt the sample conversion provided to your own needs, or create your own conversion rules. For more information, see the [conversion rules documentation](doc/rules.md). |
| 40 | + |
| 41 | +To build a conversion stylesheet from a rules file, you can just run the compiler stylesheet with an XSLT 1.0 processor. For example, using `xsltproc`: |
| 42 | + |
| 43 | +``` |
| 44 | +xsltproc src/compile.xsl rules.xml > bibframe2marc.xsl |
| 45 | +``` |
| 46 | + |
| 47 | +### Tests |
| 48 | + |
| 49 | +The compiler stylesheet has XSpec tests written for it that can be run with `make test_compile` (assuming that XSpec is installed and configured). The tests are in the `tests` subdirectory. |
| 50 | + |
| 51 | +In addition, the rules in the `rules` subdirectory can be tested using XSpec with `make test_rules`. Rules tests are in the `rules/tests` subdirectory. |
| 52 | + |
| 53 | +The `test` target of the Makefile runs both `test_compile` and `test_rules`. |
| 54 | + |
| 55 | +## TODO |
| 56 | + |
| 57 | +* A formal XML schema for the conversion rules still needs to be written |
37 | 58 |
|
38 | 59 | ## Known issues
|
39 | 60 |
|
40 |
| -* The rules compiler in `xsl/src/compile.xsl` uses the `xsl:namespace-alias` element of XSLT to allow for generating a conversion stylesheet. The behavior of this element differs depending on your XSLT processor. libxslt (xsltproc) uses the same namespace prefix in the source stylesheet as the namespace prefix in the output stylesheet, switching the namespace underneath. The Saxon XSLT processor switches out both the namespace prefix and the namespace itself. This results in slightly different output stylesheets -- but the actual BIBFRAME to MARC transformation is exactly the same. `compile.xsl` has been written to work most smoothly with `xsltproc`. |
| 61 | +* The rules compiler uses the `xsl:namespace-alias` element of XSLT to allow for generating a conversion stylesheet. The behavior of this element differs depending on your XSLT processor. libxslt (xsltproc) uses the same namespace prefix in the source stylesheet as the namespace prefix in the output stylesheet, switching the namespace underneath. The Saxon XSLT processor switches out both the namespace prefix and the namespace itself. This results in slightly different output stylesheets -- but the actual BIBFRAME to MARC transformation is exactly the same. `compile.xsl` has been written to work most smoothly with `xsltproc`. |
41 | 62 |
|
42 | 63 | ## See also
|
43 | 64 |
|
| 65 | +* [Issue tracker](https://github.com/lcnetdev/bibframe2marc-xsl/issues) on GitHub |
| 66 | +* [Conversion rules documentation](doc/rules.md) |
| 67 | +* [Design notes](doc/design.md) |
| 68 | +* [Biblio::BF2MARC](https://github.com/lcnetdev/Biblio-BF2MARC) -- a perl library that uses _bibframe2marc-xsl_ for BIBFRAME to MARC conversion |
44 | 69 | * The [Bibliographic Framework Initiative](http://www.loc.gov/bibframe/) at the Library of Congress
|
45 |
| -* The MARC21 to BIBFRAME conversion tool ([marc2bibframe2](https://github.com/lcnetdev/marc2bibframe2)) |
| 70 | +* The MARC to BIBFRAME conversion tool ([marc2bibframe2](https://github.com/lcnetdev/marc2bibframe2)) |
0 commit comments