-
Notifications
You must be signed in to change notification settings - Fork 13
MCR-3111 mycore-tei datamodel and tools #2163
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
Draft
sebhofmann
wants to merge
2
commits into
main
Choose a base branch
from
issues/MCR-3111-mycore-tei_datamodel_and_tools
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <objecttype name="tei" isChild="false" isParent="false" hasDerivates="true" xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns:tei="http://www.tei-c.org/ns/1.0" | ||
| xsi:noNamespaceSchemaLocation="datamodel.xsd"> | ||
| <xsd> | ||
| <xs:import namespace="http://www.tei-c.org/ns/1.0" schemaLocation="schema/tei_all.xsd" /> | ||
| </xsd> | ||
| <metadata> | ||
| <element name="teiContainer" type="xml" style="dontknow" notinherit="true" heritable="false"> | ||
| <xs:sequence> | ||
| <xs:element ref="tei:teiHeader" /> | ||
| </xs:sequence> | ||
| </element> | ||
| </metadata> | ||
| </objecttype> | ||
166 changes: 166 additions & 0 deletions
166
mycore-tei/src/main/java/org/mycore/tei/MCRTEISplitter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| /* | ||
| * This file is part of *** M y C o R e *** | ||
| * See http://www.mycore.de/ for details. | ||
| * | ||
| * MyCoRe is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * MyCoRe is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with MyCoRe. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package org.mycore.tei; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MyCoRe License? |
||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import org.jdom2.Attribute; | ||
| import org.jdom2.Content; | ||
| import org.jdom2.Document; | ||
| import org.jdom2.Element; | ||
| import org.jdom2.filter.Filters; | ||
| import org.jdom2.xpath.XPathExpression; | ||
| import org.jdom2.xpath.XPathFactory; | ||
| import org.mycore.common.MCRConstants; | ||
|
|
||
| /** | ||
| * Can split a TEI document into multiple documents based on the pb elements. | ||
| */ | ||
| public class MCRTEISplitter { | ||
|
|
||
| private final TeiFile original; | ||
|
|
||
| private Element copyTarget; | ||
|
|
||
| private List<TeiFile> splitDocumentList = new ArrayList<>(); | ||
|
|
||
| private int size = -1; | ||
|
|
||
| public MCRTEISplitter(TeiFile original) { | ||
| this.original = original; | ||
| } | ||
|
|
||
| /** | ||
| * Checks if the document is splitable. A document is splitable if it contains pb elements. | ||
| * @return true if the document is splitable, false otherwise | ||
| */ | ||
| public boolean isSplitable() { | ||
| XPathFactory xFactory = XPathFactory.instance(); | ||
| XPathExpression<Element> expr = xFactory.compile("//tei:pb", Filters.element(), null, | ||
| MCRConstants.TEI_NAMESPACE); | ||
| List<Element> elementList = expr.evaluate(this.original.doc()); | ||
| return !elementList.isEmpty(); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the estimated size of the split documents. This is the number of pb | ||
| * @return the estimated size of the split documents | ||
| */ | ||
| public int getEstimatedSize() { | ||
| if (size == -1) { | ||
| XPathFactory xFactory = XPathFactory.instance(); | ||
| XPathExpression<Element> expr = xFactory.compile("//tei:pb", Filters.element(), null, | ||
| MCRConstants.TEI_NAMESPACE); | ||
| List<Element> elementList = expr.evaluate(this.original.doc()); | ||
| size = elementList.size(); | ||
| } | ||
|
|
||
| return size; | ||
| } | ||
|
|
||
| private Stub copyAncestors(Element pbElement, String name) { | ||
| Element parent = pbElement; | ||
| Element lastClone = null; | ||
| Element firstClone = null; | ||
| while ((parent = parent.getParentElement()) != null) { | ||
| Element cloned = cloneElement(parent); | ||
| if (firstClone == null) { | ||
| firstClone = cloned; | ||
| } | ||
| if (lastClone != null) { | ||
| cloned.addContent(lastClone); | ||
| } | ||
| lastClone = cloned; | ||
| } | ||
|
|
||
| TeiFile teiFile = new TeiFile(name, new Document(lastClone)); | ||
| this.splitDocumentList.add(teiFile); | ||
| return new Stub(firstClone, teiFile); | ||
| } | ||
|
|
||
| private void traverse(Element element) { | ||
| for (Content content : element.getContent()) { | ||
| if (content instanceof Element contentElement && contentElement.getName().equals("pb")) { | ||
| String facs = contentElement.getAttributeValue("facs"); | ||
| if (facs.startsWith("images/")) { | ||
| facs = facs.substring("images/".length()); | ||
| } | ||
| Stub newStub = copyAncestors(element, facs); | ||
| copyTarget = newStub.newEl; | ||
| continue; | ||
| } | ||
|
|
||
| copyToNew(content); | ||
| } | ||
| copyTarget = copyTarget.getParentElement(); | ||
| } | ||
|
|
||
| private void copyToNew(Content content) { | ||
| if (content instanceof Element elementContent) { | ||
| Element cloned = cloneElement(elementContent); | ||
| copyTarget.addContent(cloned); | ||
|
|
||
| copyTarget = cloned; | ||
| traverse(elementContent); | ||
| } else { | ||
| copyTarget.addContent(content.clone()); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| private Element cloneElement(Element elementContent) { | ||
| Element element = new Element(elementContent.getName(), elementContent.getNamespace()); | ||
| elementContent.getAttributes() | ||
| .stream() | ||
| .map(Attribute::clone) | ||
| .forEach(element::setAttribute); | ||
|
|
||
| return element; | ||
| } | ||
|
|
||
| /** | ||
| * Splits the document into multiple documents based on the pb elements. | ||
| * @return a list of the split documents | ||
| */ | ||
| public List<TeiFile> split() { | ||
| if (!splitDocumentList.isEmpty()) { | ||
| splitDocumentList = new ArrayList<>(); | ||
| } | ||
|
|
||
| Element originalText = this.original.doc() | ||
| .getRootElement().getChild("text", MCRConstants.TEI_NAMESPACE); | ||
|
|
||
| Stub newStub = copyAncestors(originalText.getChildren().get(0), null); | ||
| copyTarget = newStub.newEl; | ||
|
|
||
| traverse(originalText); | ||
|
|
||
| return splitDocumentList; | ||
| } | ||
|
|
||
| /** | ||
| * Represents a TEI file. | ||
| */ | ||
| public record TeiFile(String name, Document doc) { | ||
| } | ||
|
|
||
| private record Stub(Element newEl, TeiFile teiFile) { | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
mycore-tei/src/main/resources/META-INF/resources/tei/css/tei.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * This file is part of *** M y C o R e *** | ||
| * See http://www.mycore.de/ for details. | ||
| * | ||
| * MyCoRe is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * MyCoRe is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with MyCoRe. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| .fileSection { | ||
| margin-top: 50px; | ||
| } | ||
|
|
||
| .teiDisplaySection { | ||
| padding: 15px; | ||
| background-color: #fff; | ||
| border: 1px solid #ddd; | ||
| border-radius: 4px; | ||
| margin-top: 15px; | ||
| } | ||
|
|
||
| .possibleMatch{ | ||
| margin-top: 30px; | ||
| } | ||
|
|
||
| .possibleMatch a { | ||
| display: block; | ||
| } | ||
|
|
||
| .possibleMatch b { | ||
| margin-right: 5px; | ||
| } | ||
|
|
||
| .teiLine { | ||
| display: block; | ||
| } | ||
|
|
||
| .teiRow { | ||
| display: table-row; | ||
| } | ||
|
|
||
| .teiCell { | ||
| display: table-cell; | ||
| padding: 5px; | ||
| } | ||
|
|
||
| .teiTable { | ||
| display: table; | ||
| } | ||
|
|
||
| dt a { | ||
| vertical-align: super; | ||
| line-height: 2; | ||
| } | ||
|
|
||
| dt, dd { | ||
| display: inline; | ||
| font-weight: normal; | ||
| line-height: normal; | ||
| } | ||
|
|
||
| .popupTrigger { | ||
| cursor: pointer; | ||
| } |
52 changes: 52 additions & 0 deletions
52
mycore-tei/src/main/resources/META-INF/resources/tei/css/webfont-junicode.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * This file is part of *** M y C o R e *** | ||
| * See http://www.mycore.de/ for details. | ||
| * | ||
| * MyCoRe is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * MyCoRe is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with MyCoRe. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| @font-face { | ||
| font-family: 'junicode'; | ||
| src: url('../webfonts/junicode/Junicode.ttf.eot'); | ||
| src: url('../webfonts/junicode/Junicode.ttf?iefix') format('eot'), | ||
| url('../webfonts/junicode/Junicode.ttf.woff') format('woff'), | ||
| url('../webfonts/junicode/Junicode.ttf.svg#webfont') format('svg'); | ||
| } | ||
|
|
||
| .transcription { | ||
| font-family: 'junicode', serif; | ||
| } | ||
|
|
||
| a:link { | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| a:visited { | ||
| } | ||
|
|
||
| a:hover { | ||
| color: #FFBF00; | ||
| } | ||
|
|
||
| a:active { | ||
| color: #FF0000; | ||
| } | ||
|
|
||
| .linebreak_none br { | ||
| display: none; | ||
| } | ||
|
|
||
| :target { | ||
| border: 3px solid #FFFF00; | ||
| } |
Binary file added
BIN
+1.31 MB
mycore-tei/src/main/resources/META-INF/resources/tei/webfonts/junicode/Junicode.ttf
Binary file not shown.
Binary file added
BIN
+1020 KB
mycore-tei/src/main/resources/META-INF/resources/tei/webfonts/junicode/Junicode.ttf.eot
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be more flexible I woud make this a xs:choice of tei:teiHeader and tei:TEI