RelaxNG/publiset.rng
author Patrick PIERRE <patrick.pierre@prismallia.fr>
sam., 18 juin 2011 09:47:23 +0200
changeset 29 0bd36d3b6a5a
parent 27 31bda0a55c4d
child 30 c0f9e813c039
permissions -rw-r--r--
Exemple de sélection
patrick@0
     1
<?xml version="1.0" encoding="UTF-8"?>
patrick@0
     2
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
patrick@0
     3
  <!-- $Id$ -->
patrick@0
     4
  <start>
patrick@0
     5
    <ref name="publiset"/>
patrick@0
     6
  </start>
patrick@0
     7
  <define name="publiset">
patrick@0
     8
    <element name="publiset">
patrick@0
     9
      <ref name="publiset.attributes"/>
patrick@0
    10
      <ref name="publiset.content"/>
patrick@0
    11
    </element>
patrick@0
    12
  </define>
patrick@0
    13
  <define name="publiset.attributes">
patrick@0
    14
    <ref name="version.attribute"/>
patrick@0
    15
  </define>
patrick@0
    16
  <define name="version.attribute">
patrick@0
    17
    <attribute name="version">
patrick@0
    18
      <value>1.0</value>
patrick@0
    19
    </attribute>
patrick@0
    20
  </define>
patrick@0
    21
  <define name="publiset.content">
patrick@0
    22
    <oneOrMore>
patrick@0
    23
      <choice>
patrick@0
    24
        <ref name="composition"/>
patrick@0
    25
        <ref name="selection"/>
patrick@0
    26
      </choice>
patrick@0
    27
    </oneOrMore>
patrick@0
    28
  </define>
patrick@0
    29
  <!--
patrick@0
    30
    =============================================================================
patrick@20
    31
                                     TOP LEVEL
patrick@0
    32
    =============================================================================
patrick@0
    33
  -->
patrick@0
    34
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
patrick@0
    35
  <define name="composition">
patrick@0
    36
    <element name="composition">
patrick@0
    37
      <ref name="composition.attributes"/>
patrick@0
    38
      <ref name="composition.content"/>
patrick@0
    39
    </element>
patrick@0
    40
  </define>
patrick@0
    41
  <define name="composition.attributes">
patrick@0
    42
    <interleave>
patrick@0
    43
      <ref name="composition.id.attribute"/>
patrick@29
    44
      <optional>
patrick@29
    45
        <ref name="path.attribute"/>
patrick@29
    46
      </optional>
patrick@29
    47
      <optional>
patrick@29
    48
        <ref name="xpath.attribute"/>
patrick@29
    49
      </optional>
patrick@29
    50
      <optional>
patrick@29
    51
        <ref name="xslt.attribute"/>
patrick@29
    52
      </optional>
patrick@0
    53
      <ref name="remap.attributes"/>
patrick@0
    54
    </interleave>
patrick@0
    55
  </define>
patrick@0
    56
  <define name="composition.id.attribute">
patrick@0
    57
    <attribute name="xml:id">
patrick@0
    58
      <data type="ID"/>
patrick@0
    59
    </attribute>
patrick@0
    60
  </define>
patrick@29
    61
  <define name="path.attribute">
patrick@29
    62
    <attribute name="path">
patrick@29
    63
      <data type="anyURI"/>
patrick@29
    64
    </attribute>
patrick@29
    65
  </define>
patrick@29
    66
  <define name="xslt.attribute">
patrick@29
    67
    <attribute name="xslt">
patrick@29
    68
      <data type="anyURI"/>
patrick@29
    69
    </attribute>
patrick@29
    70
  </define>
patrick@29
    71
  <define name="xpath.attribute">
patrick@29
    72
    <attribute name="xpath"/>
patrick@29
    73
  </define>
patrick@0
    74
  <define name="composition.content">
patrick@0
    75
    <optional>
patrick@20
    76
      <ref name="composition.head"/>
patrick@0
    77
    </optional>
patrick@0
    78
    <oneOrMore>
patrick@0
    79
      <choice>
patrick@0
    80
        <ref name="composition.file"/>
patrick@0
    81
        <ref name="composition.division"/>
patrick@0
    82
      </choice>
patrick@0
    83
    </oneOrMore>
patrick@0
    84
  </define>
patrick@0
    85
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
patrick@0
    86
  <define name="selection">
