Skip to content

Refactor #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
saxon9he.jar
File renamed without changes.
61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Version of the OCR-D-GT schema. Current: $(VERSION)
VERSION = 18.01

SAXON_HE_VERSION_MAJOR = 9
SAXON_HE_VERSION_MINOR = 8
SAXON_HE_VERSION_PATCH = 0-1J
SAXON_HE_ZIP = SaxonHE$(SAXON_HE_VERSION_MAJOR)-$(SAXON_HE_VERSION_MINOR)-$(SAXON_HE_VERSION_PATCH).zip
SAXON_HE_URL = https://sourceforge.net/projects/saxon/files/Saxon-HE/$(SAXON_HE_VERSION_MAJOR).$(SAXON_HE_VERSION_MINOR)/$(SAXON_HE_ZIP)/download
SAXON_HE_JAR = saxon9he.jar
SAXON = java -jar $(SAXON_HE_JAR)

ONTO_XML = DefaultLabelTypes_3.xml
ONTO_URL = https://raw.githubusercontent.com/PRImA-Research-Lab/semantic-labelling/master/ontology/$(ONTO_XML)

OCR-D-GTM-XSD = ocr-d-gtm-$(VERSION).xsd

# XSL to transform $(ONTO_XML) to $(OCR-D-GTM-XSD)
XSL_ONTO_TO_XSD = xsl/OCR-D-GTM-labelschema.xsl


# BEGIN-EVAL makefile-parser --make-help Makefile

help:
@echo ""
@echo " Targets"
@echo ""
@echo " saxon Download Saxon"
@echo " onto Fetch the ontology from upstream"
@echo " xsd Build the XSD"
@echo " clean Remove all generated files"
@echo ""
@echo " Variables"
@echo ""
@echo " VERSION Version of the OCR-D-GT schema"
@echo " XSL_ONTO_TO_XSD XSL to transform $(ONTO_XML) to $(OCR-D-GTM-XSD)"

# END-EVAL

# Download Saxon
saxon: $(SAXON_HE_JAR)

$(SAXON_HE_JAR):
wget -O "$(SAXON_HE_ZIP)" "$(SAXON_HE_URL)"
unzip "$(SAXON_HE_ZIP)" "$(SAXON_HE_JAR)"
rm -rf "$(SAXON_HE_ZIP)"

# Fetch the ontology from upstream
onto: $(ONTO_XML)

$(ONTO_XML):
curl -O '$(ONTO_XML)' '$(ONTO_URL)'

# Build the XSD
xsd: $(OCR-D-GTM-XSD)

$(OCR-D-GTM-XSD): saxon onto
$(SAXON) -xsl:$(XSL_ONTO_TO_XSD) -s:$(ONTO_XML) -o:$(OCR-D-GTM-XSD)

# Remove all generated files
clean:
rm -r $(OCR-D-GTM-XSD)
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,27 @@ The ontology is defined in
[`DefaultLabelTypes_3.xml`](./DefaultLabelTypes_3.xml) taken from
https://github.com/PRImA-Research-Lab/semantic-labelling

The [XSD](./OCR-D_GT_schema.xsd) is generated by transforming that ontology with [an XSLT stylesheet](./OCR-D_GT_labelschema_maker.xsl).
The [XSD](./ocr-d-gtm-latest.xsd) is generated by transforming that ontology with [an XSLT stylesheet](./xsl/OCR-D-GTM-labelschema.xsl).

```sh
java -jar ../saxon9he.jar -xsl:OCR-D_GT_labelschema_maker.xsl -s:DefaultLabelTypes_3.xml
Building is handled by a make file, e.g. `make xsd` to rebuild the XSD.

<!-- BEGIN-EVAL -w '```' '```' -- make help -->
```

Targets

saxon Download Saxon
onto Fetch the ontology from upstream
xsd Build the XSD
clean Remove all generated files

Variables

VERSION Version of the OCR-D-GT schema
XSL_ONTO_TO_XSD XSL to transform DefaultLabelTypes_3.xml to ocr-d-gtm-18.01.xsd
```

<!-- END-EVAL -->

## Acknowledgements

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions ocr-d-gtm-latest.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:param name="mets_schema">http://www.loc.gov/standards/mets/mets.xsd</xsl:param>
<xsl:variable name="mining_schema" select="document($mets_schema)"/>

<xsl:template match="text()"/>

<xsl:template match="Ontology">
Expand Down