Gerrit Imsieke (@gimsieke), le-tex publishing services GmbH (@letexml)
XML Prague, 2017-02-11
Schema customization, in particular:
Narrowing what is allowed in certain contexts
<body>
<div>
<head>Chapter 1</head>
<p>Text.</p>
<div>
<head>1.1 A Section</head>
<p>More text.</p>
</div>
<div>
<head>1.2 Another Section</head>
<p>Even more text.</p>
</div>
</div>
</body>
<body>
<div type="chapter">
<head>Chapter 1</head>
<p>Text.</p>
<div type="section">
<head>1.1 A Section</head>
<p>More text.</p>
</div>
<div type="section">
<head>1.2 Another Section</head>
<p>Even more text.</p>
</div>
</div>
</body>
Bibliography div
s should come after the sections. They should contain an optional head
that is followed by listBibl
without a head
.
<body>
<div type="chapter">
<head>Chapter 1</head>
<p>Text.</p>
<div type="section">
[…]
<div type="bibliography">
<head>“Bibliography” heading here?</head>
<listBibl>
<head>or here?</head>
<bibl n="1">Bibliographic Entry</bibl>
</listBibl>
</div>
</div>
</body>
floatingText
should be restricted to certain types (sidebar, box, letter, …)
<div type="section">
<head n="1.1">A Section</head>
<p>A paragraph.</p>
<floatingText type="box">
<body>
<div type="section">
<head>An interspersed Box</head>
</div>
</body>
</floatingText>
<p>Another paragraph.</p>
</div>
Candidates:
With RELAX NG, designing schemas that can be restricted without complete redefinition is more difficult than designing schemas that are easy to extend.
Eric van der Vlist (2003): RELAX NG, Ch. 12, Writing Extensible Schemas
From the tei_allPlus.rng customziation:
<define name="div">
<element name="div">
<a:documentation>(text division)
contains a subdivision of the front, body,
or back of a text.</a:documentation>
<group> [49 lines]
<ref name="att.global.attributes"/>
<ref name="att.divLike.attributes"/>
<ref name="att.typed.attributes"/>
<ref name="att.declaring.attributes"/>
<empty/>
</element>
</define>
No hooks for context-dependent div
attributes
div
into context-dependent definitions.Still:
<pattern id="top-level-div">
<rule context="tei:body/tei:div">
<assert test="@type = ('part', 'chapter')">
Type must be 'part' or 'chapter'.</assert>
</rule>
</pattern>
<pattern id="chapter-div">
<rule context="tei:div[@type = 'chapter']/tei:div">
<assert test="@type = ('section', 'bibliography')">
Type must be 'section' or 'bibliography'.</assert>
</rule>
</pattern>
<pattern id="bib">
<rule context="tei:div[@type = 'bibliography']">
<report test="following-sibling::tei:div[@type =
('part', 'chapter', 'section')]">
No regular content allowed after bibliography.
</report>
</rule>
</pattern>
…and several more rules
Like this:
<?xml-model
href="https://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng"
type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model
href="http://www.le-tex.de/resource/schema/tei-cssa/docbook-like-divs.rng"
type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
[…]
start = tei-div-epi_anything
tei-div-epi_anything =
element * - (div | floatingText | listBibl) {
tei-div-epi_any-atts,
(text
| (tei-div-epi_floatingText-poetry
| tei-div-epi_floatingText-other
| tei-div-epi_front
| tei-div-epi_body ⇦
| tei-div-epi_back
| tei-div-epi_anything))*
}
| tei-div-epi_floatingText-poetry
| tei-div-epi_floatingText-other
body
)tei-div-epi_body =
element body {
tei-div-epi_any-atts,
((tei-div-epi_part | tei-div-epi_anything)*
| (tei-div-epi_chapter⇦| tei-div-epi_anything)*)
}
tei-div-epi_chapter =
element div {
attribute type { "chapter" },
tei-div-epi_not-type-atts,
tei-div-epi_sections,⇦
(tei-div-epi_glossary | tei-div-epi_bibliography)*
}
tei-div-epi_sections =
(tei-div-epi_section | tei-div-epi_anything)*
| (tei-div-epi_sect1 | tei-div-epi_anything)*
listBibl
)tei-div-epi_bibliography =
element div {
attribute type { "bibliography" },
tei-div-epi_not-type-atts,
element head {
tei-div-epi_any-atts, (text | tei-div-epi_anything)*
}?,
element listBibl { tei-div-epi_any-atts, bibl* }
}
bibl =
element bibl {
tei-div-epi_any-atts, (text | tei-div-epi_anything)*
}
Document/schema association
<?xml-model type="application/xml"
href="http://www.le-tex.de/resource/schema/tei-cssa/tei_allPlus_docbook-like-divs.nvdl"
schematypens="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
[…]
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"
startMode="tei">
<mode name="tei">
<namespace ns="http://www.tei-c.org/ns/1.0">
<validate useMode="extensions" ⇦
schema="http://[…]/tei_allPlus.rng"/>
<validate useMode="allow"
schema="http://[…]/docbook-like-divs.rng"/>
</namespace>
</mode>
<mode name="extensions">
<namespace ns="http://www.w3.org/1998/Math/MathML">
<attach/>
</namespace>
<namespace ns="http://www.w3.org/2000/svg">
<attach/>
</namespace>
</mode>
<mode name="allow">
<anyNamespace>
<allow/>
</anyNamespace>
</mode>
</rules>
Looking good so far in oXygen 18.1:
However:
Thanks, George Bina!
xs:any/@notQName
)text/body/div
div
, use section
@class
valuesEpischema
Thank you!
The full paper is on p. 195 of the XML Prague 2017 Proceedings