patrick@0
    87
    <element name="selection">
patrick@0
    88
      <ref name="selection.attributes"/>
patrick@0
    89
      <ref name="selection.content"/>
patrick@0
    90
    </element>
patrick@0
    91
  </define>
patrick@0
    92
  <define name="selection.attributes">
patrick@29
    93
    <interleave>
patrick@29
    94
      <ref name="selection.id.attribute"/>
patrick@29
    95
      <optional>
patrick@29
    96
        <ref name="path.attribute"/>
patrick@29
    97
      </optional>
patrick@29
    98
      <optional>
patrick@29
    99
        <ref name="xpath.attribute"/>
patrick@29
   100
      </optional>
patrick@29
   101
    </interleave>
patrick@0
   102
  </define>
patrick@0
   103
  <define name="selection.id.attribute">
patrick@0
   104
    <attribute name="xml:id">
patrick@0
   105
      <data type="ID"/>
patrick@0
   106
    </attribute>
patrick@0
   107
  </define>
patrick@0
   108
  <define name="selection.content">
patrick@0
   109
    <optional>
patrick@20
   110
      <ref name="selection.head"/>
patrick@0
   111
    </optional>
patrick@0
   112
    <oneOrMore>
patrick@0
   113
      <choice>
patrick@0
   114
        <ref name="selection.file"/>
patrick@0
   115
        <ref name="selection.division"/>
patrick@0
   116
      </choice>
patrick@0
   117
    </oneOrMore>
patrick@0
   118
  </define>
patrick@0
   119
  <!--
patrick@0
   120
    =============================================================================
patrick@20
   121
                                     HEAD LEVEL
patrick@0
   122
    =============================================================================
patrick@0
   123
  -->
patrick@20
   124
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ head ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
patrick@20
   125
  <define name="composition.head">
patrick@20
   126
    <element name="head">
patrick@20
   127
      <ref name="head.attributes"/>
patrick@20
   128
      <ref name="top.head.content"/>
patrick@0
   129
    </element>
patrick@0
   130
  </define>
patrick@20
   131
  <define name="selection.head">
patrick@20
   132
    <element name="head">
patrick@20
   133
      <ref name="top.head.content"/>
patrick@0
   134
    </element>
patrick@0
   135
  </define>
patrick@20
   136
  <define name="division.head">
patrick@20
   137
    <element name="head">
patrick@20
   138
      <ref name="division.head.content"/>
patrick@20
   139
    </element>
patrick@20
   140
  </define>
patrick@20
   141
  <define name="head.attributes">
patrick@0
   142
    <ref name="remap.attributes"/>
patrick@0
   143
  </define>
patrick@20
   144
  <define name="top.head.content">
patrick@5
   145
    <interleave>
patrick@5
   146
      <optional>
patrick@5
   147
        <ref name="title"/>
patrick@20
   148
        <optional>
patrick@20
   149
          <ref name="subtitle"/>
patrick@20
   150
        </optional>
patrick@5
   151
      </optional>
patrick@5
   152
      <optional>
patrick@20
   153
        <ref name="language"/>
patrick@5
   154
      </optional>
patrick@5
   155
      <zeroOrMore>
patrick@5
   156
        <ref name="author"/>
patrick@5
   157
      </zeroOrMore>
patrick@5
   158
      <optional>
patrick@5
   159
        <ref name="publisher"/>
patrick@5
   160
      </optional>
patrick@5
   161
      <optional>
patrick@20
   162
        <ref name="source"/>
patrick@20
   163
      </optional>
patrick@20
   164
    </interleave>
patrick@20
   165
  </define>
patrick@20
   166
  <define name="division.head.content">
patrick@20
   167
    <interleave>
patrick@20
   168
      <optional>
patrick@20
   169
        <ref name="title"/>
patrick@20
   170
        <optional>
patrick@20
   171
          <ref name="subtitle"/>
patrick@20
   172
        </optional>
patrick@20
   173
      </optional>
patrick@20
   174
      <optional>
patrick@5
   175
        <ref name="language"/>
patrick@5
   176
      </optional>
patrick@5
   177
    </interleave>
patrick@0
   178
  </define>
patrick@0
   179
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
patrick@0
   180
  <define name="title">
patrick@0
   181
    <element name="title">
patrick@0
   182
      <ref name="title.content"/>
