pro-editor-schema 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -50,7 +50,6 @@ __export(index_exports, {
50
50
  DELETION_SCHEMA: () => DELETION_SCHEMA,
51
51
  DIALOGUE_SCHEMA: () => DIALOGUE_SCHEMA,
52
52
  DIALOGUE_TAG: () => DIALOGUE_TAG,
53
- ELEMENT_ROLE: () => ELEMENT_ROLE,
54
53
  ELEMENT_SCHEMAS: () => ELEMENT_SCHEMAS,
55
54
  ELEMENT_TAGS: () => ELEMENT_TAGS,
56
55
  ELE_ID_ATTRIBUTE: () => ELE_ID_ATTRIBUTE,
@@ -205,28 +204,38 @@ __export(index_exports, {
205
204
  U_SCHEMA: () => U_SCHEMA,
206
205
  createElement: () => createElement,
207
206
  findAttributeDefinitionByName: () => findAttributeDefinitionByName,
207
+ findSchemaByCode: () => findSchemaByCode,
208
208
  findSchemaByElement: () => findSchemaByElement,
209
- findSchemaByTag: () => findSchemaByTag,
210
209
  getAttributeName: () => getAttributeName,
211
210
  isAttributeRestricted: () => isAttributeRestricted,
212
211
  isIgnoredAttribute: () => isIgnoredAttribute,
213
- isIgnoredElement: () => isIgnoredElement
212
+ isIgnoredElement: () => isIgnoredElement,
213
+ validateAttributes: () => validateAttributes,
214
+ validateConsecutiveFootnoteCues: () => validateConsecutiveFootnoteCues,
215
+ validateConsecutiveFootnotes: () => validateConsecutiveFootnotes,
216
+ validateElement: () => validateElement,
217
+ validateElementAgainstSchema: () => validateElementAgainstSchema,
218
+ validateFootnoteCue: () => validateFootnoteCue,
219
+ validateFootnotes: () => validateFootnotes,
220
+ validateLinkend: () => validateLinkend,
221
+ validateLinkends: () => validateLinkends,
222
+ validateXml: () => validateXml
214
223
  });
215
224
  module.exports = __toCommonJS(index_exports);
216
225
 
217
226
  // src/schema/utils/createSchema.ts
218
227
  var createSchema = ({
228
+ code,
219
229
  kind,
220
230
  tag,
221
- role,
222
231
  requiredAttributes,
223
232
  optionalAttributes,
224
233
  allowedChildTagNames
225
234
  }) => {
226
235
  return {
236
+ code,
227
237
  kind,
228
238
  tag,
229
- role,
230
239
  requiredAttributes,
231
240
  optionalAttributes,
232
241
  allowedChildTagNames: new Set(allowedChildTagNames)
@@ -308,6 +317,7 @@ var ATOM_TAGS_ALLOWED_CHILDREN = [
308
317
 
309
318
  // src/schema/elementSchemas/atoms/b.ts
310
319
  var B_SCHEMA = createSchema({
320
+ code: "b",
311
321
  kind: "atom",
312
322
  tag: B_TAG,
313
323
  requiredAttributes: [...ID_ATTRS],
@@ -315,21 +325,11 @@ var B_SCHEMA = createSchema({
315
325
  allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
316
326
  });
317
327
 
318
- // src/schema/schema.types.ts
319
- var ELEMENT_ROLE = /* @__PURE__ */ ((ELEMENT_ROLE2) => {
320
- ELEMENT_ROLE2["QUERYCOMMENTSWRAPPER"] = "QUERYCOMMENTSWRAPPER";
321
- ELEMENT_ROLE2["HEADING"] = "HEADING";
322
- ELEMENT_ROLE2["FOOTNOTE"] = "FOOTNOTE";
323
- ELEMENT_ROLE2["INS"] = "INS";
324
- ELEMENT_ROLE2["DEL"] = "DEL";
325
- return ELEMENT_ROLE2;
326
- })(ELEMENT_ROLE || {});
327
-
328
328
  // src/schema/elementSchemas/atoms/commentQuerySection.ts
329
329
  var COMMENT_QUERY_SECTION_SCHEMA = createSchema({
330
330
  kind: "atom",
331
331
  tag: SPAN_TAG,
332
- role: "QUERYCOMMENTSWRAPPER" /* QUERYCOMMENTSWRAPPER */,
332
+ code: "commentQuerySection",
333
333
  requiredAttributes: [...ID_ATTRS, "id"],
334
334
  optionalAttributes: [...TRACK_CHANGES_ATTRS, "title"],
335
335
  allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
@@ -349,9 +349,9 @@ var INLINE_ELEMENT_TAGS_ALLOWED_CHILDREN = [
349
349
 
350
350
  // src/schema/elementSchemas/atoms/deletion.ts
351
351
  var DELETION_SCHEMA = createSchema({
352
+ code: "deletion",
352
353
  kind: "atom",
353
354
  tag: SPAN_TAG,
354
- role: "DEL" /* DEL */,
355
355
  requiredAttributes: [...TRACK_CHANGES_ATTRS, ...ID_ATTRS],
356
356
  optionalAttributes: [],
357
357
  allowedChildTagNames: [
@@ -362,6 +362,7 @@ var DELETION_SCHEMA = createSchema({
362
362
 
363
363
  // src/schema/elementSchemas/atoms/emphasis.ts
364
364
  var EMPHASIS_SCHEMA = createSchema({
365
+ code: "emphasis",
365
366
  kind: "atom",
366
367
  tag: EMPHASIS_TAG,
367
368
  requiredAttributes: [...ID_ATTRS],
@@ -378,6 +379,7 @@ var EMPHASIS_SCHEMA = createSchema({
378
379
 
379
380
  // src/schema/elementSchemas/atoms/highlightmark.ts
380
381
  var HIGHLIGHTMARK_SCHEMA = createSchema({
382
+ code: "highlightmark",
381
383
  kind: "atom",
382
384
  tag: HIGHLIGHTMARK_TAG,
383
385
  requiredAttributes: [...ID_ATTRS],
@@ -387,6 +389,7 @@ var HIGHLIGHTMARK_SCHEMA = createSchema({
387
389
 
388
390
  // src/schema/elementSchemas/atoms/i.ts
389
391
  var I_SCHEMA = createSchema({
392
+ code: "i",
390
393
  kind: "atom",
391
394
  tag: I_TAG,
392
395
  requiredAttributes: [...ID_ATTRS],
@@ -396,9 +399,9 @@ var I_SCHEMA = createSchema({
396
399
 
397
400
  // src/schema/elementSchemas/atoms/insertion.ts
398
401
  var INSERTION_SCHEMA = createSchema({
402
+ code: "insertion",
399
403
  kind: "atom",
400
404
  tag: SPAN_TAG,
401
- role: "INS" /* INS */,
402
405
  requiredAttributes: [...TRACK_CHANGES_ATTRS, ...ID_ATTRS],
403
406
  optionalAttributes: [],
404
407
  allowedChildTagNames: [
@@ -409,6 +412,7 @@ var INSERTION_SCHEMA = createSchema({
409
412
 
410
413
  // src/schema/elementSchemas/atoms/sc.ts
411
414
  var SC_SCHEMA = createSchema({
415
+ code: "sc",
412
416
  kind: "atom",
413
417
  tag: SC_TAG,
414
418
  requiredAttributes: [...ID_ATTRS],
@@ -418,6 +422,7 @@ var SC_SCHEMA = createSchema({
418
422
 
419
423
  // src/schema/elementSchemas/atoms/strike.ts
420
424
  var STRIKE_SCHEMA = createSchema({
425
+ code: "strike",
421
426
  kind: "atom",
422
427
  tag: STRIKE_TAG,
423
428
  requiredAttributes: [...ID_ATTRS],
@@ -427,6 +432,7 @@ var STRIKE_SCHEMA = createSchema({
427
432
 
428
433
  // src/schema/elementSchemas/atoms/sub.ts
429
434
  var SUB_SCHEMA = createSchema({
435
+ code: "sub",
430
436
  kind: "atom",
431
437
  tag: SUB_TAG,
432
438
  requiredAttributes: [...ID_ATTRS],
@@ -436,6 +442,7 @@ var SUB_SCHEMA = createSchema({
436
442
 
437
443
  // src/schema/elementSchemas/atoms/sup.ts
438
444
  var SUP_SCHEMA = createSchema({
445
+ code: "sup",
439
446
  kind: "atom",
440
447
  tag: SUP_TAG,
441
448
  requiredAttributes: [...ID_ATTRS],
@@ -445,6 +452,7 @@ var SUP_SCHEMA = createSchema({
445
452
 
446
453
  // src/schema/elementSchemas/atoms/u.ts
447
454
  var U_SCHEMA = createSchema({
455
+ code: "u",
448
456
  kind: "atom",
449
457
  tag: U_TAG,
450
458
  requiredAttributes: [...ID_ATTRS],
@@ -454,6 +462,7 @@ var U_SCHEMA = createSchema({
454
462
 
455
463
  // src/schema/elementSchemas/atoms/content.ts
456
464
  var CONTENT_SCHEMA = createSchema({
465
+ code: "content",
457
466
  kind: "inline",
458
467
  tag: CONTENT_TAG,
459
468
  requiredAttributes: [...ID_ATTRS],
@@ -472,6 +481,7 @@ var CONTENT_SCHEMA = createSchema({
472
481
 
473
482
  // src/schema/elementSchemas/atoms/comment.ts
474
483
  var COMMENT_SCHEMA = createSchema({
484
+ code: "comment",
475
485
  kind: "inline",
476
486
  tag: COMMENT_TAG,
477
487
  requiredAttributes: [...ID_ATTRS, "id"],
@@ -494,6 +504,7 @@ var COMMENT_SCHEMA = createSchema({
494
504
 
495
505
  // src/schema/elementSchemas/atoms/query.ts
496
506
  var QUERY_SCHEMA = createSchema({
507
+ code: "query",
497
508
  kind: "inline",
498
509
  tag: QUERY_TAG,
499
510
  requiredAttributes: [...ID_ATTRS, "id"],
@@ -516,6 +527,7 @@ var QUERY_SCHEMA = createSchema({
516
527
 
517
528
  // src/schema/elementSchemas/atoms/reply.ts
518
529
  var REPLY_SCHEMA = createSchema({
530
+ code: "reply",
519
531
  kind: "inline",
520
532
  tag: REPLY_TAG,
521
533
  requiredAttributes: [...ID_ATTRS, "id"],
@@ -687,6 +699,7 @@ var GROUP_ELEMENTS_TAGS = [
687
699
 
688
700
  // src/schema/elementSchemas/elements/authors/authorgroup.ts
689
701
  var AUTHORGROUP_SCHEMA = createSchema({
702
+ code: "authorgroup",
690
703
  kind: "group",
691
704
  tag: AUTHORGROUP_TAG,
692
705
  requiredAttributes: [...ID_ATTRS],
@@ -699,6 +712,7 @@ var AUTHORGROUP_SCHEMA = createSchema({
699
712
 
700
713
  // src/schema/elementSchemas/elements/authors/author.ts
701
714
  var AUTHOR_SCHEMA = createSchema({
715
+ code: "author",
702
716
  kind: "group",
703
717
  tag: AUTHOR_TAG,
704
718
  requiredAttributes: [...ID_ATTRS],
@@ -715,6 +729,7 @@ var AUTHOR_SCHEMA = createSchema({
715
729
 
716
730
  // src/schema/elementSchemas/elements/authors/olink.ts
717
731
  var OLINK_SCHEMA = createSchema({
732
+ code: "olink",
718
733
  kind: "element",
719
734
  tag: OLINK_TAG,
720
735
  requiredAttributes: [...ID_ATTRS],
@@ -724,6 +739,7 @@ var OLINK_SCHEMA = createSchema({
724
739
 
725
740
  // src/schema/elementSchemas/elements/authors/personname.ts
726
741
  var PERSONNAME_SCHEMA = createSchema({
742
+ code: "personname",
727
743
  kind: "group",
728
744
  tag: PERSONNAME_TAG,
729
745
  requiredAttributes: [...ID_ATTRS],
@@ -737,6 +753,7 @@ var PERSONNAME_SCHEMA = createSchema({
737
753
 
738
754
  // src/schema/elementSchemas/elements/authors/firstname.ts
739
755
  var FIRSTNAME_SCHEMA = createSchema({
756
+ code: "firstname",
740
757
  kind: "element",
741
758
  tag: FIRSTNAME_TAG,
742
759
  requiredAttributes: [...ID_ATTRS],
@@ -746,6 +763,7 @@ var FIRSTNAME_SCHEMA = createSchema({
746
763
 
747
764
  // src/schema/elementSchemas/elements/authors/surname.ts
748
765
  var SURNAME_SCHEMA = createSchema({
766
+ code: "surname",
749
767
  kind: "element",
750
768
  tag: SURNAME_TAG,
751
769
  requiredAttributes: [...ID_ATTRS],
@@ -755,6 +773,7 @@ var SURNAME_SCHEMA = createSchema({
755
773
 
756
774
  // src/schema/elementSchemas/elements/authors/honorific.ts
757
775
  var HONORIFIC_SCHEMA = createSchema({
776
+ code: "honorific",
758
777
  kind: "element",
759
778
  tag: HONORIFIC_TAG,
760
779
  requiredAttributes: [...ID_ATTRS],
@@ -764,6 +783,7 @@ var HONORIFIC_SCHEMA = createSchema({
764
783
 
765
784
  // src/schema/elementSchemas/elements/authors/orgname.ts
766
785
  var ORGNAME_SCHEMA = createSchema({
786
+ code: "orgname",
767
787
  kind: "element",
768
788
  tag: ORGNAME_TAG,
769
789
  requiredAttributes: [...ID_ATTRS],
@@ -773,6 +793,7 @@ var ORGNAME_SCHEMA = createSchema({
773
793
 
774
794
  // src/schema/elementSchemas/elements/authors/email.ts
775
795
  var EMAIL_SCHEMA = createSchema({
796
+ code: "email",
776
797
  kind: "element",
777
798
  tag: EMAIL_TAG,
778
799
  requiredAttributes: [...ID_ATTRS],
@@ -782,6 +803,7 @@ var EMAIL_SCHEMA = createSchema({
782
803
 
783
804
  // src/schema/elementSchemas/elements/authors/org.ts
784
805
  var ORG_SCHEMA = createSchema({
806
+ code: "org",
785
807
  kind: "element",
786
808
  tag: ORG_TAG,
787
809
  requiredAttributes: [...ID_ATTRS],
@@ -791,6 +813,7 @@ var ORG_SCHEMA = createSchema({
791
813
 
792
814
  // src/schema/elementSchemas/elements/authors/affiliation.ts
793
815
  var AFFILIATION_SCHEMA = createSchema({
816
+ code: "affiliation",
794
817
  kind: "group",
795
818
  tag: AFFILIATION_TAG,
796
819
  requiredAttributes: [...ID_ATTRS],
@@ -800,6 +823,7 @@ var AFFILIATION_SCHEMA = createSchema({
800
823
 
801
824
  // src/schema/elementSchemas/elements/degrees.ts
802
825
  var DEGREES_SCHEMA = createSchema({
826
+ code: "degrees",
803
827
  kind: "element",
804
828
  tag: DEGREES_TAG,
805
829
  requiredAttributes: [...ID_ATTRS],
@@ -809,6 +833,7 @@ var DEGREES_SCHEMA = createSchema({
809
833
 
810
834
  // src/schema/elementSchemas/elements/dialogue/line.ts
811
835
  var LINE_SCHEMA = createSchema({
836
+ code: "line",
812
837
  kind: "element",
813
838
  tag: LINE_TAG,
814
839
  requiredAttributes: [...ID_ATTRS],
@@ -824,6 +849,7 @@ var LINE_SCHEMA = createSchema({
824
849
 
825
850
  // src/schema/elementSchemas/elements/dialogue/speaker.ts
826
851
  var SPEAKER_SCHEMA = createSchema({
852
+ code: "speaker",
827
853
  kind: "element",
828
854
  tag: SPEAKER_TAG,
829
855
  requiredAttributes: [...ID_ATTRS],
@@ -839,6 +865,7 @@ var SPEAKER_SCHEMA = createSchema({
839
865
 
840
866
  // src/schema/elementSchemas/elements/dialogue/dialogue.ts
841
867
  var DIALOGUE_SCHEMA = createSchema({
868
+ code: "dialogue",
842
869
  kind: "group",
843
870
  tag: DIALOGUE_TAG,
844
871
  requiredAttributes: [...ID_ATTRS],
@@ -858,6 +885,7 @@ var DIALOGUE_SCHEMA = createSchema({
858
885
 
859
886
  // src/schema/elementSchemas/elements/equation.ts
860
887
  var EQUATION_SCHEMA = createSchema({
888
+ code: "equation",
861
889
  kind: "element",
862
890
  tag: EQUATION_TAG,
863
891
  requiredAttributes: [],
@@ -867,6 +895,7 @@ var EQUATION_SCHEMA = createSchema({
867
895
 
868
896
  // src/schema/elementSchemas/elements/figure/img.ts
869
897
  var IMG_SCHEMA = createSchema({
898
+ code: "img",
870
899
  kind: "element",
871
900
  tag: IMG_TAG,
872
901
  requiredAttributes: [...ID_ATTRS, "src", "format"],
@@ -887,6 +916,7 @@ var IMG_SCHEMA = createSchema({
887
916
 
888
917
  // src/schema/elementSchemas/elements/figure/alttext.ts
889
918
  var ALTTEXT_SCHEMA = createSchema({
919
+ code: "alttext",
890
920
  kind: "group",
891
921
  tag: ALTTEXT_TAG,
892
922
  requiredAttributes: [],
@@ -896,6 +926,7 @@ var ALTTEXT_SCHEMA = createSchema({
896
926
 
897
927
  // src/schema/elementSchemas/elements/figure/imageobject.ts
898
928
  var IMAGEOBJECT_SCHEMA = createSchema({
929
+ code: "imageobject",
899
930
  kind: "group",
900
931
  tag: IMAGEOBJECT_TAG,
901
932
  requiredAttributes: [...ID_ATTRS],
@@ -908,6 +939,7 @@ var IMAGEOBJECT_SCHEMA = createSchema({
908
939
 
909
940
  // src/schema/elementSchemas/elements/figure/mediaobject.ts
910
941
  var MEDIAOBJECT_SCHEMA = createSchema({
942
+ code: "mediaobject",
911
943
  kind: "group",
912
944
  tag: MEDIAOBJECT_TAG,
913
945
  requiredAttributes: [...ID_ATTRS],
@@ -917,6 +949,7 @@ var MEDIAOBJECT_SCHEMA = createSchema({
917
949
 
918
950
  // src/schema/elementSchemas/elements/figure/caption1.ts
919
951
  var CAPTION_SCHEMA = createSchema({
952
+ code: "caption1",
920
953
  kind: "group",
921
954
  tag: CAPTION_TAG,
922
955
  requiredAttributes: [...ID_ATTRS],
@@ -926,6 +959,7 @@ var CAPTION_SCHEMA = createSchema({
926
959
 
927
960
  // src/schema/elementSchemas/elements/figure/figsource.ts
928
961
  var FIGSOURCE_SCHEMA = createSchema({
962
+ code: "figsource",
929
963
  kind: "element",
930
964
  tag: FIGSOURCE_TAG,
931
965
  requiredAttributes: [...ID_ATTRS],
@@ -938,6 +972,7 @@ var FIGSOURCE_SCHEMA = createSchema({
938
972
 
939
973
  // src/schema/elementSchemas/elements/figure/fignote.ts
940
974
  var FIGNOTE_SCHEMA = createSchema({
975
+ code: "fignote",
941
976
  kind: "element",
942
977
  tag: FIGNOTE_TAG,
943
978
  requiredAttributes: [...ID_ATTRS],
@@ -950,6 +985,7 @@ var FIGNOTE_SCHEMA = createSchema({
950
985
 
951
986
  // src/schema/elementSchemas/elements/figure/figure.ts
952
987
  var FIGURE_SCHEMA = createSchema({
988
+ code: "figure1",
953
989
  kind: "group",
954
990
  tag: FIGURE_TAG,
955
991
  requiredAttributes: [...ID_ATTRS, "xmlid"],
@@ -970,6 +1006,7 @@ var FIGURE_SCHEMA = createSchema({
970
1006
 
971
1007
  // src/schema/elementSchemas/elements/footnote.ts
972
1008
  var FOOTNOTE_SCHEMA = createSchema({
1009
+ code: "footnote",
973
1010
  kind: "element",
974
1011
  tag: FOOTNOTE_TAG,
975
1012
  requiredAttributes: [
@@ -991,6 +1028,7 @@ var FOOTNOTE_SCHEMA = createSchema({
991
1028
 
992
1029
  // src/schema/elementSchemas/elements/footnoteNumber.ts
993
1030
  var FOOTNOTE_NUMBER_SCHEMA = createSchema({
1031
+ code: "footnoteno",
994
1032
  kind: "element",
995
1033
  tag: FOOTNOTE_NUMBER_TAG,
996
1034
  requiredAttributes: [...ID_ATTRS],
@@ -1000,6 +1038,7 @@ var FOOTNOTE_NUMBER_SCHEMA = createSchema({
1000
1038
 
1001
1039
  // src/schema/elementSchemas/elements/informalfigure.ts
1002
1040
  var INFORMALFIGURE_SCHEMA = createSchema({
1041
+ code: "informalfigure",
1003
1042
  kind: "element",
1004
1043
  tag: INFORMALFIGURE_TAG,
1005
1044
  requiredAttributes: [...ID_ATTRS],
@@ -1012,6 +1051,7 @@ var INFORMALFIGURE_SCHEMA = createSchema({
1012
1051
 
1013
1052
  // src/schema/elementSchemas/elements/keywords/keywordset.ts
1014
1053
  var KEYWORDSET_SCHEMA = createSchema({
1054
+ code: "keywordset",
1015
1055
  kind: "group",
1016
1056
  tag: KEYWORDSET_TAG,
1017
1057
  requiredAttributes: [
@@ -1032,6 +1072,7 @@ var KEYWORDSET_SCHEMA = createSchema({
1032
1072
 
1033
1073
  // src/schema/elementSchemas/elements/keywords/keyword.ts
1034
1074
  var KEYWORD_SCHEMA = createSchema({
1075
+ code: "keyword",
1035
1076
  kind: "element",
1036
1077
  tag: KEYWORD_TAG,
1037
1078
  requiredAttributes: [...ID_ATTRS],
@@ -1041,6 +1082,7 @@ var KEYWORD_SCHEMA = createSchema({
1041
1082
 
1042
1083
  // src/schema/elementSchemas/elements/keywords/punc.ts
1043
1084
  var PUNC_SCHEMA = createSchema({
1085
+ code: "punc",
1044
1086
  kind: "element",
1045
1087
  tag: PUNC_TAG,
1046
1088
  requiredAttributes: [...ID_ATTRS],
@@ -1048,8 +1090,66 @@ var PUNC_SCHEMA = createSchema({
1048
1090
  allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1049
1091
  });
1050
1092
 
1093
+ // src/schema/elementSchemas/inlineElements/footnoteLink.ts
1094
+ var FOOTNOTE_LINK_SCHEMA = createSchema({
1095
+ code: "footnote1",
1096
+ kind: "inline",
1097
+ tag: FOOTNOTE_LINK_TAG,
1098
+ requiredAttributes: [...ID_ATTRS],
1099
+ optionalAttributes: ["linkend"],
1100
+ allowedChildTagNames: [{ tagName: SUP_TAG, required: true }]
1101
+ });
1102
+
1103
+ // src/schema/elementSchemas/inlineElements/inlineequation.ts
1104
+ var INLINEEQUATION_SCHEMA = createSchema({
1105
+ code: "inlineequation",
1106
+ kind: "inline",
1107
+ tag: INLINEEQUATION_TAG,
1108
+ requiredAttributes: [...ID_ATTRS],
1109
+ optionalAttributes: ["linkend"],
1110
+ allowedChildTagNames: []
1111
+ });
1112
+
1113
+ // src/schema/elementSchemas/inlineElements/link.ts
1114
+ var LINK_SCHEMA = createSchema({
1115
+ code: "link",
1116
+ kind: "inline",
1117
+ tag: LINK_TAG,
1118
+ requiredAttributes: [
1119
+ ...ID_ATTRS,
1120
+ "linkend",
1121
+ "data-target-id",
1122
+ {
1123
+ name: "role",
1124
+ values: ["table", "figure", "equation", "footnote", "bibr"],
1125
+ defaultValue: ""
1126
+ }
1127
+ ],
1128
+ optionalAttributes: [],
1129
+ allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1130
+ });
1131
+
1132
+ // src/schema/elementSchemas/inlineElements/uri.ts
1133
+ var URI_SCHEMA = createSchema({
1134
+ code: "uri",
1135
+ kind: "inline",
1136
+ tag: URI_TAG,
1137
+ requiredAttributes: [...ID_ATTRS],
1138
+ optionalAttributes: ["linkend"],
1139
+ allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1140
+ });
1141
+
1142
+ // src/schema/elementSchemas/inlineElements/index.ts
1143
+ var INLINE_ELEMENT_SCHEMAS = [
1144
+ URI_SCHEMA,
1145
+ FOOTNOTE_LINK_SCHEMA,
1146
+ LINK_SCHEMA,
1147
+ INLINEEQUATION_SCHEMA
1148
+ ];
1149
+
1051
1150
  // src/schema/elementSchemas/elements/label.ts
1052
1151
  var LABEL_SCHEMA = createSchema({
1152
+ code: "label1",
1053
1153
  kind: "element",
1054
1154
  tag: LABEL_TAG,
1055
1155
  requiredAttributes: [...ID_ATTRS],
@@ -1061,11 +1161,18 @@ var LABEL_SCHEMA = createSchema({
1061
1161
  defaultValue: "false"
1062
1162
  }
1063
1163
  ],
1064
- allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1164
+ allowedChildTagNames: [
1165
+ ...ATOM_TAGS_ALLOWED_CHILDREN,
1166
+ {
1167
+ tagName: LINK_TAG,
1168
+ required: false
1169
+ }
1170
+ ]
1065
1171
  });
1066
1172
 
1067
1173
  // src/schema/elementSchemas/elements/list/token.ts
1068
1174
  var TOKEN_SCHEMA = createSchema({
1175
+ code: "token",
1069
1176
  kind: "element",
1070
1177
  tag: TOKEN_TAG,
1071
1178
  requiredAttributes: [...ID_ATTRS],
@@ -1075,6 +1182,7 @@ var TOKEN_SCHEMA = createSchema({
1075
1182
 
1076
1183
  // src/schema/elementSchemas/elements/list/li.ts
1077
1184
  var LI_SCHEMA = createSchema({
1185
+ code: "li",
1078
1186
  kind: "element",
1079
1187
  tag: LI_TAG,
1080
1188
  requiredAttributes: [...ID_ATTRS],
@@ -1103,6 +1211,7 @@ var LI_SCHEMA = createSchema({
1103
1211
 
1104
1212
  // src/schema/elementSchemas/elements/list/ol.ts
1105
1213
  var OL_SCHEMA = createSchema({
1214
+ code: "ol",
1106
1215
  kind: "group",
1107
1216
  tag: OL_TAG,
1108
1217
  requiredAttributes: [...ID_ATTRS],
@@ -1139,6 +1248,7 @@ var OL_SCHEMA = createSchema({
1139
1248
 
1140
1249
  // src/schema/elementSchemas/elements/list/ul.ts
1141
1250
  var UL_SCHEMA = createSchema({
1251
+ code: "ul",
1142
1252
  kind: "group",
1143
1253
  tag: UL_TAG,
1144
1254
  requiredAttributes: [...ID_ATTRS],
@@ -1179,6 +1289,7 @@ var UL_SCHEMA = createSchema({
1179
1289
 
1180
1290
  // src/schema/elementSchemas/elements/para.ts
1181
1291
  var PARA_SCHEMA = createSchema({
1292
+ code: "para",
1182
1293
  kind: "element",
1183
1294
  tag: PARA_TAG,
1184
1295
  requiredAttributes: [...ID_ATTRS],
@@ -1204,6 +1315,7 @@ var PARA_SCHEMA = createSchema({
1204
1315
 
1205
1316
  // src/schema/elementSchemas/elements/paragraphNumberTag.ts
1206
1317
  var TAG_SCHEMA = createSchema({
1318
+ code: "tag",
1207
1319
  kind: "element",
1208
1320
  tag: TAG_TAG,
1209
1321
  requiredAttributes: [...ID_ATTRS, "data-id"],
@@ -1213,6 +1325,7 @@ var TAG_SCHEMA = createSchema({
1213
1325
 
1214
1326
  // src/schema/elementSchemas/elements/runningHeads/lrh.ts
1215
1327
  var LRH_SCHEMA = createSchema({
1328
+ code: "lrh",
1216
1329
  kind: "element",
1217
1330
  tag: LRH_TAG,
1218
1331
  requiredAttributes: [...ID_ATTRS],
@@ -1222,6 +1335,7 @@ var LRH_SCHEMA = createSchema({
1222
1335
 
1223
1336
  // src/schema/elementSchemas/elements/runningHeads/rrh.ts
1224
1337
  var RRH_SCHEMA = createSchema({
1338
+ code: "rrh",
1225
1339
  kind: "element",
1226
1340
  tag: RRH_TAG,
1227
1341
  requiredAttributes: [...ID_ATTRS],
@@ -1231,6 +1345,7 @@ var RRH_SCHEMA = createSchema({
1231
1345
 
1232
1346
  // src/schema/elementSchemas/elements/source.ts
1233
1347
  var SOURCE_SCHEMA = createSchema({
1348
+ code: "source1",
1234
1349
  kind: "element",
1235
1350
  tag: SOURCE_TAG,
1236
1351
  requiredAttributes: [...ID_ATTRS],
@@ -1247,6 +1362,7 @@ var SOURCE_SCHEMA = createSchema({
1247
1362
 
1248
1363
  // src/schema/elementSchemas/elements/subtitle.ts
1249
1364
  var SUBTITLE_SCHEMA = createSchema({
1365
+ code: "subtitle1",
1250
1366
  kind: "element",
1251
1367
  tag: SUBTITLE_TAG,
1252
1368
  requiredAttributes: [...ID_ATTRS],
@@ -1262,6 +1378,7 @@ var SUBTITLE_SCHEMA = createSchema({
1262
1378
 
1263
1379
  // src/schema/elementSchemas/elements/table/tp.ts
1264
1380
  var TP_SCHEMA = createSchema({
1381
+ code: "tp",
1265
1382
  kind: "element",
1266
1383
  tag: TP_TAG,
1267
1384
  requiredAttributes: [],
@@ -1274,6 +1391,7 @@ var TP_SCHEMA = createSchema({
1274
1391
 
1275
1392
  // src/schema/elementSchemas/elements/table/td.ts
1276
1393
  var TD_SCHEMA = createSchema({
1394
+ code: "td",
1277
1395
  kind: "group",
1278
1396
  tag: TD_TAG,
1279
1397
  requiredAttributes: [...ID_ATTRS],
@@ -1287,6 +1405,7 @@ var TD_SCHEMA = createSchema({
1287
1405
 
1288
1406
  // src/schema/elementSchemas/elements/table/tr.ts
1289
1407
  var TR_SCHEMA = createSchema({
1408
+ code: "tr",
1290
1409
  kind: "group",
1291
1410
  tag: TR_TAG,
1292
1411
  requiredAttributes: [],
@@ -1296,6 +1415,7 @@ var TR_SCHEMA = createSchema({
1296
1415
 
1297
1416
  // src/schema/elementSchemas/elements/table/thead.ts
1298
1417
  var THEAD_SCHEMA = createSchema({
1418
+ code: "thead",
1299
1419
  kind: "element",
1300
1420
  tag: THEAD_TAG,
1301
1421
  requiredAttributes: [],
@@ -1305,6 +1425,7 @@ var THEAD_SCHEMA = createSchema({
1305
1425
 
1306
1426
  // src/schema/elementSchemas/elements/table/tbody.ts
1307
1427
  var TBODY_SCHEMA = createSchema({
1428
+ code: "tbody",
1308
1429
  kind: "group",
1309
1430
  tag: TBODY_TAG,
1310
1431
  requiredAttributes: [],
@@ -1314,6 +1435,7 @@ var TBODY_SCHEMA = createSchema({
1314
1435
 
1315
1436
  // src/schema/elementSchemas/elements/table/htmlTable.ts
1316
1437
  var HTML_TABLE_SCHEMA = createSchema({
1438
+ code: "table",
1317
1439
  kind: "group",
1318
1440
  tag: HTML_TABLE_TAG,
1319
1441
  requiredAttributes: [],
@@ -1326,6 +1448,7 @@ var HTML_TABLE_SCHEMA = createSchema({
1326
1448
 
1327
1449
  // src/schema/elementSchemas/elements/table/tgroup.ts
1328
1450
  var TGROUP_SCHEMA = createSchema({
1451
+ code: "tgroup",
1329
1452
  kind: "group",
1330
1453
  tag: TGROUP_TAG,
1331
1454
  requiredAttributes: [...ID_ATTRS, "cols"],
@@ -1335,6 +1458,7 @@ var TGROUP_SCHEMA = createSchema({
1335
1458
 
1336
1459
  // src/schema/elementSchemas/elements/table/tblfn.ts
1337
1460
  var TBLFN_SCHEMA = createSchema({
1461
+ code: "tblfn",
1338
1462
  kind: "element",
1339
1463
  tag: TBLFN_TAG,
1340
1464
  requiredAttributes: [...ID_ATTRS],
@@ -1347,6 +1471,7 @@ var TBLFN_SCHEMA = createSchema({
1347
1471
 
1348
1472
  // src/schema/elementSchemas/elements/table/tblsource.ts
1349
1473
  var TBLSOURCE_SCHEMA = createSchema({
1474
+ code: "tblsource",
1350
1475
  kind: "element",
1351
1476
  tag: TBLSOURCE_TAG,
1352
1477
  requiredAttributes: [],
@@ -1356,6 +1481,7 @@ var TBLSOURCE_SCHEMA = createSchema({
1356
1481
 
1357
1482
  // src/schema/elementSchemas/elements/table/table1.ts
1358
1483
  var TABLE_SCHEMA = createSchema({
1484
+ code: "table1",
1359
1485
  kind: "group",
1360
1486
  tag: TABLE_TAG,
1361
1487
  requiredAttributes: [...ID_ATTRS, "xmlid", "role"],
@@ -1378,6 +1504,7 @@ var TABLE_SCHEMA = createSchema({
1378
1504
 
1379
1505
  // src/schema/elementSchemas/elements/title.ts
1380
1506
  var TITLE_SCHEMA = createSchema({
1507
+ code: "title1",
1381
1508
  kind: "element",
1382
1509
  tag: TITLE_TAG,
1383
1510
  requiredAttributes: [...ID_ATTRS],
@@ -1453,6 +1580,7 @@ var ELEMENT_SCHEMAS = [
1453
1580
 
1454
1581
  // src/schema/elementSchemas/groupElements/abstract.ts
1455
1582
  var ABSTRACT_SCHEMA = createSchema({
1583
+ code: "abstract1",
1456
1584
  kind: "group",
1457
1585
  tag: ABSTRACT_TAG,
1458
1586
  requiredAttributes: [
@@ -1481,6 +1609,7 @@ var ABSTRACT_SCHEMA = createSchema({
1481
1609
 
1482
1610
  // src/schema/elementSchemas/groupElements/appendix.ts
1483
1611
  var APPENDIX_SCHEMA = createSchema({
1612
+ code: "appendix",
1484
1613
  kind: "group",
1485
1614
  tag: APPENDIX_TAG,
1486
1615
  requiredAttributes: [...ID_ATTRS, "id", "xmlid"],
@@ -1494,6 +1623,7 @@ var APPENDIX_SCHEMA = createSchema({
1494
1623
 
1495
1624
  // src/schema/elementSchemas/groupElements/blockquote.ts
1496
1625
  var BLOCKQUOTE_SCHEMA = createSchema({
1626
+ code: "blockquote",
1497
1627
  kind: "group",
1498
1628
  tag: BLOCKQUOTE_TAG,
1499
1629
  requiredAttributes: [...ID_ATTRS],
@@ -1519,6 +1649,7 @@ var BLOCKQUOTE_SCHEMA = createSchema({
1519
1649
 
1520
1650
  // src/schema/elementSchemas/groupElements/box.ts
1521
1651
  var BOX_SCHEMA = createSchema({
1652
+ code: "sidebar",
1522
1653
  kind: "group",
1523
1654
  tag: SIDEBAR_TAG,
1524
1655
  requiredAttributes: [
@@ -1546,6 +1677,7 @@ var BOX_SCHEMA = createSchema({
1546
1677
 
1547
1678
  // src/schema/elementSchemas/groupElements/chapter.ts
1548
1679
  var CHAPTER_SCHEMA = createSchema({
1680
+ code: "chapter",
1549
1681
  kind: "group",
1550
1682
  tag: CHAPTER_TAG,
1551
1683
  requiredAttributes: [...ID_ATTRS, "xmlid"],
@@ -1579,6 +1711,7 @@ var CHAPTER_SCHEMA = createSchema({
1579
1711
 
1580
1712
  // src/schema/elementSchemas/groupElements/epigraph.ts
1581
1713
  var EPIGRAPH_SCHEMA = createSchema({
1714
+ code: "epigraph",
1582
1715
  kind: "group",
1583
1716
  tag: EPIGRAPH_TAG,
1584
1717
  requiredAttributes: [...ID_ATTRS],
@@ -1596,9 +1729,9 @@ var EPIGRAPH_SCHEMA = createSchema({
1596
1729
 
1597
1730
  // src/schema/elementSchemas/groupElements/footnoteSection.ts
1598
1731
  var FOOTNOTE_SECTION_SCHEMA = createSchema({
1732
+ code: "footnoteSection",
1599
1733
  kind: "group",
1600
1734
  tag: SECTION_TAG,
1601
- role: "FOOTNOTE" /* FOOTNOTE */,
1602
1735
  requiredAttributes: [
1603
1736
  ...ID_ATTRS,
1604
1737
  {
@@ -1616,9 +1749,9 @@ var FOOTNOTE_SECTION_SCHEMA = createSchema({
1616
1749
 
1617
1750
  // src/schema/elementSchemas/groupElements/heading.ts
1618
1751
  var HEADING_SCHEMA = createSchema({
1752
+ code: "heading",
1619
1753
  kind: "group",
1620
1754
  tag: SECTION_TAG,
1621
- role: "HEADING" /* HEADING */,
1622
1755
  requiredAttributes: [
1623
1756
  ...ID_ATTRS,
1624
1757
  "xmlid",
@@ -1651,6 +1784,7 @@ var HEADING_SCHEMA = createSchema({
1651
1784
 
1652
1785
  // src/schema/elementSchemas/groupElements/info.ts
1653
1786
  var INFO_SCHEMA = createSchema({
1787
+ code: "info1",
1654
1788
  kind: "group",
1655
1789
  tag: INFO_TAG,
1656
1790
  requiredAttributes: [...ID_ATTRS],
@@ -1667,6 +1801,7 @@ var INFO_SCHEMA = createSchema({
1667
1801
 
1668
1802
  // src/schema/elementSchemas/groupElements/poem.ts
1669
1803
  var POEM_SCHEMA = createSchema({
1804
+ code: "poem",
1670
1805
  kind: "group",
1671
1806
  tag: POEM_TAG,
1672
1807
  requiredAttributes: [...ID_ATTRS],
@@ -1695,59 +1830,6 @@ var GROUP_ELEMENT_SCHEMAS = [
1695
1830
  AFFILIATION_SCHEMA
1696
1831
  ];
1697
1832
 
1698
- // src/schema/elementSchemas/inlineElements/footnoteLink.ts
1699
- var FOOTNOTE_LINK_SCHEMA = createSchema({
1700
- kind: "inline",
1701
- tag: FOOTNOTE_LINK_TAG,
1702
- requiredAttributes: [...ID_ATTRS],
1703
- optionalAttributes: ["linkend"],
1704
- allowedChildTagNames: [{ tagName: SUP_TAG, required: true }]
1705
- });
1706
-
1707
- // src/schema/elementSchemas/inlineElements/inlineequation.ts
1708
- var INLINEEQUATION_SCHEMA = createSchema({
1709
- kind: "inline",
1710
- tag: INLINEEQUATION_TAG,
1711
- requiredAttributes: [...ID_ATTRS],
1712
- optionalAttributes: ["linkend"],
1713
- allowedChildTagNames: []
1714
- });
1715
-
1716
- // src/schema/elementSchemas/inlineElements/link.ts
1717
- var LINK_SCHEMA = createSchema({
1718
- kind: "inline",
1719
- tag: LINK_TAG,
1720
- requiredAttributes: [
1721
- ...ID_ATTRS,
1722
- "linkend",
1723
- "data-target-id",
1724
- {
1725
- name: "role",
1726
- values: ["table", "figure", "equation", "footnote"],
1727
- defaultValue: ""
1728
- }
1729
- ],
1730
- optionalAttributes: [],
1731
- allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1732
- });
1733
-
1734
- // src/schema/elementSchemas/inlineElements/uri.ts
1735
- var URI_SCHEMA = createSchema({
1736
- kind: "inline",
1737
- tag: URI_TAG,
1738
- requiredAttributes: [...ID_ATTRS],
1739
- optionalAttributes: ["linkend"],
1740
- allowedChildTagNames: [...ATOM_TAGS_ALLOWED_CHILDREN]
1741
- });
1742
-
1743
- // src/schema/elementSchemas/inlineElements/index.ts
1744
- var INLINE_ELEMENT_SCHEMAS = [
1745
- URI_SCHEMA,
1746
- FOOTNOTE_LINK_SCHEMA,
1747
- LINK_SCHEMA,
1748
- INLINEEQUATION_SCHEMA
1749
- ];
1750
-
1751
1833
  // src/schema/schemas.ts
1752
1834
  var SCHEMAS = [
1753
1835
  ...ATOM_SCHEMAS,
@@ -1756,10 +1838,7 @@ var SCHEMAS = [
1756
1838
  ...INLINE_ELEMENT_SCHEMAS
1757
1839
  ];
1758
1840
  var SCHEMA_MAP = new Map(
1759
- SCHEMAS.map((schema) => [
1760
- schema.tag.toUpperCase() + (schema.role?.toUpperCase() ?? ""),
1761
- schema
1762
- ])
1841
+ SCHEMAS.map((schema) => [schema.code, schema])
1763
1842
  );
1764
1843
 
1765
1844
  // src/schema/shared/ignoredElements.ts
@@ -1768,11 +1847,7 @@ var IGNORED_ELEMENT_SELECTORS = [
1768
1847
  "span.printlabel",
1769
1848
  "span.refIcon",
1770
1849
  "span.missLink",
1771
- "span.ref-drag",
1772
- "inlineequation",
1773
- // TODO: remove this once we have a proper inlineequation schema
1774
- "equation"
1775
- // TODO: remove this once we have a proper equation schema
1850
+ "span.ref-drag"
1776
1851
  ];
1777
1852
 
1778
1853
  // src/schema/shared/ignoredAttributes.ts
@@ -1798,41 +1873,36 @@ var isIgnoredAttribute = (attribute) => IGNORED_ATTRIBUTES.includes(attribute) |
1798
1873
  (startsWith) => attribute.startsWith(startsWith)
1799
1874
  );
1800
1875
  var isIgnoredElement = (element) => IGNORED_ELEMENT_SELECTORS.some((selector) => element.matches(selector));
1801
- var findSchemaByTag = (tagName, role) => {
1802
- if (role) {
1803
- return SCHEMA_MAP.get(tagName.toUpperCase() + role);
1804
- }
1805
- return SCHEMA_MAP.get(tagName.toUpperCase());
1806
- };
1876
+ var findSchemaByCode = (code) => SCHEMA_MAP.get(code);
1807
1877
  var findSchemaByElement = (element) => {
1808
1878
  const isInsertion = element.classList.contains("ins");
1809
1879
  const isDeletion = element.classList.contains("del");
1810
1880
  const isQueryComment = element.classList.contains("cmtQurySection");
1811
1881
  const role = element.getAttribute("role");
1882
+ if (isQueryComment) {
1883
+ return findSchemaByCode("commentQuerySection");
1884
+ }
1885
+ if (isInsertion) {
1886
+ return findSchemaByCode("insertion");
1887
+ }
1888
+ if (isDeletion) {
1889
+ return findSchemaByCode("deletion");
1890
+ }
1812
1891
  if (role) {
1813
1892
  if (role.startsWith("H")) {
1814
- return SCHEMA_MAP.get(
1815
- element.tagName.toUpperCase() + "HEADING" /* HEADING */
1816
- );
1893
+ return findSchemaByCode("heading");
1817
1894
  }
1818
1895
  if (role === "ch" || role === "bk") {
1819
- return SCHEMA_MAP.get(
1820
- element.tagName.toUpperCase() + "FOOTNOTE" /* FOOTNOTE */
1821
- );
1896
+ return findSchemaByCode("footnoteSection");
1822
1897
  }
1823
1898
  }
1824
- if (isInsertion) {
1825
- return SCHEMA_MAP.get(element.tagName.toUpperCase() + "INS" /* INS */);
1826
- }
1827
- if (isDeletion) {
1828
- return SCHEMA_MAP.get(element.tagName.toUpperCase() + "DEL" /* DEL */);
1899
+ const candidates = [...SCHEMA_MAP.values()].filter(
1900
+ (schema) => schema.tag === element.tagName.toUpperCase()
1901
+ );
1902
+ if (candidates.length > 0) {
1903
+ return candidates[0];
1829
1904
  }
1830
- if (isQueryComment) {
1831
- return SCHEMA_MAP.get(
1832
- element.tagName.toUpperCase() + "QUERYCOMMENTSWRAPPER" /* QUERYCOMMENTSWRAPPER */
1833
- );
1834
- }
1835
- return SCHEMA_MAP.get(element.tagName.toUpperCase());
1905
+ return void 0;
1836
1906
  };
1837
1907
  var isAttributeRestricted = (attr) => typeof attr !== "string";
1838
1908
  var getAttributeName = (attribute) => typeof attribute === "string" ? attribute : attribute.name;
@@ -1859,6 +1929,420 @@ var createElement = ({
1859
1929
  }
1860
1930
  return element;
1861
1931
  };
1932
+
1933
+ // src/validation/utils/retrieveTextIgnoringNodesWithSelector.ts
1934
+ var retrieveTextIgnoringNodesWithSelector = (element, selector = ".del") => {
1935
+ const clonedElement = element.cloneNode(true);
1936
+ for (const delElement of clonedElement.querySelectorAll(selector)) {
1937
+ delElement.remove();
1938
+ }
1939
+ return clonedElement.textContent || "";
1940
+ };
1941
+
1942
+ // src/validation/validateFootnotes.ts
1943
+ var extractFootnoteNumber = (footnote) => {
1944
+ if (!footnote) return "no label";
1945
+ const footnoteNumberText = retrieveTextIgnoringNodesWithSelector(footnote);
1946
+ const footnoteNumber = Number(footnoteNumberText);
1947
+ if (!Number.isInteger(footnoteNumber) || footnoteNumber <= 0) {
1948
+ return "no label";
1949
+ }
1950
+ return footnoteNumber;
1951
+ };
1952
+ var validateFootnoteCue = (footnoteElement, root) => {
1953
+ const errors = [];
1954
+ const store = footnoteElement.getAttribute("store");
1955
+ if (!store) {
1956
+ return errors;
1957
+ }
1958
+ const linkend = footnoteElement.getAttribute("xmlid") || "";
1959
+ const footnoteNumber = footnoteElement.querySelector(
1960
+ FOOTNOTE_NUMBER_SCHEMA.tag
1961
+ );
1962
+ const footnoteLink = root.querySelector(
1963
+ `${FOOTNOTE_LINK_SCHEMA.tag}[linkend='${CSS.escape(linkend)}']`
1964
+ );
1965
+ if (footnoteLink) {
1966
+ return errors;
1967
+ }
1968
+ if (!footnoteNumber) {
1969
+ errors.push({
1970
+ id: `footnote-number-missing-${store}`,
1971
+ store,
1972
+ title: "Footnote number missing",
1973
+ kind: "missing",
1974
+ description: "The footnote number is missing. Please add it to the footnote.",
1975
+ level: "blocker"
1976
+ });
1977
+ }
1978
+ const label = extractFootnoteNumber(footnoteNumber);
1979
+ errors.push({
1980
+ id: `unreferenced-footnote-${store}`,
1981
+ store,
1982
+ title: "Unreferenced footnote",
1983
+ kind: "unlinked",
1984
+ description: `The footnote ${label} is not referenced to any footnote cue in this chapter. Please reference it in the chapter.`,
1985
+ level: "blocker"
1986
+ });
1987
+ return errors;
1988
+ };
1989
+ var validateConsecutiveFootnotes = (root) => {
1990
+ const footnotes = Array.from(root.querySelectorAll(FOOTNOTE_SCHEMA.tag));
1991
+ if (footnotes.length === 0) {
1992
+ return [];
1993
+ }
1994
+ for (const [index, footnote] of footnotes.entries()) {
1995
+ const store = footnote.getAttribute("store") || "";
1996
+ const expectedNumber = index + 1;
1997
+ const footnoteNumberElement = footnote.querySelector(
1998
+ FOOTNOTE_NUMBER_SCHEMA.tag
1999
+ );
2000
+ if (!footnoteNumberElement) {
2001
+ continue;
2002
+ }
2003
+ const label = extractFootnoteNumber(footnoteNumberElement);
2004
+ if (label === expectedNumber) {
2005
+ continue;
2006
+ }
2007
+ return [
2008
+ {
2009
+ id: `non-consecutive-footnote-numbers-${store}`,
2010
+ store,
2011
+ title: "Non-consecutive footnote numbers",
2012
+ kind: "missing",
2013
+ description: "Footnote numbers must be consecutive. Please reorder the footnotes.",
2014
+ level: "warning"
2015
+ }
2016
+ ];
2017
+ }
2018
+ return [];
2019
+ };
2020
+ var validateConsecutiveFootnoteCues = (root) => {
2021
+ const footnoteLinks = Array.from(
2022
+ root.querySelectorAll(FOOTNOTE_LINK_SCHEMA.tag)
2023
+ );
2024
+ if (footnoteLinks.length === 0) {
2025
+ return [];
2026
+ }
2027
+ for (const [index, footnoteLink] of footnoteLinks.entries()) {
2028
+ const store = footnoteLink.getAttribute("store") || "";
2029
+ const expectedNumber = index + 1;
2030
+ const label = extractFootnoteNumber(footnoteLink);
2031
+ if (label === expectedNumber) {
2032
+ continue;
2033
+ }
2034
+ return [
2035
+ {
2036
+ id: `non-consecutive-footnote-cues-${store}`,
2037
+ store,
2038
+ title: "Non-consecutive footnote cues",
2039
+ kind: "missing",
2040
+ description: "Footnote cues must be consecutive. Please reorder the footnote cues.",
2041
+ level: "warning"
2042
+ }
2043
+ ];
2044
+ }
2045
+ return [];
2046
+ };
2047
+ var validateFootnotes = (root) => {
2048
+ const errors = [];
2049
+ for (const footnote of root.querySelectorAll(FOOTNOTE_SCHEMA.tag)) {
2050
+ errors.push(...validateFootnoteCue(footnote, root));
2051
+ }
2052
+ errors.push(...validateConsecutiveFootnotes(root));
2053
+ errors.push(...validateConsecutiveFootnoteCues(root));
2054
+ return errors;
2055
+ };
2056
+
2057
+ // src/validation/validateLinkend.ts
2058
+ var findElementInCurrentChapter = (root, linkend) => {
2059
+ return !!root.querySelector(`[xmlid='${CSS.escape(linkend)}']`);
2060
+ };
2061
+ var findElementInReferenceChapters = (linkend, referenceChapterLinkends) => {
2062
+ return referenceChapterLinkends.includes(linkend);
2063
+ };
2064
+ var validateLinkend = (linkElement, root, referenceChapterLinkends = []) => {
2065
+ const store = linkElement.getAttribute("store");
2066
+ if (!store) {
2067
+ return [];
2068
+ }
2069
+ const linkend = linkElement.getAttribute("linkend");
2070
+ if (!linkend) {
2071
+ return [];
2072
+ }
2073
+ const isLinkFootnoteCue = linkElement.tagName.toUpperCase() === FOOTNOTE_LINK_SCHEMA.tag;
2074
+ if (isLinkFootnoteCue) {
2075
+ if (findElementInCurrentChapter(root, linkend)) {
2076
+ return [];
2077
+ }
2078
+ return [
2079
+ {
2080
+ id: `unlinked-footnote-cue-${store}`,
2081
+ store,
2082
+ title: "Unlinked footnote cue",
2083
+ kind: "unlinked",
2084
+ description: "This footnote cue is not referenced to any footnote in this chapter. Please link it again manually.",
2085
+ level: "blocker"
2086
+ }
2087
+ ];
2088
+ }
2089
+ if (findElementInCurrentChapter(root, linkend) || findElementInReferenceChapters(linkend, referenceChapterLinkends)) {
2090
+ return [];
2091
+ }
2092
+ return [
2093
+ {
2094
+ id: `unlinked-element-${store}`,
2095
+ store,
2096
+ title: "Unlinked element",
2097
+ kind: "unlinked",
2098
+ description: "This link is not referenced to any element in the current chapter or reference chapters. Please link it again manually.",
2099
+ level: "blocker"
2100
+ }
2101
+ ];
2102
+ };
2103
+ var validateLinkends = (root, referenceChapterLinkends = []) => {
2104
+ const errors = [];
2105
+ for (const linkElement of root.querySelectorAll("[linkend]")) {
2106
+ errors.push(
2107
+ ...validateLinkend(linkElement, root, referenceChapterLinkends)
2108
+ );
2109
+ }
2110
+ return errors;
2111
+ };
2112
+
2113
+ // src/validation/validateAttributes.ts
2114
+ var validateAttributes = (element, schema) => {
2115
+ const errors = [];
2116
+ const definitions = [
2117
+ ...schema.requiredAttributes,
2118
+ ...schema.optionalAttributes
2119
+ ];
2120
+ for (const attribute of schema.requiredAttributes) {
2121
+ const name = getAttributeName(attribute);
2122
+ if (!element.hasAttribute(name)) {
2123
+ errors.push({
2124
+ id: `missing-required-attribute-${name}`,
2125
+ store: element.id,
2126
+ title: `Missing required attribute "${name}"`,
2127
+ level: "warning",
2128
+ kind: "missing",
2129
+ description: `The attribute "${name}" is required but not present in the element.`
2130
+ });
2131
+ }
2132
+ }
2133
+ for (const name of element.getAttributeNames()) {
2134
+ if (isIgnoredAttribute(name)) {
2135
+ continue;
2136
+ }
2137
+ const definition = findAttributeDefinitionByName(definitions, name);
2138
+ if (!definition) {
2139
+ errors.push({
2140
+ id: `unexpected-attribute-${name}`,
2141
+ store: element.id,
2142
+ title: `Unexpected attribute "${name}"`,
2143
+ level: "warning",
2144
+ kind: "forbidden",
2145
+ description: `The attribute "${name}" is not allowed in this element.`
2146
+ });
2147
+ continue;
2148
+ }
2149
+ if (!isAttributeRestricted(definition)) {
2150
+ continue;
2151
+ }
2152
+ const value = element.getAttribute(name);
2153
+ if (value === null) {
2154
+ continue;
2155
+ }
2156
+ if (!definition.values.includes(value)) {
2157
+ errors.push({
2158
+ id: `forbidden-attribute-value-${name}-${value}`,
2159
+ store: element.id,
2160
+ title: `Invalid attribute value "${value}"`,
2161
+ level: "warning",
2162
+ kind: "forbidden",
2163
+ description: `The attribute "${name}" has an invalid value "${value}".`
2164
+ });
2165
+ }
2166
+ }
2167
+ return errors;
2168
+ };
2169
+
2170
+ // src/validation/validateChildren.ts
2171
+ var validateElementAgainstSchema = (element, schema) => {
2172
+ const errors = [];
2173
+ if (element.tagName.toUpperCase() !== schema.tag) {
2174
+ errors.push({
2175
+ id: `expected-element-${schema.tag}`,
2176
+ store: element.id,
2177
+ title: `Expected ${schema.tag}, got ${element.tagName}`,
2178
+ level: "warning",
2179
+ kind: "forbidden",
2180
+ description: `The element is not allowed in this context.`
2181
+ });
2182
+ }
2183
+ if (schema.code === "insertion" && !element.classList.contains("ins")) {
2184
+ errors.push({
2185
+ id: `missing-class-ins-${element.id}`,
2186
+ store: element.id,
2187
+ title: 'Missing class "ins" for insertion element',
2188
+ level: "warning",
2189
+ kind: "missing",
2190
+ description: `The element is missing the class "ins".`
2191
+ });
2192
+ }
2193
+ if (schema.code === "deletion" && !element.classList.contains("del")) {
2194
+ errors.push({
2195
+ id: `missing-class-del-${element.id}`,
2196
+ store: element.id,
2197
+ title: 'Missing class "del" for deletion element',
2198
+ level: "warning",
2199
+ kind: "missing",
2200
+ description: `The element is missing the class "del".`
2201
+ });
2202
+ }
2203
+ if (schema.code === "commentQuerySection" && !element.classList.contains("cmtQurySection")) {
2204
+ errors.push({
2205
+ id: `missing-class-cmtQurySection-${element.id}`,
2206
+ store: element.id,
2207
+ title: 'Missing class "cmtQurySection" for comment query section',
2208
+ level: "warning",
2209
+ kind: "missing",
2210
+ description: `The element is missing the class "cmtQurySection".`
2211
+ });
2212
+ }
2213
+ errors.push(...validateAttributes(element, schema));
2214
+ errors.push(...validateChildren(element, schema));
2215
+ return errors;
2216
+ };
2217
+ var validateChildren = (element, schema) => {
2218
+ const errors = [];
2219
+ const childElements = [...element.children].filter(
2220
+ (child) => !isIgnoredElement(child)
2221
+ );
2222
+ const allowedChildren = [...schema.allowedChildTagNames];
2223
+ for (const child of childElements) {
2224
+ const childTag = child.tagName.toUpperCase();
2225
+ const allowedChild = allowedChildren.find(
2226
+ (candidate) => candidate.tagName === childTag
2227
+ );
2228
+ if (!allowedChild) {
2229
+ errors.push({
2230
+ id: `forbidden-child-element-${child.tagName}`,
2231
+ store: child.id,
2232
+ title: `Forbidden child element ${child.tagName}`,
2233
+ level: "warning",
2234
+ kind: "forbidden",
2235
+ description: `The child element ${child.tagName} is not allowed in this context.`
2236
+ });
2237
+ continue;
2238
+ }
2239
+ const childSchema = findSchemaByElement(child);
2240
+ if (!childSchema) {
2241
+ errors.push({
2242
+ id: `no-schema-found-for-child-element-${child.tagName}`,
2243
+ store: child.id,
2244
+ title: `No schema found for child element ${child.tagName}`,
2245
+ level: "warning",
2246
+ kind: "missing",
2247
+ description: `No schema found for child element ${child.tagName}.`
2248
+ });
2249
+ continue;
2250
+ }
2251
+ errors.push(...validateElementAgainstSchema(child, childSchema));
2252
+ }
2253
+ for (const allowedChild of allowedChildren) {
2254
+ if (!allowedChild.required) {
2255
+ continue;
2256
+ }
2257
+ const hasChild = childElements.some(
2258
+ (child) => child.tagName.toUpperCase() === allowedChild.tagName
2259
+ );
2260
+ if (!hasChild) {
2261
+ errors.push({
2262
+ id: `missing-required-child-element-${allowedChild.tagName}`,
2263
+ store: element.id,
2264
+ title: `Missing required child element ${allowedChild.tagName}`,
2265
+ level: "warning",
2266
+ kind: "missing",
2267
+ description: `The child element ${allowedChild.tagName} is required but not present.`
2268
+ });
2269
+ }
2270
+ }
2271
+ if (schema.allowedChildTagNames.size === 0 && childElements.length > 0) {
2272
+ errors.push({
2273
+ id: `leaf-element-cannot-contain-child-elements-${element.id}`,
2274
+ store: element.id,
2275
+ title: "Leaf element cannot contain child elements",
2276
+ level: "warning",
2277
+ kind: "forbidden",
2278
+ description: `The element is a leaf element and cannot contain child elements.`
2279
+ });
2280
+ }
2281
+ return errors;
2282
+ };
2283
+
2284
+ // src/validation/utils/parseXML.ts
2285
+ var parseXml = (xml) => {
2286
+ const doc = new DOMParser().parseFromString(xml.trim(), "application/xml");
2287
+ const parserError = doc.querySelector("parsererror");
2288
+ if (parserError) {
2289
+ throw new Error(
2290
+ `Unable to parse XML: ${parserError.textContent ?? "unknown error"}`
2291
+ );
2292
+ }
2293
+ const element = doc.documentElement;
2294
+ if (!element) {
2295
+ throw new Error("XML string did not produce an element");
2296
+ }
2297
+ return element;
2298
+ };
2299
+
2300
+ // src/validation/validateXml.ts
2301
+ var getLinkableRoles = () => {
2302
+ const linkRoleDefinition = findAttributeDefinitionByName(
2303
+ LINK_SCHEMA.requiredAttributes,
2304
+ "role"
2305
+ );
2306
+ if (!linkRoleDefinition) {
2307
+ return [];
2308
+ }
2309
+ if (isAttributeRestricted(linkRoleDefinition)) {
2310
+ return linkRoleDefinition.values;
2311
+ }
2312
+ return [];
2313
+ };
2314
+ var validateElement = (element, root, referenceChapterLinkends) => {
2315
+ if (isIgnoredElement(element)) {
2316
+ return [];
2317
+ }
2318
+ const errors = [];
2319
+ const schema = findSchemaByElement(element);
2320
+ if (schema) {
2321
+ errors.push(...validateElementAgainstSchema(element, schema));
2322
+ const role = element.getAttribute("role") || "";
2323
+ const linkableRoles = getLinkableRoles();
2324
+ if (schema.tag === LINK_SCHEMA.tag && linkableRoles.includes(role) || schema.tag === FOOTNOTE_LINK_SCHEMA.tag) {
2325
+ errors.push(...validateLinkend(element, root, referenceChapterLinkends));
2326
+ }
2327
+ if (schema.tag === FOOTNOTE_SCHEMA.tag) {
2328
+ errors.push(...validateFootnoteCue(element, root));
2329
+ }
2330
+ }
2331
+ for (const child of Array.from(element.children)) {
2332
+ errors.push(...validateElement(child, root, referenceChapterLinkends));
2333
+ }
2334
+ return errors;
2335
+ };
2336
+ var validateXml = (xml, referenceChapterLinkends) => {
2337
+ const root = parseXml(xml);
2338
+ const errors = [];
2339
+ errors.push(...validateConsecutiveFootnotes(root));
2340
+ errors.push(...validateConsecutiveFootnoteCues(root));
2341
+ for (const child of Array.from(root.children)) {
2342
+ errors.push(...validateElement(child, root, referenceChapterLinkends));
2343
+ }
2344
+ return errors;
2345
+ };
1862
2346
  // Annotate the CommonJS export names for ESM import in node:
1863
2347
  0 && (module.exports = {
1864
2348
  ABSTRACT_SCHEMA,
@@ -1891,7 +2375,6 @@ var createElement = ({
1891
2375
  DELETION_SCHEMA,
1892
2376
  DIALOGUE_SCHEMA,
1893
2377
  DIALOGUE_TAG,
1894
- ELEMENT_ROLE,
1895
2378
  ELEMENT_SCHEMAS,
1896
2379
  ELEMENT_TAGS,
1897
2380
  ELE_ID_ATTRIBUTE,
@@ -2046,10 +2529,20 @@ var createElement = ({
2046
2529
  U_SCHEMA,
2047
2530
  createElement,
2048
2531
  findAttributeDefinitionByName,
2532
+ findSchemaByCode,
2049
2533
  findSchemaByElement,
2050
- findSchemaByTag,
2051
2534
  getAttributeName,
2052
2535
  isAttributeRestricted,
2053
2536
  isIgnoredAttribute,
2054
- isIgnoredElement
2537
+ isIgnoredElement,
2538
+ validateAttributes,
2539
+ validateConsecutiveFootnoteCues,
2540
+ validateConsecutiveFootnotes,
2541
+ validateElement,
2542
+ validateElementAgainstSchema,
2543
+ validateFootnoteCue,
2544
+ validateFootnotes,
2545
+ validateLinkend,
2546
+ validateLinkends,
2547
+ validateXml
2055
2548
  });