Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
blob: d91c65845f7a02a9b8d6dce259acd3b2f5c60e96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.lovullo.com/rater"
  xmlns="http://www.lovullo.com/rater"
  xmlns:c="http://www.lovullo.com/calc"
  elementFormDefault="qualified">

<!-- this schema supports calculations -->
<xs:import
  namespace="http://www.lovullo.com/calc"
  schemaLocation="calc.xsd" />

<!-- can include maps -->
<xs:import
  namespace="http://www.lovullo.com/rater/map"
  schemaLocation="map.xsd" />

<!-- C1 map -->
<xs:import
  namespace="http://www.lovullo.com/rater/map/c1"
  schemaLocation="c1map.xsd" />

<!-- worksheets -->
<xs:import
  namespace="http://www.lovullo.com/rater/worksheet"
  schemaLocation="worksheet.xsd" />


<!--basicTypes-->
  <xs:simpleType name="packageNameType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Name of a package/rater. Must match the name of the XML file, sans the
        extension. If the package is in a subdirectory, then the name should be
        a relative path (e.g. "rates/company").
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:string">
      <xs:pattern value="[a-z][a-z0-9/-]+" />
      <xs:minLength value="2" />
      <xs:maxLength value="75" />
    </xs:restriction>
  </xs:simpleType>


  <xs:simpleType name="constNameType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Name of a constant.

        Underscore prefixes should be reserved for system constants.
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:NCName">
      <xs:pattern value="_*[A-Z][A-Z0-9_]+" />
      <xs:minLength value="1" />
      <xs:maxLength value="75" />
    </xs:restriction>
  </xs:simpleType>


  <xs:simpleType name="typeNameType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Name of a type (as would be defined via typedef).
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:NCName">
      <xs:pattern value="[a-zA-Z]+" />
      <xs:minLength value="1" />
      <xs:maxLength value="50" />
    </xs:restriction>
  </xs:simpleType>


  <xs:simpleType name="functionNameType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Name of a mathematical function.

        Since the name will appear in equations, it has a restricted character
        set and length.
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:NCName">
      <xs:pattern value="[a-z_-]+" />
      <xs:minLength value="1" />
      <xs:maxLength value="15" />
    </xs:restriction>
  </xs:simpleType>


  <xs:simpleType name="paramNameType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Name of a parameter (global or local)
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:NCName">
      <xs:pattern value="[a-z_][a-z0-9_]*" />
      <xs:minLength value="1" />
    </xs:restriction>
  </xs:simpleType>


  <xs:simpleType name="yieldsNameType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Represents a value yielded by a calculation (e.g. a premium).

        The camelCase requirement as opposed to the snake_case requirement used
        for other variables, such as params, is intended to provide a
        distinction.
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:string">
      <xs:pattern value="_*[a-z][a-zA-Z0-9]+|\{?@[a-z][a-zA-Z0-9_]*@\}?" />
      <xs:minLength value="1" />
      <xs:maxLength value="50" />
    </xs:restriction>
  </xs:simpleType>


  <xs:simpleType name="indexNameType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Single-character index variable
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:string">
      <xs:pattern value="[a-z]|\{?@[a-z][a-zA-Z0-9_]*@\}?" />
    </xs:restriction>
  </xs:simpleType>


  <xs:simpleType name="templateNameType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Template name; underscore prefix and suffix is mandatory to help ensure
        distinctive names between other identifiers.
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:string">
      <xs:pattern value="_[a-zA-Z0-9@\{\}-]+_|@[a-z][a-zA-Z0-9]*@" />
    </xs:restriction>
  </xs:simpleType>


  <xs:simpleType name="templateParamNameType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Template parameter name

        Template parameters are delimited by '@'s; this restriction is in place
        to permit substring replacements with clear delimiters.
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:string">
      <xs:pattern value="@[a-z_-][a-zA-Z0-9_-]*@" />
    </xs:restriction>
  </xs:simpleType>


  <xs:simpleType name="descType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Documentation for a specific element.

        The documentation must not be sparse; please provide something
        descriptive that will be useful to someone completely new to the code.
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:string">
      <!-- let's make an attempt at reasonable documentation, shall we? -->
      <xs:minLength value="2" />
    </xs:restriction>
  </xs:simpleType>


  <xs:simpleType name="symbolType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Symbol used to represent an entity when rendered.

        The string should consist of TeX/LaTeX commands and should produce a
        single symbol.
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:string" />
  </xs:simpleType>


  <xs:simpleType name="setType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Types of sets (vectors or matrices)
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:token">
      <xs:enumeration value="vector" />
      <xs:enumeration value="matrix" />
    </xs:restriction>
  </xs:simpleType>
<!--/basicTypes-->