patrick@0
   183
    </element>
patrick@0
   184
  </define>
patrick@0
   185
  <define name="subtitle">
patrick@0
   186
    <element name="subtitle">
patrick@0
   187
      <ref name="title.content"/>
patrick@0
   188
    </element>
patrick@0
   189
  </define>
patrick@20
   190
  <define name="title.content">
patrick@20
   191
    <ref name="inlines"/>
patrick@20
   192
  </define>
patrick@20
   193
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ language ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
patrick@20
   194
  <define name="language">
patrick@20
   195
    <element name="language">
patrick@20
   196
      <ref name="language.attributes"/>
patrick@20
   197
    </element>
patrick@20
   198
  </define>
patrick@20
   199
  <define name="language.attributes">
patrick@20
   200
    <ref name="lang.attribute"/>
patrick@20
   201
  </define>
patrick@20
   202
  <define name="lang.attribute">
patrick@20
   203
    <attribute name="xml:lang">
patrick@20
   204
      <data type="language"/>
patrick@20
   205
    </attribute>
patrick@20
   206
  </define>
patrick@5
   207
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ author, publisher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
patrick@5
   208
  <!-- ~~~~~~ author -->
patrick@5
   209
  <define name="author">
patrick@5
   210
    <element name="author">
patrick@5
   211
      <ref name="author.content"/>
patrick@5
   212
    </element>
patrick@5
   213
  </define>
patrick@5
   214
  <define name="author.content">
patrick@5
   215
    <optional>
patrick@5
   216
      <ref name="firstname"/>
patrick@5
   217
    </optional>
patrick@5
   218
    <ref name="lastname"/>
patrick@5
   219
  </define>
patrick@5
   220
  <!-- ~~~~~~ publisher -->
patrick@5
   221
  <define name="publisher">
patrick@5
   222
    <element name="publisher">
patrick@5
   223
      <ref name="publisher.content"/>
patrick@5
   224
    </element>
patrick@5
   225
  </define>
patrick@5
   226
  <define name="publisher.content">
patrick@5
   227
    <ref name="inlines"/>
patrick@5
   228
  </define>
patrick@5
   229
  <!-- ~~~~~~ firstname -->
patrick@5
   230
  <define name="firstname">
patrick@5
   231
    <element name="firstname">
patrick@5
   232
      <ref name="firstname.content"/>
patrick@5
   233
    </element>
patrick@5
   234
  </define>
patrick@5
   235
  <define name="firstname.content">
patrick@5
   236
    <ref name="inlines"/>
patrick@5
   237
  </define>
patrick@5
   238
  <!-- ~~~~~~ lastname -->
patrick@5
   239
  <define name="lastname">
patrick@5
   240
    <element name="lastname">
patrick@5
   241
      <ref name="lastname.content"/>
patrick@5
   242
    </element>
patrick@5
   243
  </define>
patrick@5
   244
  <define name="lastname.content">
patrick@5
   245
    <ref name="inlines"/>
patrick@5
   246
  </define>
patrick@0
   247
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
patrick@2
   248
  <!-- ~~~~~~ source -->
patrick@0
   249
  <define name="source">
patrick@0
   250
    <element name="source">
patrick@0
   251
      <ref name="source.attributes"/>
patrick@0
   252
      <choice>
patrick@0
   253
        <group>
patrick@0
   254
          <attribute name="type">
patrick@0
   255
            <value>book</value>
patrick@0
   256
          </attribute>
patrick@0
   257
          <ref name="source.content.book"/>
patrick@0
   258
        </group>
patrick@0
   259
        <attribute name="type">
patrick@0
   260
          <value>file</value>
patrick@0
   261
        </attribute>
patrick@0
   262
      </choice>
patrick@0
   263
    </element>
patrick@0
   264
  </define>
patrick@0
   265
  <define name="source.attributes">
patrick@0
   266
    <interleave>
patrick@0
   267
      <optional>
patrick@0
   268
        <ref name="source.id.attribute"/>
patrick@0
   269
      </optional>
patrick@0
   270
      <ref name="remap.attributes"/>
patrick@0
   271
    </interleave>
patrick@0
   272
  </define>
patrick@0
   273
  <define name="source.id.attribute">
patrick@0
   274
    <attribute name="id">
patrick@0
   275
      <data type="NMTOKEN"/>
patrick@0
   276
    </attribute>
