Skip to content

Commit 6736ae6

Browse files
committed
schema validate
1 parent fc3093b commit 6736ae6

2 files changed

Lines changed: 26 additions & 17 deletions

File tree

schema/alix.rng

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<grammar
33
xmlns="http://relaxng.org/ns/structure/1.0"
4-
ns="https://oeuvres.github.io/alix"
4+
ns="https://github.com/oeuvres/alix/ns"
55
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
66
xml:lang="en"
77
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
@@ -240,6 +240,7 @@ According to Lucene model, there are 3 levels of objects inside Alix.
240240
<define name="chapter">
241241
<element name="chapter">
242242
<a:documentation>A set of <a:el>field</a:el>s, like a <a:el>document</a:el>, except it has to be inside a <a:el>book</a:el>.</a:documentation>
243+
<ref name="docid"/>
243244
<oneOrMore>
244245
<ref name="field"/>
245246
</oneOrMore>
@@ -286,7 +287,16 @@ If you need only lightweight token search (for example bibliographic strings), p
286287
<attribute name="type">
287288
<value>text</value>
288289
</attribute>
289-
<ref name="xml"/>
290+
<optional>
291+
<choice>
292+
<attribute name="include"/>
293+
<attribute name="exclude"/>
294+
</choice>
295+
</optional>
296+
<choice>
297+
<attribute name="copy"/>
298+
<ref name="xml"/>
299+
</choice>
290300
</element>
291301
</define>
292302
<define name="field-meta">
@@ -299,10 +309,7 @@ Typical use: bibliographic citations, identifiers embedded in text strings, name
299309
<attribute name="type">
300310
<value>meta</value>
301311
</attribute>
302-
<choice>
303-
<attribute name="value"/>
304-
<ref name="xml"/>
305-
</choice>
312+
<ref name="xml"/>
306313
</element>
307314
</define>
308315
<define name="field-store">

test/src/test/test-data/ingest-alix-test.xml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<?xml-model href="https://raw.githubusercontent.com/oeuvres/alix/master/schema/alix.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
23
<alix:book
3-
xmlns:alix="https://oeuvres.github.io/alix"
4+
xmlns:alix="https://github.com/oeuvres/alix/ns"
45
xmlns="http://www.w3.org/1999/xhtml"
56
xml:id="demo-book">
67

78
<!-- Book-level metadata -->
89
<alix:field name="doc_kind" type="category" value="book"/>
9-
<alix:field name="title" type="meta" value="Demo Book for Alix SAX Ingest"/>
10+
<alix:field name="title" type="meta">Demo Book for Alix SAX Ingest</alix:field>
1011
<alix:field name="year" type="int" value="1959"/>
1112
<alix:field name="author" type="facet" value="Jean Piaget"/>
1213
<alix:field name="author" type="facet" value="Bärbel Inhelder"/>
@@ -24,21 +25,21 @@
2425

2526
<alix:field name="doc_kind" type="category" value="chapter"/>
2627
<alix:field name="bookid" type="category" value="demo-book"/>
27-
<alix:field name="title" type="meta" value="Chapter I. Demo chapter"/>
28+
<alix:field name="title" type="meta">Chapter I. Demo chapter</alix:field>
2829
<alix:field name="year" type="int" value="1959"/>
2930
<alix:field name="author" type="facet" value="Jean Piaget"/>
3031

3132
<!-- Stored display/result string -->
3233
<alix:field name="resultline" type="store" value="Piaget (1959), Chapter I, p. 1-12."/>
3334

3435
<!-- Main source text (XHTML payload) -->
35-
<alix:field name="text" type="text">
36+
<alix:field name="text" type="text" exclude="nav">
3637
<article id="ch1">
3738
<h1>Chapter I. Demo chapter</h1>
3839

3940
<p>This is author text before a quotation.</p>
4041

41-
<blockquote data-tei-type="quote">
42+
<blockquote other-type="quote">
4243
<p>This quoted passage should be indexable separately.</p>
4344
</blockquote>
4445

@@ -49,18 +50,19 @@
4950
</div>
5051

5152
<p>Final paragraph of author text.</p>
53+
54+
<nav>
55+
<a href="intro" class="prev">Introduction</a>
56+
<a href="ch2" class="next">Chapter II</a>
57+
</nav>
5258
</article>
5359
</alix:field>
5460

5561
<!-- Derived field: only observation zones -->
56-
<alix:field name="observations" type="text" source="text">
57-
<alix:include attribute="data-tei-type" value="observation"/>
58-
</alix:field>
62+
<alix:field name="observations" type="text" copy="text" include="@data-tei-type='observation'"/>
5963

6064
<!-- Derived field: exclude quoted zones -->
61-
<alix:field name="text_noquotes" type="text" source="text">
62-
<alix:exclude attribute="data-tei-type" value="quote"/>
63-
</alix:field>
65+
<alix:field name="text_noquotes" type="text" copy="text" exclude="@other-type='observation'"/>
6466

6567
</alix:chapter>
6668
</alix:book>

0 commit comments

Comments
 (0)