<!--constants-->
  <xs:complexType name="itemSetType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Permits the static declaration of a matrix; a set represents a vector
        and sibling sets can be combined to create a matrix
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <!-- allow an empty set for skipping rows -->
      <xs:element name="item" type="itemType" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>

    <xs:attribute name="desc" type="descType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Description explaining what the set represents
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <xs:complexType name="itemType">
    <xs:attribute name="value" type="xs:token">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Value of the constant; must be compatible with the
          enumeration's @type.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="desc" type="descType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Description explaining what the value represents
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <xs:complexType name="constType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Defines a single constant.

        Constants differ from other variables (such as parameters) in that their
        values cannot change; they exist as an alternative to hard-coding values
        and as a means of re-use (magic values are not permitted).

        The value of the constant must be compatiable with its type.
      </xs:documentation>
    </xs:annotation>

    <xs:choice>
      <xs:element name="set" type="itemSetType" minOccurs="0" maxOccurs="unbounded" />
      <xs:element name="item" type="itemType" minOccurs="0" maxOccurs="unbounded" />
    </xs:choice>

    <xs:attribute name="name" type="constNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Name of the constant. The name must always be used in place of the
          value when referencing the constant.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="value" type="xs:token">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Value of the constant; must be within the domain of its type.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="values" type="xs:token">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Short-hand GNU Octave / MATLAB Style matrix specification.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="type" type="typeNameType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Constant data type
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="desc" type="descType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Useful description of the constant that explains what it is used for
          and provides a context
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="sym" type="symbolType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Optional LaTeX symbol for typesetting
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="magic" type="xs:boolean">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          (CORE ONLY) Denotes a constant whose value may be determined by runtime

          This should prevent any compiler from inlining the constant value.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
<!--/constants-->


<!--import-->
  <xs:simpleType name="packagePathType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Path to a package without the extension.
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:string">
      <xs:pattern value="[a-z./][a-zA-Z0-9./-]+" />
      <xs:minLength value="2" />
      <xs:maxLength value="100" />
    </xs:restriction>
  </xs:simpleType>


  <xs:complexType name="topicOfType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Declares the package that this package is a sub-topic of.
      </xs:documentation>
    </xs:annotation>

    <xs:attribute name="package" type="packagePathType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Path to package, sans the ``.xml'' extension.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="section" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Parent section name; defaults to root.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <xs:complexType name="importType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Permits importing package or template contents for use in the parent document.

        The @package attribute may be used for explicitly loading a package.

        @templates specifies a path for template auto-loading, but does not load any
        templates, allowing the system to use only the templates that are needed.
      </xs:documentation>
    </xs:annotation>

    <xs:attribute name="package" type="packagePathType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Path to package to import, sans the ``.xml'' extension.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="export" type="xs:boolean">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Export the symbols imported by this package

          By default, all imported symbols are local, meaning that importing a
          package will not include the symbols that the package itself has
          imported. This is generally desirable from a maintainance standpoint,
          but certain meta-packages (packages that exist simply to include
          packages) may wish to make use of this feature.

          Use sparingly.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="topic-of" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Short-hand for a separate topic-of node; parent
          section.  "true" is equivalent to "root".
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="allow-nonpkg" type="xs:boolean">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Allow importing symbol tables that are not explicitly defined as
          includable packages.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="ignore-keep" type="xs:boolean">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Strip @keep flag from all imported symbols.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="keep-classes" type="xs:boolean">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Keep all classifications, even if @ignore-keep is set.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
<!--/import-->


<!--typedef-->
  <xs:complexType name="typedefType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Defines a type that may be used to represent a restricted set of values.
      </xs:documentation>
    </xs:annotation>

    <xs:choice>
      <xs:element name="union" type="unionType" minOccurs="0" maxOccurs="1" />
      <xs:element name="enum" type="enumType" minOccurs="0" maxOccurs="1" />

      <!-- used only by core packages -->
      <xs:element name="base-type" minOccurs="0" maxOccurs="1" />
    </xs:choice>

    <xs:attribute name="name" type="typeNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Name by which the type may be referenced
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="desc" type="descType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Description of what the type may be used for
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="sym" type="symbolType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Optional LaTeX symbol for typesetting
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <xs:complexType name="unionType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Merges multiple typedefs of the same type into a single type.

        Useful for categorizing types and sub-types in a semantic manner.
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:element name="typedef" type="typedefType" minOccurs="2" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>


  <xs:complexType name="enumType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Defines an enumerated set of values.

        The type may accept any @value in the set. When referenced, @name must
        be used. The name must be styled as a constant (since it is not a
        variable).
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:element name="item" minOccurs="1" maxOccurs="unbounded">
        <xs:complexType>
          <xs:attribute name="name" type="constNameType" use="required">
            <xs:annotation>
              <xs:documentation xml:lang="en">
                Name of enumerated value. This defines a constant and so the
                name should be styled as such.
              </xs:documentation>
            </xs:annotation>
          </xs:attribute>
          <xs:attribute name="value" type="xs:token">
            <xs:annotation>
              <xs:documentation xml:lang="en">
                Value of the constant; must be compatible with the
                enumeration's @type.
              </xs:documentation>
            </xs:annotation>
          </xs:attribute>
          <xs:attribute name="desc" type="descType" use="required">
            <xs:annotation>
              <xs:documentation xml:lang="en">
                Description explaining what the value represents
              </xs:documentation>
            </xs:annotation>
          </xs:attribute>
        </xs:complexType>
      </xs:element>
    </xs:sequence>

    <xs:attribute name="type" type="typeNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Type of all enumerated values in a particular list
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
<!--/typedef-->