patrick@0
   277
  </define>
patrick@0
   278
  <define name="source.content.book">
patrick@0
   279
    <optional>
patrick@0
   280
      <ref name="title"/>
patrick@0
   281
    </optional>
patrick@0
   282
    <optional>
patrick@0
   283
      <ref name="pagenumber"/>
patrick@0
   284
    </optional>
patrick@0
   285
  </define>
patrick@2
   286
  <!-- ~~~~~~ pagenumber -->
patrick@0
   287
  <define name="pagenumber">
patrick@0
   288
    <element name="pagenumber">
patrick@0
   289
      <ref name="pagenumber.attributes"/>
patrick@0
   290
    </element>
patrick@0
   291
  </define>
patrick@0
   292
  <define name="pagenumber.attributes">
patrick@0
   293
    <ref name="pagenumber.value.attribute"/>
patrick@0
   294
  </define>
patrick@0
   295
  <define name="pagenumber.value.attribute">
patrick@0
   296
    <attribute name="value">
patrick@0
   297
      <ref name="pagenumber.value.enumeration"/>
patrick@0
   298
    </attribute>
patrick@0
   299
  </define>
patrick@0
   300
  <define name="pagenumber.value.enumeration">
patrick@0
   301
    <data type="positiveInteger"/>
patrick@0
   302
  </define>
patrick@0
   303
  <!--
patrick@0
   304
    =============================================================================
patrick@20
   305
                                   DIVISION LEVEL
patrick@0
   306
    =============================================================================
patrick@0
   307
  -->
patrick@0
   308
  <define name="composition.division">
patrick@0
   309
    <element name="division">
patrick@0
   310
      <ref name="composition.division.attributes"/>
patrick@0
   311
      <ref name="composition.division.content"/>
patrick@0
   312
    </element>
patrick@0
   313
  </define>
patrick@0
   314
  <define name="selection.division">
patrick@0
   315
    <element name="division">
patrick@0
   316
      <ref name="selection.division.attributes"/>
patrick@0
   317
      <ref name="selection.division.content"/>
patrick@0
   318
    </element>
patrick@0
   319
  </define>
patrick@0
   320
  <define name="composition.division.attributes">
patrick@0
   321
    <interleave>
patrick@0
   322
      <optional>
patrick@26
   323
        <ref name="path.attribute"/>
patrick@0
   324
      </optional>
patrick@23
   325
      <optional>
patrick@29
   326
        <ref name="xpath.attribute"/>
patrick@23
   327
      </optional>
patrick@23
   328
      <optional>
patrick@29
   329
        <ref name="xslt.attribute"/>
patrick@23
   330
      </optional>
patrick@0
   331
      <ref name="remap.attributes"/>
patrick@0
   332
    </interleave>
patrick@0
   333
  </define>
patrick@0
   334
  <define name="selection.division.attributes">
patrick@29
   335
    <interleave>
patrick@29
   336
      <optional>
patrick@29
   337
        <ref name="path.attribute"/>
patrick@29
   338
      </optional>
patrick@29
   339
      <optional>
patrick@29
   340
        <ref name="xpath.attribute"/>
patrick@29
   341
      </optional>
patrick@29
   342
    </interleave>
patrick@23
   343
  </define>
patrick@0
   344
  <define name="composition.division.content">
patrick@0
   345
    <optional>
patrick@20
   346
      <ref name="composition.head"/>
patrick@0
   347
    </optional>
patrick@0
   348
    <oneOrMore>
patrick@0
   349
      <choice>
patrick@20
   350
        <ref name="composition.division"/>
patrick@0
   351
        <ref name="composition.file"/>
patrick@0
   352
      </choice>
patrick@0
   353
    </oneOrMore>
patrick@0
   354
  </define>
patrick@0
   355
  <define name="selection.division.content">
patrick@0
   356
    <optional>
patrick@20
   357
      <ref name="selection.head"/>
patrick@0
   358
    </optional>
patrick@0
   359
    <oneOrMore>
patrick@0
   360
      <choice>
patrick@20
   361
        <ref name="selection.division"/>
patrick@0
   362
        <ref name="selection.file"/>
patrick@0
   363
      </choice>
patrick@0
   364
    </oneOrMore>
patrick@0
   365
  </define>
patrick@0
   366
  <!--
patrick@0
   367
    =============================================================================
