-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4312 from inception-project/feature/4308-Support-…
…for-custom-XML-formats #4308 - Support for custom XML formats
- Loading branch information
Showing
6 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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
131 changes: 131 additions & 0 deletions
131
...-io-xml/src/main/resources/META-INF/asciidoc/user-guide/formats-xml-custom.adoc
This file contains 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,131 @@ | ||
// Licensed to the Technische Universität Darmstadt under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The Technische Universität Darmstadt | ||
// licenses this file to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
[[sect_formats_xml_custom]] | ||
= XML (custom) | ||
|
||
==== | ||
CAUTION: Experimental feature. To use this functionality, you need to enable it first by adding `format.custom-xml.enabled` to the `settings.properties` file. | ||
==== | ||
|
||
Custom XML document support allows defining own XML annotation formats that can be displayed as formatted documents in HTML-based editors (e.g. the Apache Annotator editor or the RecogitoJS editor). | ||
|
||
The custom XML document support has the goal to provide means of suitably formatting and rendering XML documents in the browser. It does **not** aim at being able to extract potential annotations from the XML document and making them accessible and editable as annotations within {application-name}. It only offers support for **importing** custom XML documents, but not for exporting them. To **export** the annotated document, another format such as <<sect_formats_uimaxmi>> has to be used. | ||
|
||
Custom XML formats are based on the <<sect_formats_xml>> format support. They are defined by creating a sub-folder `xml-formats` in the application home direcotry. Within that folder, another folder is created for each custom XML format. The name of the folder is used as part of the format identifier. Within this per-format folder, a file called `plugin.json` need to be created with the following content: | ||
|
||
.Example `plugin.json` for custom XML format | ||
[source,json] | ||
---- | ||
{ | ||
"name": "TTML format (external)", | ||
"stylesheets": [ | ||
"styles.css" | ||
] | ||
} | ||
---- | ||
|
||
The `plugin.json` file should define one or more CSS stylesheets that define how elements of the custom XML format should be rendered on screen. | ||
|
||
.Example `styles.css` for custom XML format | ||
[source,css] | ||
---- | ||
@namespace tt url('http://www.w3.org/ns/ttml'); | ||
tt|p { | ||
display: block; | ||
border-color: gray; | ||
border-style: solid; | ||
border-width: 1px; | ||
border-radius: 0.5em; | ||
margin-top: 0.25em; | ||
margin-bottom: 0.25em; | ||
&::before { | ||
border-radius: 0.5em 0em 0em 0.5em; | ||
display: inline-block; | ||
padding-left: 0.5em; | ||
padding-right: 0.5em; | ||
margin-right: 0.5em; | ||
background-color: lightgray; | ||
min-width: 10em; | ||
content: attr(agent) '\a0'; | ||
} | ||
} | ||
---- | ||
|
||
Additionally, a `policy.yaml` file should be present in the format folder. It defines how the elements of the XML should be handled when rendering the documents for display in the browser. | ||
|
||
|
||
.Example `policy.yaml` for custom XML format | ||
[source,yaml] | ||
---- | ||
name: TTML Content Policies | ||
version: 1.0 | ||
policies: | ||
- elements: [ | ||
"{http://www.w3.org/ns/ttml}tt", | ||
"{http://www.w3.org/ns/ttml}body", | ||
"{http://www.w3.org/ns/ttml}div", | ||
"{http://www.w3.org/ns/ttml}p" ] | ||
action: "PASS" | ||
- attributes: ["{http://www.w3.org/ns/ttml#metadata}agent"] | ||
action: "PASS_NO_NS" | ||
---- | ||
|
||
An example XML file that could be imported with such a format would look like this: | ||
|
||
.Example `dialog.xml` file | ||
[source,json] | ||
---- | ||
<tt xmlns="http://www.w3.org/ns/ttml" xmlns:ttm="http://www.w3.org/ns/ttml#metadata" xml:lang="en"> | ||
<head> | ||
<metadata> | ||
<ttm:agent xml:id="speaker1">Speaker 1</ttm:agent> | ||
<ttm:agent xml:id="speaker2">Speaker 2</ttm:agent> | ||
</metadata> | ||
</head> | ||
<body> | ||
<div> | ||
<p begin="00:00:01.000" end="00:00:05.000" ttm:agent="speaker1"> | ||
Hello, this is the first speaker. | ||
</p> | ||
<p begin="00:00:06.000" end="00:00:10.000" ttm:agent="speaker2"> | ||
And this is the second speaker. | ||
</p> | ||
</div> | ||
</body> | ||
</tt> | ||
---- | ||
|
||
NOTE: When exporting a project that contains documents using a custom XML format and importing | ||
it into another {application-name} instance in which the format has not been declared, the custom | ||
XML documents will not be usable. You will also have to copy the custom format declaration over | ||
to the new instance. If you use custom XML formats, make sure you keep backups of them | ||
along with the projects that use them. Also try to use names for your formats that are unlikely to | ||
clash with others. E.g. `tei` may not be the best name for a custom TEI format support - | ||
`project-theater-2000-tei` may be a better name.¸ | ||
|
||
[cols="2,1,1,1,3"] | ||
|==== | ||
| Format | Read | Write | Custom Layers | Description | ||
|
||
| XML (custom) (`custom-xml-format-FOLDERNAME`) | ||
| yes | ||
| no | ||
| no | ||
| | ||
|==== |
This file contains 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 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