<!--funcAndParams-->
  <xs:complexType name="paramType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Represents a parameter accepted by the rater or a function.

        Parameters accepted by the rater itself will be declared globally,
        whereas parameters defined within functions will be local to that
        function.

        Regardless of scope, parameter names must never conflict.
      </xs:documentation>
    </xs:annotation>

    <xs:attribute name="name" type="paramNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Name by which parameter can be identified
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="type" type="typeNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Parameter data type
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="desc" type="descType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Description of parameter
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="set" type="setType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Whether or not the parameter is a set of values of type @type (an
          array)
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="default" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Default value for parameter if none is provided; must be within the
          domain of its @type
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="sym" type="symbolType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Optional LaTeX symbol for typesetting
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <xs:complexType name="functionType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Defines a mathematical function --- a reusable equation that optionally
        accepts arguments.

        Functions also have access to the global argument list and any other
        values; not everything must be passed in. Functions may contain only
        a single calculation node (which itself may contain other calculations).
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:element name="param" type="paramType" minOccurs="0" maxOccurs="unbounded" />
      <xs:group ref="c:calculationRoot" minOccurs="1" maxOccurs="1" />
    </xs:sequence>

    <xs:attribute name="name" type="functionNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Name of the function. Since the function is intended to be a function
          in the mathematical sense and may be output as part of an equation,
          the name is restricted to lowercase alpha characters.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="desc" type="descType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Description of function and its purpose
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="sym" type="symbolType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Optional symbol to use in place of function name when typesetting
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
<!--/funcAndParams-->