patrick@20
   368
                                     FILE LEVEL
patrick@0
   369
    =============================================================================
patrick@0
   370
  -->
patrick@0
   371
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
patrick@0
   372
  <define name="composition.file">
patrick@0
   373
    <element name="file">
patrick@0
   374
      <ref name="composition.file.attributes"/>
patrick@2
   375
      <ref name="file.content"/>
patrick@0
   376
    </element>
patrick@0
   377
  </define>
patrick@0
   378
  <define name="selection.file">
patrick@0
   379
    <element name="file">
patrick@0
   380
      <ref name="selection.file.attributes"/>
patrick@2
   381
      <ref name="file.content"/>
patrick@0
   382
    </element>
patrick@0
   383
  </define>
patrick@0
   384
  <define name="composition.file.attributes">
patrick@0
   385
    <interleave>
patrick@0
   386
      <optional>
patrick@29
   387
        <ref name="xpath.attribute"/>
patrick@0
   388
      </optional>
patrick@20
   389
      <optional>
patrick@29
   390
        <ref name="xslt.attribute"/>
patrick@20
   391
      </optional>
patrick@0
   392
      <ref name="remap.attributes"/>
patrick@0
   393
    </interleave>
patrick@0
   394
  </define>
patrick@0
   395
  <define name="selection.file.attributes">
patrick@29
   396
    <optional>
patrick@29
   397
      <ref name="xpath.attribute"/>
patrick@29
   398
    </optional>
patrick@0
   399
  </define>
patrick@2
   400
  <define name="file.content">
patrick@2
   401
    <data type="anyURI"/>
patrick@2
   402
  </define>
patrick@0
   403
  <!--
patrick@0
   404
    =============================================================================
patrick@20
   405
                                    INLINE LEVEL
patrick@0
   406
    =============================================================================
patrick@0
   407
  -->
patrick@0
   408
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
patrick@0
   409
  <define name="inlines">
patrick@0
   410
    <mixed>
patrick@0
   411
      <interleave>
patrick@0
   412
        <zeroOrMore>
patrick@0
   413
          <ref name="sup"/>
patrick@0
   414
        </zeroOrMore>
patrick@0
   415
        <zeroOrMore>
patrick@0
   416
          <ref name="sub"/>
patrick@0
   417
        </zeroOrMore>
patrick@0
   418
      </interleave>
patrick@0
   419
    </mixed>
patrick@0
   420
  </define>
patrick@0
   421
  <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
patrick@0
   422
  <define name="sup">
patrick@0
   423
    <element name="sup">
patrick@0
   424
      <ref name="inlines"/>
patrick@0
   425
    </element>
patrick@0
   426
  </define>
patrick@0
   427
  <define name="sub">
patrick@0
   428
    <element name="sub">
patrick@0
   429
      <ref name="inlines"/>
patrick@0
   430
    </element>
patrick@0
   431
  </define>
patrick@0
   432
  <!--
patrick@0
   433
    =============================================================================
patrick@20
   434
                                  REMAP ATTRIBUTES
patrick@0
   435
    =============================================================================
patrick@0
   436
  -->
patrick@0
   437
  <define name="remap.attributes">
patrick@0
   438
    <interleave>
patrick@0
   439
      <optional>
patrick@0
   440
        <ref name="as.attribute"/>
patrick@0
   441
      </optional>
patrick@0
   442
      <optional>
patrick@0
   443
        <ref name="attributes.attribute"/>
patrick@0
   444
      </optional>
patrick@0
   445
    </interleave>
patrick@0
   446
  </define>
patrick@0
   447
  <define name="as.attribute">
patrick@0
   448
    <attribute name="as">
patrick@0
   449
      <data type="QName"/>
patrick@0
   450
    </attribute>
patrick@0
   451
  </define>
patrick@0
   452
  <define name="attributes.attribute">
patrick@0
   453
    <attribute name="attributes">
patrick@0
   454
      <list>
patrick@0
   455
        <oneOrMore>
patrick@0
   456
          <data type="token">
patrick@0
   457
            <param name="pattern">\c+=\S+</param>
patrick@0
   458
          </data>
patrick@0
   459
        </oneOrMore>
patrick@0
   460
      </list>
patrick@0
   461
    </attribute>
patrick@0
   462
  </define>
patrick@0
   463
</grammar>