Skip to content

Commit 0dd3ea9

Browse files
authored
Reorganize as standalone XSLT app
Organize as standalone application. Update documentation.
1 parent 7617ec2 commit 0dd3ea9

31 files changed

+95
-34
lines changed

.gitignore

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
xsl/bibframe2marc.xsl
2-
xsl/rules.xml
3-
xsl/test/xspec/*
4-
xsl/rules/test/xspec/*
5-
xsl/rules/test/tests/xspec/*
1+
bibframe2marc.xsl
2+
rules.xml
3+
test/xspec/*
4+
rules/test/xspec/*
5+
rules/test/tests/xspec/*

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ env:
1717
- XSPEC=/tmp/xspec/bin/xspec.sh
1818
- SAXON_CP=/usr/share/java/Saxon-HE.jar
1919

20-
script: "cd xsl && make test XSPEC=$XSPEC"
20+
script: "make test XSPEC=$XSPEC"

xsl/Makefile Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
.PHONY : test_compile test_rules test check clean distclean
1+
.PHONY : all test_compile test_rules test check clean distclean
22

33
XSLTPROC = xsltproc
44
XSPEC = xspec.sh
55

66
bibframe2marc.xsl : rules.xml
77
$(XSLTPROC) src/compile.xsl rules.xml > bibframe2marc.xsl
88

9+
all : bibframe2marc.xsl test
10+
911
rules.xml : $(shell find rules)
1012
./buildrules.sh
1113

README.md

+52-27
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,70 @@
1-
# bibframe2marc
1+
# bibframe2marc-xsl
22

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/).
44

5-
## Background: What goes into a MARC record
5+
## Introduction
66

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.
88

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
1710

18-
An RDF graph with these characteristics is referred to as a BIBFRAME "description" for simplicity's sake.
11+
### Build dependencies
1912

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.
2114

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.
2316

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).
2518

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
3320

34-
### XSLT conversion
21+
### Building
3522

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
3758

3859
## Known issues
3960

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`.
4162

4263
## See also
4364

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
4469
* 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))

xsl/buildrules.sh buildrules.sh

File renamed without changes.

doc/design.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# bibframe2marc-xsl design notes
2+
3+
_bibframe2marc-xsl_ is designed to be part of a conversion pipeline for converting BIBFRAME RDF descriptions to MARC records. By limiting the scope of the conversion to striped RDF/XML to MARCXML, the main intellectual work of specifying the conversion can be separated from all the mechanics of RDF dereferencing and inference and MARC format conversion, leaving those tasks to a wrapper application.
4+
5+
The schema for constructing conversion rules (see [rules.md](rules.md)) is designed to allow for specifying a conversion based on XPath matching of the RDF/XML document.
6+
7+
## Background: What goes into a MARC record
8+
9+
MARC21 bibliographic records can be constructed from an RDF graph with the following characteristics:
10+
11+
* One or more `bf:Instance` subjects with one or more `bf:instanceOf` predicates with a `bf:Work` object.
12+
* The `bf:instanceOf` predicate can also be calculated as the inverse of a `bf:hasInstance` predicate of a `bf:Work` subject.
13+
* Each `bf:Instance` to `bf:Work` relationship can generate a new MARC record.
14+
* 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.
15+
* 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.
16+
* 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.
17+
* Series and linking relationships should be used to infer which `bf:Work` node should be used in the construction of the record.
18+
* If a "primary" `bf:Work` node can not be inferred, multiple records will be constructed.
19+
20+
An RDF graph with these characteristics is referred to as a BIBFRAME "description" for simplicity's sake.
21+
22+
This converter takes BIBFRAME descriptions and transforms them into MARC21 records.
23+
24+
## Conversion wrapper
25+
26+
A sample application that uses _bibframe2marc-xsl_ is included with the [Biblio::BF2MARC](https://github.com/lcnetdev/Biblio-BF2MARC) perl module.
27+
28+
* 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:
29+
* `<bf:Instance>`
30+
* `<bf:Work>`
31+
* These nodes refer to each other through the `bf:instanceOf` and `bf:hasInstance` predicates.
32+
* Objects are dereferenced, so that all the required data is in the RDF/XML documents
33+
* The wrapper script passes the RDF/XML documents to an XSLT stylesheet for transformation to MARCXML (one at a time).
34+
* The wrapper script returns a MARC21 collection of bibliographic records in MARCXML.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

xsl/rules/VERSION rules/VERSION

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)