<!--rate-->
  <xs:simpleType name="classType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        String of classifications, space-delimited.
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:token">
      <xs:pattern value="([a-z-][a-z0-9-]+ ?)+|@[a-z][a-zA-Z0-9_]*@" />
      <xs:minLength value="1" />
      <xs:maxLength value="100" />
    </xs:restriction>
  </xs:simpleType>



  <!-- name derived from xsl:with-param; distinguishes between macro params and
       lv:arg -->
  <xs:complexType name="withParamType">
    <xs:sequence>
      <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
    </xs:sequence>

    <xs:attribute name="name" type="templateParamNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Name of parameter to replace in template
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="value" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          String with which template parameter should be replaced

          All template parameters are replaced by the preprocessor before
          the XML document reaches any other system; this means that all
          parameter replacements are performed as strings, just as if you
          copied and pasted the template XML into place and did a
          search-and-replace/regex on the XML.

          Consequently, variable replacements are not permitted. You may
          replace the parameter with text representing the name of a
          global parameter, for example, but you cannot pass in the
          current value of of that parameter.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <xs:complexType name="applyTemplateType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        This node will be entirely removed and replaced with the child nodes
        of the referenced template.
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:element name="with-param" type="withParamType" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>

    <xs:attribute name="name" type="templateNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Name of template to include in its place.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <!-- any other attributes will be expanded into lv:with-param; this works
         well since macros work with string values -->
    <xs:anyAttribute namespace="##any" processContents="lax" />
  </xs:complexType>


  <xs:complexType name="inlineTemplateType" mixed="true">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        This node will be replaced with the processed template.
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:element name="for-each" minOccurs="0" maxOccurs="1">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="sym-set" minOccurs="0" maxOccurs="unbounded">
              <xs:complexType>
                <xs:anyAttribute namespace="##any" processContents="lax" />
              </xs:complexType>
            </xs:element>
            <xs:element name="set" minOccurs="0" maxOccurs="unbounded">
              <xs:complexType>
                <xs:anyAttribute namespace="##any" processContents="lax" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>

      <!-- see also templateType -->
      <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
    </xs:sequence>
  </xs:complexType>


  <xs:group name="calcOrTemplate">
    <xs:choice>
      <!-- long-hand -->
      <xs:element name="apply-template" type="applyTemplateType" />
      <xs:element name="inline-template" type="inlineTemplateType" />

      <!-- short-hand with namespace prefix -->
      <xs:any namespace="http://www.lovullo.com/rater/apply-template"
        minOccurs="0" maxOccurs="unbounded" processContents="lax" />

      <xs:group ref="c:calculationRoot" />
    </xs:choice>
  </xs:group>


  <xs:complexType name="rateCommon" abstract="true">
    <xs:attribute name="class" type="classType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Classifications, delimited by spaces, that must be satisfied in order
          to perform the premium calculation.

          If no classification is given, then the rating will always be
          performed.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="no" type="classType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Classifications, delimited by commas, that must be <em>not</em> be
          satisfied in order to perform the premium calculation.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="sym" type="symbolType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Optional LaTeX symbol used to identify this premium (display only)
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="always" type="xs:boolean">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Always enter this rate block, even if the classification does not
          match. This is useful if you wish to use the _CMATCH_ results
          even on a non-match.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <!-- alternative to @class -->
  <xs:complexType name="classNodeType">
    <xs:attribute name="ref" type="classNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Class name to apply to block
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="no" type="xs:boolean" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Whether or not the classification should be considered as if it were
          part of a @no attribute
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <xs:complexType name="rateTypeSansYields">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Represents a premium calculation to be performed based on a prior
        classification (sans @yields)
      </xs:documentation>
    </xs:annotation>

    <xs:complexContent>
      <xs:extension base="rateCommon">
        <xs:sequence>
          <xs:element name="class" type="classNodeType" minOccurs="0" maxOccurs="unbounded" />
          <xs:group ref="calcOrTemplate" minOccurs="1" maxOccurs="1" />
        </xs:sequence>

        <xs:attribute name="precision" type="constNameType">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Precision of result (empty will use system default)
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="keep" type="xs:boolean">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Compile the rate block even if it does not contribute to the
              final premium (that is---is outside the dependency tree of
              lv:yields)

              This is useful for calculating supplemental data that does not
              directly contribute to the premium.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="external" type="xs:boolean">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Rate calculation should be compiled external to the classifier (that
              is, the classification should only be performed on-demand for rating
              purposes).

              This has the benefit of removing the classifier from the classify()
              method, which may be important for, say, asserting on final premium
              amount.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>


  <xs:complexType name="rateType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Represents a premium calculation to be performed based on a prior
        classification
      </xs:documentation>
    </xs:annotation>

    <xs:complexContent>
      <xs:extension base="rateTypeSansYields">
        <xs:attribute name="yields" type="yieldsNameType" use="required">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Variable in which to store the result of the calculation (will
              default to 0 if calculation is not performed).
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>


  <xs:complexType name="rateEachType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Identical to lv:rate, except that it requires and index with which it
        will automatically loop through the magic _CMATCH_ set and multiply the
        calculation by its value; this creates a conditional effect.
      </xs:documentation>
    </xs:annotation>

    <xs:complexContent>
      <xs:extension base="rateTypeSansYields">
        <xs:attribute name="index" type="indexNameType">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Set the index to use for summing over the _CMATCH_ set.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="yields" type="yieldsNameType">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Optional variable in which to store the result of the calculation (will
              default to 0 if calculation is not performed).

              If not provided, will prefix the value of @generates.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="generates" type="yieldsNameType">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Produces a generating function as vector @generates
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="gensym" type="symbolType">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Symbol to use for display of generator
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="dim" type="xs:string">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Number of dimensions as integer or alias.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>


  <xs:complexType name="rateEachTemplateType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Generates lv:rate-each, applying the given template (simply removes
        boilerplate template application at the root level)

        The template is expected to accept an @index@ parameter.
      </xs:documentation>
    </xs:annotation>

    <xs:complexContent>
      <xs:extension base="rateCommon">
        <xs:sequence>
          <xs:element name="class" minOccurs="0" maxOccurs="unbounded">
            <xs:complexType>
              <xs:attribute name="ref" type="classNameType" use="required" />
            </xs:complexType>
          </xs:element>
          <xs:element name="with-param" type="withParamType" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>

        <xs:attribute name="name" type="templateNameType">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Template to apply
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="yields" type="yieldsNameType" use="required">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Variable in which to store the result of the calculation (will
              default to 0 if calculation is not performed).
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="generates">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Produces a generating function as vector @generates
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="gensym" type="symbolType">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Symbol to use for display of generator
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="keep" type="xs:boolean">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Compile the rate block even if it does not contribute to the
              final premium (that is---is outside the dependency tree of
              lv:yields)

              This is useful for calculating supplemental data that does not
              directly contribute to the premium.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="local" type="xs:boolean">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              The symbol associated with the rate block should never be exported
              (similar to a private member in Object-Oriented languages, or
              static definitions in C)
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>


  <xs:group name="templateParamGenGroup">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Permits default value generation.
      </xs:documentation>
    </xs:annotation>

    <xs:choice>
      <xs:element name="text">
        <xs:complexType>
          <xs:simpleContent>
            <xs:extension base="xs:string">
              <xs:attribute name="unique" type="xs:boolean" />
            </xs:extension>
          </xs:simpleContent>
        </xs:complexType>
      </xs:element>

      <xs:element name="param-value">
        <xs:complexType>
          <xs:attribute name="name" type="xs:string" use="required" />

          <xs:attribute name="ucfirst" type="xs:boolean">
            <xs:annotation>
              <xs:documentation xml:lang="en">
                Converts the first character of the value to uppercase
              </xs:documentation>
            </xs:annotation>
          </xs:attribute>

          <xs:attribute name="upper" type="xs:boolean">
            <xs:annotation>
              <xs:documentation xml:lang="en">
                Converts the string to uppercase
              </xs:documentation>
            </xs:annotation>
          </xs:attribute>

          <xs:attribute name="lower" type="xs:boolean">
            <xs:annotation>
              <xs:documentation xml:lang="en">
                Converts the string to lowercase
              </xs:documentation>
            </xs:annotation>
          </xs:attribute>

          <xs:attribute name="snake" type="xs:boolean">
            <xs:annotation>
              <xs:documentation xml:lang="en">
                Converts '-' to '_'
              </xs:documentation>
            </xs:annotation>
          </xs:attribute>

          <xs:attribute name="rmdash" type="xs:boolean">
            <xs:annotation>
              <xs:documentation xml:lang="en">
                Converts '-' to ''
              </xs:documentation>
            </xs:annotation>
          </xs:attribute>

          <xs:attribute name="dash" type="xs:boolean">
            <xs:annotation>
              <xs:documentation xml:lang="en">
                Converts spaces to dashes
              </xs:documentation>
            </xs:annotation>
          </xs:attribute>

          <xs:attribute name="identifier" type="xs:string">
            <xs:annotation>
              <xs:documentation xml:lang="en">
                Strip all characters that do not constitute a valid
                object identifier (for use in genrating names)
              </xs:documentation>
            </xs:annotation>
          </xs:attribute>
        </xs:complexType>
      </xs:element>

      <xs:element name="param-inherit">
        <xs:complexType>
          <xs:attribute name="meta" type="xs:string" use="required" />
        </xs:complexType>
      </xs:element>

      <xs:element name="param-add">
        <xs:complexType>
          <xs:attribute name="name" type="xs:string" use="required" />

          <xs:attribute name="value" type="xs:string">
            <xs:annotation>
              <xs:documentation xml:lang="en">
                Value to add to param (assumed to be a numeric param)
              </xs:documentation>
            </xs:annotation>
          </xs:attribute>
        </xs:complexType>
      </xs:element>

      <xs:element name="param-class-to-yields">
        <xs:annotation>
          <xs:documentation xml:lang="en">
            Converts a class name to its @yields variable
          </xs:documentation>
        </xs:annotation>

        <xs:complexType>
          <xs:attribute name="name" type="xs:string" use="required" />
        </xs:complexType>
      </xs:element>

      <xs:element name="param-sym-value">
        <xs:annotation>
          <xs:documentation xml:lang="en">
            Retrieve symbol metadata.
          </xs:documentation>
        </xs:annotation>

        <xs:complexType>
          <xs:attribute name="name" type="xs:string" use="required" />
          <xs:anyAttribute namespace="##any" processContents="lax" />
        </xs:complexType>
      </xs:element>
    </xs:choice>
  </xs:group>


  <xs:element name="param-copy">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="param-meta" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:attribute name="name" type="xs:string" use="required" />
            <xs:attribute name="value" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>

      <xs:attribute name="name" type="xs:string" use="required" />

      <xs:attribute name="expand" type="xs:boolean">
        <xs:annotation>
          <xs:documentation xml:lang="en">
            Result of param copy should trigger template param expansion has if
            the copied nodes were a part of the template itself.

            Without this option, param expansion is not performed on the copied
            nodes for that pass, meaning that the copied nodes will be
            unaffected by the template.
          </xs:documentation>
        </xs:annotation>
      </xs:attribute>
    </xs:complexType>
  </xs:element>

  <!-- TODO: if -->
  <xs:element name="unless">
    <xs:complexType mixed="true">
      <xs:sequence>
        <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
      </xs:sequence>

      <xs:anyAttribute namespace="##any" processContents="lax" />
    </xs:complexType>
  </xs:element>


  <xs:complexType name="templateParamType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Declares a parameter available for replacement within the template.

        Notice how, unlike parameters for raters and functions, this parameter
        does not require a type; this is because all replacements are done by
        the preprocessor and, as such, all replacements are done as strings.
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:group ref="templateParamGenGroup" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>

    <xs:attribute name="name" type="templateParamNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Parameter name to be used for replacements
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="desc" type="descType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Parameter description
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <xs:complexType name="templateType" mixed="true">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Declares a template whose body may be referenced using lv:apply-template.

        Templates are a basic means of code reuse that act as macros: when
        referenced by lv:apply-template, the body of the template will be put
        in its place as if it were pasted by hand. Therefore, this achieves the
        effect of copy-and-paste without the obvious downsides of actually
        copying and pasting code.

        This permits the construction of lv:rate blocks in a more natural manner. Other
        methods of re-use include referencing previously calculated premiums (by other
        lv:rate blocks) and the use of functions; both have their downsides. Namely:

          - Premiums calculated by other lv:rate blocks yield a single float value, which
            aggregates individual indexes that may have been used during rating. As such,
            if you need those individual premiums per index, premiums from other lv:rate
            blocks cannot be used. In such a case, functions may be used.
          - Using a function requires verbose code for application and makes
            the documentation and debugging more complicated. It does, however,
            have the benefit of being able to accept arguments, which templates
            cannot do (and as such should be used whenever variable reuse is
            necessary outside the scope of the global parameter list).
          - Templates were designed with the idea that a bunch of common calculations
            could be defined that could then be applied to individual raters as a more
            natural alternative to functions. That is---the developer is accustomed to
            creating lv:rate blocks that contain calculations, not excessive function
            calls joined together with other expressions. Templates eliminate the need
            for boilerplate function application code and, because they are handled by
            the preprocessor, also generate easy-to-understand documentation and make
            debugging more natural for both developers and testers.
          - While templates do not accept arguments, they *do* permit string-replacement
            of parameters by the preprocessor. This has the benefit of being
            able to replace text as if it were done in your editor.
            Consequently, this means that the replacement can be anything that
            is considered valid by the validator/compiler.
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:element name="param" type="templateParamType" minOccurs="0" maxOccurs="unbounded" />
      <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
    </xs:sequence>

    <xs:attribute name="name" type="templateNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Template name; will be used by lv:apply-template.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="desc" type="descType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Describe purpose of the template
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
<!--/rate-->


<!--classify-->
  <xs:simpleType name="classNameType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Classification identifier; will be used to refer to the classification.
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:string">
      <xs:pattern value="[a-z-][a-z0-9-]+|@[a-z][a-zA-Z0-9_]*@" />
      <xs:minLength value="2" />
      <xs:maxLength value="75" />
    </xs:restriction>
  </xs:simpleType>


  <xs:complexType name="classifyType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Classifies data based on the provided argument list and other
        classifications. Classifications are used during rating to determine
        how premiums should be calculated in a declarative manner.

        If no classification criteria are provided, then the classification
        will always take place (implying a direct "is a" relationship between
        the rater and a particular classification).
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:group ref="classCriteria" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>

    <xs:attribute name="as" type="classNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Name of classification. Can be used to determine whether or not the
          data has been classified as such.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="any" type="xs:boolean">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Convert classification from a universal quantifier into an
          existential
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="desc" type="descType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Description of classification
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="yields" type="yieldsNameType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Optional variable in which to store a boolean set of matches (useful
          if classifying against sets)

          As an example, consider classifying as vacant land by matching on a
          set of class codes. The system will check each class code in the
          provided set against valid class codes for vacant land. Should one
          item in the set match <em>any</em> of the criteria, the
          classification will succeed and its associated index in the @yields
          identifier will be set to 1. Otherwise, the value will remain 0.

          This allows for performing conditional calculations by simply
          multiplying by the boolean value. If the value is 0, that portion of
          the equation will effectively have not happened, simulating a
          conditional.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="keep" type="xs:boolean">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Always perform the classification, even if it is unused.

          Otherwise, the system may not compile unused classifications (and so
          the classification would not occur).
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="terminate" type="xs:boolean">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Classification should result in termination (useful for eligibility
          and error conditions)
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="external" type="xs:boolean">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Classification should be compiled external to the classifier (that
          is, the classification should only be performed on-demand for rating
          purposes).

          This has the benefit of removing the classifier from the classify()
          method, which may be important for, say, asserting on final premium
          amount.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <xs:group name="classCriteria">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Criteria with which a classification may be matched.

        All criteria is driven off of the global argument list.
      </xs:documentation>
    </xs:annotation>

    <xs:choice>
      <xs:group ref="applyTemplateGroup" minOccurs="0" maxOccurs="unbounded" />
      <xs:element name="any" type="anyMatchType" />
      <xs:element name="match" type="matchType" />
      <xs:element name="join" type="joinMatchType" />
      <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
    </xs:choice>
  </xs:group>


  <xs:complexType name="anyMatchType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Succeeds if any of the child matches succeed (equivalent to an OR statement).
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:group ref="anyMatchNodes" minOccurs="1" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:group name="anyMatchNodes">
    <xs:choice>
      <xs:group ref="classCriteria" minOccurs="1" maxOccurs="unbounded" />
      <xs:element name="all" type="allMatchType" minOccurs="0" maxOccurs="unbounded" />
      <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
    </xs:choice>
  </xs:group>


  <xs:complexType name="allMatchType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Succeeds if all of the child matches succeed (equivalent to an AND statement).

        This is implied by the root lv:classify node.
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:group ref="classCriteria" minOccurs="1" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>


  <xs:complexType name="matchType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Perform a basic match against a given value or enumerated list.

        One of value or anyOf should be provided. If neither is provided, one
        may provide any condition nodes accepted by c:when; multiple will be
        combined with logical and. This provides additional flexibility
        necessary for more complicated assertions that would otherwise rely on
        convoluted regular expressions.
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:group ref="c:conditions" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>

    <xs:attribute name="on" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Name of global parameter to perform match on
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="value" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Value to match against (must be within domain of parameter). Use only
          one of this or @anyOf.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="anyOf" type="typeNameType">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Value must match any value within an enumerated list. Enumeration to
          match against must be within the domain of the parameter. USe only
          one of this or @value.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="pattern" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          JavaScript-compatible regular expression

          Forward slashes must be escaped with a backslash and opening/closing
          delimiters should not be specified.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <xs:complexType name="joinMatchType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Join matching classifiers into an lv:any block where they will be
        matched on the value TRUE.

        Each matching classifier must have a @yields attribute.
      </xs:documentation>
    </xs:annotation>

    <xs:attribute name="prefix" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Any classifier's @as attribute matching this prefix will be included
          within an lv:any block.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="all" type="xs:boolean">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Univerisal quantifier (default is existential)
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
<!--/classify-->


<xs:complexType name="yieldType">
  <xs:annotation>
    <xs:documentation xml:lang="en">
      Yields a single value (premium) representing the entire result of the
      rating process.
    </xs:documentation>
  </xs:annotation>

  <xs:sequence>
    <xs:group ref="c:calculationRoot" minOccurs="1" maxOccurs="1" />
  </xs:sequence>
</xs:complexType>


<!--extern-->
  <xs:simpleType name="externSymbolTypes">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Internal symbol types

        These are the strings used directly by the symbol map; it is
        recommended that the user use some type of abstraction (e.g. a
        template).
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:token">
      <xs:enumeration value="rate" />
      <xs:enumeration value="gen" />
      <xs:enumeration value="cgen" />
      <xs:enumeration value="param" />
      <xs:enumeration value="lparam" />
      <xs:enumeration value="const" />
      <xs:enumeration value="tpl" />
      <xs:enumeration value="type" />
    </xs:restriction>
  </xs:simpleType>


  <xs:complexType name="externType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        Declares an external symbol

        This allows a symbol to be used in a package that does not either include
        or define it. The symbol must be defined before linking.
      </xs:documentation>
    </xs:annotation>

    <xs:attribute name="name" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Symbol name
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="type" type="externSymbolTypes" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Symbol type
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="dtype" type="typeNameType" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Symbol data type
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="dim" type="xs:integer" use="required">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Symbol dimensions (0 = scalar, 1 = vector, 2 = matrix, etc)
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>

    <xs:attribute name="missing" type="xs:string">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Optional user-friendly message to output when extern is
          missing (such as how to satisfy it).
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
<!--/extern-->


<xs:element name="packageBase" type="packageBaseType" abstract="true">
  <xs:annotation>
    <xs:documentation xml:lang="en">
      Represents a single rater (calculator). This is a root node; there may be
      only one rater per document.
    </xs:documentation>
  </xs:annotation>
</xs:element>


<xs:group name="sectionGroupRoot">
  <xs:choice>
    <xs:group ref="rateGroup" minOccurs="0" maxOccurs="unbounded" />

    <xs:element name="section">
      <xs:complexType mixed="true">
        <xs:annotation>
          <xs:documentation xml:lang="en">
            Denotes a group of common data.  The section title will
            become a heading in the documentation.
          </xs:documentation>
        </xs:annotation>

        <!-- XXX: duplicated -->
        <xs:choice maxOccurs="unbounded">
          <xs:group ref="importGroup" minOccurs="0" maxOccurs="unbounded" />
          <xs:element name="extern" type="externType" minOccurs="0" maxOccurs="unbounded" />
          <xs:element name="meta" type="metaType" minOccurs="0" maxOccurs="unbounded" />
          <xs:element name="param" type="paramType" minOccurs="0" maxOccurs="unbounded" />
          <xs:element name="typedef" type="typedefType" minOccurs="0" maxOccurs="unbounded" />
          <xs:element name="const" type="constType" minOccurs="0" maxOccurs="unbounded" />
          <xs:group ref="classifyGroup" minOccurs="0" maxOccurs="unbounded" />
          <xs:group ref="functionGroup" minOccurs="0" maxOccurs="unbounded" />
          <xs:group ref="sectionGroupRoot" minOccurs="0" maxOccurs="unbounded" />
        </xs:choice>

        <xs:attribute name="title" type="descType" use="required">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Section title to appear in documentation.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:complexType>
    </xs:element>
  </xs:choice>
</xs:group>


<xs:group name="applyTemplateGroup">
  <xs:choice>
    <!-- any of the below can be enclosed within a template -->
    <xs:element name="apply-template" type="applyTemplateType" />
    <xs:element name="inline-template" type="inlineTemplateType" />

    <!-- short-hand with namespace prefix -->
    <xs:any namespace="http://www.lovullo.com/rater/apply-template"
      minOccurs="0" maxOccurs="unbounded" processContents="lax" />
  </xs:choice>
</xs:group>

<xs:group name="importGroup">
  <xs:choice>
    <xs:element name="topic-of" type="topicOfType" minOccurs="0" maxOccurs="1" />
    <xs:element name="import" type="importType" minOccurs="0" maxOccurs="unbounded" />
    <xs:group ref="applyTemplateGroup" minOccurs="0" maxOccurs="unbounded" />
  </xs:choice>
</xs:group>

<xs:group name="rateGroup">
  <xs:choice>
    <xs:group ref="applyTemplateGroup" minOccurs="0" maxOccurs="unbounded" />

    <xs:element name="rate" type="rateType" minOccurs="0" maxOccurs="unbounded" />
    <xs:element name="rate-each" type="rateEachType" minOccurs="0" maxOccurs="unbounded" />
    <xs:element name="rate-each-template" type="rateEachTemplateType" minOccurs="0" maxOccurs="unbounded" />
    <xs:element name="template" type="templateType" minOccurs="0" maxOccurs="unbounded" />
  </xs:choice>
</xs:group>

<xs:group name="functionGroup">
  <xs:choice>
    <xs:element name="function" type="functionType" minOccurs="0" maxOccurs="unbounded" />
    <xs:element name="template" type="templateType" minOccurs="0" maxOccurs="unbounded" />
  </xs:choice>
</xs:group>

<xs:group name="classifyGroup">
  <xs:choice>
    <xs:element name="classify" type="classifyType" minOccurs="0" />
    <xs:element name="apply-template" type="applyTemplateType" minOccurs="0" />
    <xs:element name="inline-template" type="inlineTemplateType" minOccurs="0" />
    <xs:any namespace="http://www.lovullo.com/rater/apply-template" processContents="lax" minOccurs="0" />
  </xs:choice>
</xs:group>


<xs:complexType name="metaType">
  <xs:sequence>
    <xs:element name="prop" minOccurs="1" maxOccurs="unbounded">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="value" minOccurs="0" maxOccurs="unbounded">
            <xs:complexType>
              <xs:attribute name="name" type="constNameType" use="required" />
            </xs:complexType>
          </xs:element>

          <xs:element name="const" minOccurs="0" maxOccurs="unbounded">
            <xs:complexType>
              <xs:attribute name="value" type="xs:string" use="required" />
            </xs:complexType>
          </xs:element>
        </xs:sequence>

        <xs:attribute name="name" type="xs:string" use="required" />
      </xs:complexType>
    </xs:element>
  </xs:sequence>
</xs:complexType>


<xs:complexType name="packageBaseType" abstract="true"
                mixed="true">
  <xs:annotation>
    <xs:documentation xml:lang="en">
      Base type that defines elements and attributes acceptable by any package
      (note that a rater is considered to be a concrete package).
    </xs:documentation>
  </xs:annotation>

  <xs:choice maxOccurs="unbounded">
    <xs:group ref="importGroup" minOccurs="0" maxOccurs="unbounded" />
    <xs:element name="extern" type="externType" minOccurs="0" maxOccurs="unbounded" />
    <xs:element name="meta" type="metaType" minOccurs="0" maxOccurs="unbounded" />
    <xs:element name="const" type="constType" minOccurs="0" maxOccurs="unbounded" />
    <xs:element name="param" type="paramType" minOccurs="0" maxOccurs="unbounded" />
    <xs:element name="typedef" type="typedefType" minOccurs="0" maxOccurs="unbounded" />
    <xs:group ref="classifyGroup" minOccurs="0" maxOccurs="unbounded" />
    <xs:group ref="functionGroup" minOccurs="0" maxOccurs="unbounded" />
    <xs:group ref="sectionGroupRoot" minOccurs="0" maxOccurs="unbounded" />

    <!-- intended for code generators -->
    <xs:element name="__external-data" minOccurs="0" maxOccurs="1">
      <xs:complexType>
        <xs:sequence>
          <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
        </xs:sequence>
      </xs:complexType>
    </xs:element>

    <xs:element name="yield" type="yieldType" minOccurs="0" maxOccurs="1">
      <xs:annotation>
        <xs:documentation xml:lang="en">
          Entry point for a program package; yields final result.

          This will result in an error if the package is not a program.
        </xs:documentation>
      </xs:annotation>
    </xs:element>

    <!-- with how dynamic the system is, maintaining this XSD is becoming
         cumbersome; we need to generate one -->
    <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
  </xs:choice>

  <xs:attribute name="name" type="packageNameType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        UNIX-style package name that may be used to identify the package. Must
        match the name of the file, sans the ``.xml'' extension.
      </xs:documentation>
    </xs:annotation>
  </xs:attribute>
</xs:complexType>


<xs:element name="rater">
  <xs:annotation>
    <xs:documentation xml:lang="en">
      Represents a single rater (calculator). This is a root node; there may be
      only one rater per document. All raters yield a final premium.
    </xs:documentation>
  </xs:annotation>

  <xs:complexType>
    <xs:complexContent>
      <xs:extension base="packageBaseType" />
    </xs:complexContent>
  </xs:complexType>
</xs:element>


<xs:element name="package">
  <xs:annotation>
    <xs:documentation xml:lang="en">
      Represents a reusable package that may be included in raters or other
      packages. This is a root node; there may be only one per document.
    </xs:documentation>
  </xs:annotation>

  <xs:complexType>
    <xs:complexContent>
      <xs:extension base="packageBaseType">
        <!-- TODO: make required after @desc is removed -->
        <xs:attribute name="title" type="descType">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Package title.  This is used as a user-friendly package
              name, and as the heading for generated documentation.

              This replaces the previous <tt>@desc</tt> attribute,
              which existed prior to the literate implementation.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="desc" type="descType">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Deprecated; use @title.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="program" type="xs:boolean">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Package contains an entry point can may be linked into an
              executable.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <!-- used only by core packages -->
        <xs:attribute name="core" type="xs:boolean">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Used to indicate that the package is contained within the rating
              framework itself. <strong>Do not use for your own
              packages.</strong>
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="debug" type="xs:boolean">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Setting this to "true" will enable pretty sweet debugging features that
              will make your life more tolerable (and perhaps even pleasant).
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>

        <xs:attribute name="auto-keep-imports" type="xs:boolean">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Automatically treat all symbols as if they had @keep set.

              This ensures that all imported symbols will be present in
              the compiled output.  This is generally not desired, since
              it will inflate the output by including unused symbols.

              N.B.: Currently only keeps classifications and their
              generators!

              This is of limited use outside of specialized settings, such
              as the UI classifier.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>


        <xs:attribute name="keep-elig-class" type="xs:boolean">
          <xs:annotation>
            <xs:documentation xml:lang="en">
              Mark generated eligibility classification with @keep.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:element>


<xs:element name="template" type="templateType">
  <xs:annotation>
    <xs:documentation xml:lang="en">
      Templates may exist as the root node in their own file for auto-loading.
    </xs:documentation>
  </xs:annotation>
</xs:element>

</xs:schema>