-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChapter10.html
More file actions
1693 lines (1420 loc) · 101 KB
/
Copy pathChapter10.html
File metadata and controls
1693 lines (1420 loc) · 101 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Chapter 10 — Validation and Quality Assurance</title>
<link rel="icon" type="image/png" href="FundsXML-Logo.png">
<style>
:root {
--ink: #1a1a1a;
--ink-soft: #444;
--ink-muted: #6b7280;
--accent: #0b5394;
--accent-soft: #e3ecf6;
--accent-hover: #083d73;
--rule: #d0d7de;
--rule-soft: #e8ecf1;
--bg: #fbfbf8;
--paper: #ffffff;
--callout: #f3f6fb;
--row-alt: #f6f8fa;
--code-bg: #f4f6f9;
--code-ink: #22272e;
--tok-tag: #0b5394;
--tok-attr: #1a7f4b;
--tok-string: #a8410a;
--tok-comment: #6b7280;
--tok-decl: #7048c4;
--tok-punct: #6b7684;
--tip: #1a7f4b;
--tip-bg: #effaf3;
--warn: #a85a00;
--warn-bg: #fff5e6;
--example: #5b4ab3;
--example-bg: #f1eefb;
--shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
--shadow-md: 0 2px 8px rgba(15,23,42,0.08);
}
html[data-theme="dark"] {
--ink: #e6e8eb;
--ink-soft: #b1b6bd;
--ink-muted: #858a93;
--accent: #79b8ff;
--accent-soft: #17304b;
--accent-hover: #a8d0ff;
--rule: #2e333b;
--rule-soft: #24282f;
--bg: #101214;
--paper: #191c1f;
--callout: #1b2432;
--row-alt: #171a1e;
--code-bg: #161a1f;
--code-ink: #d9dde3;
--tok-tag: #7cb7f5;
--tok-attr: #7fd0a3;
--tok-string: #e0966a;
--tok-comment: #8a919c;
--tok-decl: #c3aef2;
--tok-punct: #9aa2ad;
--tip: #6bd494;
--tip-bg: #122820;
--warn: #e7a76b;
--warn-bg: #2b1f12;
--example: #b4a6f4;
--example-bg: #231d37;
--shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
--shadow-md: 0 2px 10px rgba(0,0,0,0.45);
}
html[data-theme="dark"] img { filter: brightness(0.92) contrast(1.05); }
html {
-webkit-text-size-adjust: 100%;
scroll-behavior: smooth;
}
body {
font-family: "Source Serif Pro", "Source Serif 4", Georgia, "Times New Roman", serif;
font-size: 18px;
line-height: 1.65;
color: var(--ink);
background: var(--bg);
max-width: 46em;
margin: 3em auto;
padding: 0 1.5em;
hyphens: auto;
hyphenate-limit-chars: 7 3 3;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
font-feature-settings: "kern", "liga", "calt";
}
::selection { background: var(--accent-soft); color: var(--ink); }
h1, h2, h3, h4 {
font-family: "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif;
color: var(--ink);
line-height: 1.25;
margin-top: 2em;
scroll-margin-top: 1.5em;
font-feature-settings: "kern", "liga";
letter-spacing: -0.005em;
}
h1 {
font-size: 2.1em;
border-bottom: 3px solid var(--accent);
padding-bottom: 0.3em;
margin-top: 0;
letter-spacing: -0.015em;
}
h1 .subtitle {
display: block;
font-size: 0.55em;
font-weight: 400;
font-style: italic;
color: var(--ink-soft);
margin-top: 0.4em;
letter-spacing: 0;
}
h2 {
font-size: 1.45em;
margin-top: 2.4em;
border-bottom: 1px solid var(--rule);
padding-bottom: 0.2em;
}
h3 { font-size: 1.15em; color: var(--accent); }
h4 { font-size: 1em; color: var(--ink-soft); }
p {
margin: 0.9em 0;
text-align: justify;
text-justify: inter-word;
orphans: 2;
widows: 2;
}
ul, ol { padding-left: 1.4em; }
li { margin: 0.35em 0; }
li::marker { color: var(--accent); }
strong { color: var(--ink); font-weight: 600; }
em { color: var(--ink-soft); }
hr {
border: none;
border-top: 1px solid var(--rule);
margin: 2.4em 0;
}
a {
color: var(--accent);
text-decoration: underline;
text-decoration-thickness: 1px;
text-decoration-color: rgba(11, 83, 148, 0.35);
text-underline-offset: 0.18em;
transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover {
color: var(--accent-hover);
text-decoration-color: var(--accent);
}
a:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
border-radius: 2px;
}
html[data-theme="dark"] a { text-decoration-color: rgba(121, 184, 255, 0.4); }
table {
border-collapse: collapse;
width: 100%;
margin: 1.8em 0;
font-size: 0.92em;
font-family: "Inter", -apple-system, sans-serif;
font-variant-numeric: tabular-nums lining-nums;
background: var(--paper);
border-radius: 4px;
overflow: hidden;
box-shadow: var(--shadow-sm);
}
caption {
caption-side: bottom;
text-align: left;
color: var(--ink-soft);
font-family: "Inter", sans-serif;
font-size: 0.9em;
font-style: italic;
padding: 0.6em 0.2em 0;
}
th, td {
text-align: left;
padding: 0.6em 0.85em;
border-bottom: 1px solid var(--rule-soft);
vertical-align: top;
}
th {
background: var(--callout);
border-bottom: 2px solid var(--accent);
font-weight: 600;
color: var(--ink);
}
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: var(--accent-soft); }
tbody tr:last-child td { border-bottom: none; }
blockquote {
margin: 1.4em 0;
padding: 1em 1.2em;
background: var(--callout);
border-left: 4px solid var(--accent);
color: var(--ink-soft);
font-size: 0.95em;
border-radius: 0 4px 4px 0;
}
blockquote p { margin: 0.4em 0; }
blockquote p:first-child { margin-top: 0; }
blockquote p:last-child { margin-bottom: 0; }
blockquote.tip { background: var(--tip-bg); border-color: var(--tip); }
blockquote.warning { background: var(--warn-bg); border-color: var(--warn); color: var(--ink); }
blockquote.example { background: var(--example-bg); border-color: var(--example); }
code {
font-family: "JetBrains Mono", "Source Code Pro", "SF Mono", Menlo, Consolas, monospace;
font-size: 0.9em;
background: var(--code-bg);
color: var(--code-ink);
padding: 0.1em 0.35em;
border-radius: 3px;
font-feature-settings: "liga" 0, "calt" 0;
word-break: break-word;
}
pre {
font-family: "JetBrains Mono", "Source Code Pro", "SF Mono", Menlo, Consolas, monospace;
font-size: 0.85em;
line-height: 1.55;
background: var(--code-bg);
color: var(--code-ink);
border-left: 3px solid var(--accent);
padding: 1em 1.2em;
margin: 1.4em 0;
overflow-x: auto;
hyphens: none;
tab-size: 2;
border-radius: 0 4px 4px 0;
box-shadow: var(--shadow-sm);
font-feature-settings: "liga" 0, "calt" 0;
}
pre code {
background: none;
padding: 0;
border-radius: 0;
font-size: 1em;
word-break: normal;
}
pre .tok-tag { color: var(--tok-tag); }
pre .tok-attr { color: var(--tok-attr); }
pre .tok-string { color: var(--tok-string); }
pre .tok-comment { color: var(--tok-comment); font-style: italic; }
pre .tok-decl { color: var(--tok-decl); }
pre .tok-punct { color: var(--tok-punct); }
figure { margin: 1.6em 0; text-align: center; }
figure img { max-width: 100%; height: auto; border-radius: 4px; box-shadow: var(--shadow-sm); }
figcaption {
font-family: "Inter", sans-serif;
font-size: 0.88em;
color: var(--ink-soft);
margin-top: 0.6em;
font-style: italic;
}
img { max-width: 100%; height: auto; }
.chapter-meta {
font-family: "Inter", sans-serif;
font-size: 0.85em;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--accent);
font-weight: 600;
margin-bottom: 0.6em;
}
.lead { font-size: 1.08em; color: var(--ink-soft); font-style: italic; }
.glossary-entry { margin: 0.6em 0; }
.glossary-entry strong { color: var(--accent); }
.idx { line-height: 1.55; margin: 0.15em 0; }
.idx strong { color: var(--ink); }
.index-note { font-size: 0.9em; color: var(--ink-soft); margin-bottom: 1em; }
/* --- sticky chapter nav --- */
#toc-nav {
position: fixed;
top: 0;
left: 0;
width: 18em;
max-height: 100vh;
overflow-y: auto;
background: var(--bg);
border-right: 1px solid var(--rule);
padding: 1em 0.8em 1.5em 0.8em;
font-family: "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif;
font-size: 0.72em;
line-height: 1.4;
z-index: 1000;
box-shadow: 2px 0 8px rgba(0,0,0,0.06);
transition: transform 0.25s ease;
scrollbar-width: thin;
scrollbar-color: var(--rule) transparent;
}
#toc-nav::-webkit-scrollbar { width: 6px; }
#toc-nav::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }
#toc-nav::-webkit-scrollbar-track { background: transparent; }
#toc-nav.collapsed { transform: translateX(-100%); box-shadow: none; }
#toc-nav .toc-title {
font-weight: 700;
color: var(--accent);
margin-bottom: 0.8em;
padding-bottom: 0.4em;
font-size: 1.05em;
letter-spacing: 0.03em;
border-bottom: 1px solid var(--rule-soft);
}
#toc-nav ul { list-style: none; padding: 0; margin: 0; }
#toc-nav li { margin: 0.2em 0; }
#toc-nav li.toc-h1 {
font-weight: 700;
margin-top: 0.7em;
color: var(--accent);
}
#toc-nav a {
color: var(--ink-soft);
text-decoration: none;
display: block;
padding: 0.2em 0.5em;
border-radius: 3px;
border-left: 2px solid transparent;
transition: background 0.15s, color 0.15s, border-color 0.15s;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#toc-nav a:hover { background: var(--callout); color: var(--accent); }
#toc-nav a.active {
background: var(--callout);
color: var(--accent);
border-left-color: var(--accent);
font-weight: 600;
}
#toc-toggle {
position: fixed;
top: 0.5em;
left: 0.5em;
z-index: 1001;
width: 2.1em;
height: 2.1em;
border: 1px solid var(--rule);
border-radius: 4px;
background: var(--bg);
color: var(--accent);
font-size: 1.1em;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
box-shadow: var(--shadow-sm);
transition: left 0.25s ease, transform 0.15s;
font-family: "Inter", sans-serif;
}
#toc-toggle:hover { transform: scale(1.05); }
#toc-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#toc-toggle.open { left: 18.5em; }
/* --- heading anchor links --- */
.heading-anchor {
color: var(--rule);
text-decoration: none;
font-weight: 400;
margin-left: 0.35em;
opacity: 0;
transition: opacity 0.15s;
font-size: 0.72em;
vertical-align: middle;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor { opacity: 1; color: var(--accent); }
.heading-anchor:hover { color: var(--accent-hover); }
.heading-anchor:focus-visible {
opacity: 1;
outline: 2px solid var(--accent);
outline-offset: 2px;
border-radius: 2px;
}
/* --- back-to-top button --- */
#top-btn {
position: fixed;
bottom: 1.5em;
right: 1.5em;
padding: 0.6em 1em;
background: var(--accent);
color: #fff;
border: none;
border-radius: 999px;
font-family: "Inter", -apple-system, sans-serif;
font-size: 0.85em;
font-weight: 600;
letter-spacing: 0.03em;
cursor: pointer;
opacity: 0;
pointer-events: none;
transform: translateY(6px);
transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s;
box-shadow: var(--shadow-md);
z-index: 999;
}
#top-btn.visible { opacity: 0.95; pointer-events: auto; transform: translateY(0); }
#top-btn:hover { opacity: 1; background: var(--accent-hover); }
#top-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* --- per-chapter navigation bar (standalone pages only; stripped from
the concatenated complete book by build_complete.sh) --- */
.chapter-nav {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1em;
margin: 2.5em 0;
padding: 0.9em 0;
border-top: 1px solid var(--rule);
border-bottom: 1px solid var(--rule);
font-family: "Inter", -apple-system, sans-serif;
font-size: 0.85em;
font-weight: 600;
letter-spacing: 0.02em;
}
.chapter-nav:first-child { margin-top: 0; }
.chapter-nav a {
color: var(--accent);
text-decoration: none;
padding: 0.35em 0.2em;
transition: color 0.15s;
}
.chapter-nav a:hover { color: var(--accent-hover); }
.chapter-nav .cn-toc { color: var(--ink-muted); font-weight: 500; }
.chapter-nav .cn-disabled { color: var(--rule); cursor: default; }
.chapter-nav .cn-next { text-align: right; }
/* --- theme toggle --- */
#theme-btn {
position: fixed;
top: 0.5em;
right: 0.5em;
width: 2.1em;
height: 2.1em;
border-radius: 50%;
border: 1px solid var(--rule);
background: var(--paper);
color: var(--accent);
font-size: 1em;
line-height: 1;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
box-shadow: var(--shadow-sm);
transition: transform 0.15s ease, background 0.15s, border-color 0.15s;
font-family: "Inter", -apple-system, sans-serif;
z-index: 1001;
}
#theme-btn:hover { transform: scale(1.05); border-color: var(--accent); }
#theme-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#theme-btn .icon-sun { display: none; }
#theme-btn .icon-moon { display: inline; }
html[data-theme="dark"] #theme-btn .icon-sun { display: inline; }
html[data-theme="dark"] #theme-btn .icon-moon { display: none; }
/* --- feedback (report an issue) --- */
#feedback-btn {
position: fixed;
top: 3.1em;
right: 0.5em;
width: 2.1em;
height: 2.1em;
border-radius: 50%;
border: 1px solid var(--rule);
background: var(--paper);
color: var(--accent);
font-size: 1em;
line-height: 1;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
box-shadow: var(--shadow-sm);
transition: transform 0.15s ease, background 0.15s, border-color 0.15s;
font-family: "Inter", -apple-system, sans-serif;
z-index: 1001;
}
#feedback-btn:hover { transform: scale(1.05); border-color: var(--accent); }
#feedback-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#feedback-pop {
position: absolute;
display: none;
z-index: 1002;
}
#feedback-pop button {
padding: 0.45em 0.9em;
background: var(--accent);
color: #fff;
border: none;
border-radius: 999px;
font-family: "Inter", -apple-system, sans-serif;
font-size: 0.8em;
font-weight: 600;
letter-spacing: 0.02em;
cursor: pointer;
box-shadow: var(--shadow-md);
}
#feedback-pop button:hover { background: var(--accent-hover); }
/* --- download link (pill, visible only on screen) --- */
.download-link {
display: inline-block;
padding: 0.55em 1.1em;
background: var(--accent);
color: #fff;
text-decoration: none;
font-family: "Inter", -apple-system, sans-serif;
font-weight: 600;
font-size: 0.9em;
letter-spacing: 0.02em;
border-radius: 999px;
box-shadow: var(--shadow-sm);
transition: background 0.15s, transform 0.15s;
}
.download-link:hover {
background: var(--accent-hover);
color: #fff;
transform: translateY(-1px);
box-shadow: var(--shadow-md);
text-decoration: none;
}
.download-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.download-link::before {
content: "↓";
display: inline-block;
margin-right: 0.4em;
font-weight: 700;
}
/* --- medium viewports: push body right so the sidebar doesn't
overlap the first characters of each line --- */
@media (min-width: 901px) and (max-width: 1400px) {
body:has(#toc-nav:not(.collapsed)) {
padding-left: 18em;
}
}
/* --- small screens --- */
@media (max-width: 900px) {
body { margin: 2em auto; padding: 0 1em; }
#toc-nav { width: 82%; max-width: 20em; }
#toc-toggle.open { left: calc(82% + 0.5em); }
}
/* --- reduced motion --- */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.001ms !important;
transition-duration: 0.001ms !important;
scroll-behavior: auto !important;
}
}
/* --- print --- */
@page { size: A4; margin: 22mm 18mm 20mm 18mm; }
@page :first { margin-top: 0; }
@media print {
html[data-theme="dark"] { /* force light theme in PDF regardless of user toggle */
--ink: #000; --ink-soft: #333; --ink-muted: #5a5f66;
--accent: #0b5394; --accent-soft: #e3ecf6; --accent-hover: #083d73;
--rule: #cfd4d9; --rule-soft: #e8ecf1;
--bg: #fff; --paper: #fff; --callout: #f5f7fb; --row-alt: #f7f9fc;
--code-bg: #f4f6f9; --code-ink: #22272e;
--tok-tag: #0b5394; --tok-attr: #1a7f4b; --tok-string: #a8410a;
--tok-comment: #6b7280; --tok-decl: #7048c4; --tok-punct: #6b7684;
}
:root {
--bg: #fff; --paper: #fff;
--ink: #000; --ink-soft: #333;
--rule: #cfd4d9; --callout: #f5f7fb; --row-alt: #f7f9fc;
}
#toc-nav, #toc-toggle, #top-btn, #theme-btn, #feedback-btn, #feedback-pop,
.chapter-nav, .heading-anchor, .download-link { display: none !important; }
body {
font-size: 10.5pt;
max-width: none;
margin: 0;
padding: 0;
line-height: 1.5;
background: #fff;
color: #000;
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
h1 { font-size: 1.8em; }
h2 { font-size: 1.3em; page-break-after: avoid; }
h3, h4 { page-break-after: avoid; }
p, li { orphans: 3; widows: 3; }
table, blockquote, figure { page-break-inside: avoid; }
pre { page-break-inside: auto; white-space: pre-wrap; word-wrap: break-word; }
th, tbody tr:nth-child(even), .pages, h2.part-title {
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
a { color: var(--accent); text-decoration: none; }
}
</style>
<script id="theme-preload">(function(){try{var t=localStorage.getItem('fundsxml-theme');if(t==='dark')document.documentElement.setAttribute('data-theme','dark');}catch(e){}})();</script>
</head>
<body>
<nav class="chapter-nav" aria-label="Chapter navigation"><a class="cn-prev" href="Chapter09.html">‹ Chapter 9</a><a class="cn-toc" href="index.html">Contents</a><a class="cn-next" href="Chapter11.html">Chapter 11 ›</a></nav>
<img src="FundsXML-Logo.png" alt="FundsXML" style="height:28px;width:auto;display:block;margin:0 0 1.5em 0;">
<div class="chapter-meta">Part III — Implementation and Practice · Chapter 10</div>
<h1>Validation and Quality Assurance<span class="subtitle">Ensuring correct FundsXML files</span></h1>
<hr>
<h2>10.1 Setting the Scene: Why Validation Matters</h2>
<p>Part II of this book taught the reader to <em>read and produce</em> FundsXML documents. Part III, which this chapter opens, is about <em>running them in production</em>. The distinction matters: a document that parses cleanly in a text editor is not necessarily a document that will survive a production pipeline. Real deliveries cross network boundaries, pass through multiple systems, and are consumed by consumers whose tolerance for sloppy data ranges from "reject on first error" to "silently ignore and continue". The producer who does not validate every file before emitting it is pushing that tolerance onto someone else.</p>
<p>This chapter treats validation as an engineering discipline rather than an afterthought. It introduces the two-stage validation model that every production FundsXML pipeline should implement, shows how to run the first stage (schema validation) with the free <code>xmllint</code> tool and with the four programming languages most commonly found in production pipelines (Python, Java, C# and PowerShell), catalogues the five or six error patterns that account for the overwhelming majority of real-world validation failures, explains why schema validation alone is not enough, introduces Schematron as the standard tool for the second stage (business-rule validation) with runners in each of the same four languages, and assembles a complete validation workflow — in both Bash and PowerShell — that a producer can drop into its delivery pipeline as a gatekeeper. Every command shown in the chapter has been run against real FundsXML files, and every error message has been captured verbatim from the actual tool output.</p>
<p>By the end of this chapter, you should be able to:</p>
<ul>
<li>explain the two-stage validation model and name what each stage catches that the other misses;</li>
<li>run <code>xmllint --noout --schema FundsXML4.xsd</code> against any FundsXML file and interpret the results;</li>
<li>validate a FundsXML file using Python, Java, C# or PowerShell as an alternative to <code>xmllint</code>, choosing whichever language matches your production pipeline;</li>
<li>read an <code>xmllint</code> error message and map it to one of the recurring error patterns the chapter catalogues;</li>
<li>write a Schematron rule that expresses a business constraint the schema cannot enforce;</li>
<li>compile and execute Schematron rules with the tooling the chapter introduces — in Python, Java, C# or PowerShell;</li>
<li>assemble a validation gatekeeper script (Bash or PowerShell) that a production pipeline can use to accept or reject every outgoing delivery.</li>
</ul>
<p>The tools used throughout the chapter are free and ubiquitous. <code>xmllint</code> comes with <code>libxml2</code> and is installed by default on virtually every Linux distribution, in the macOS developer tools, and in the Windows Subsystem for Linux. The language-specific validators use standard libraries and widely available open-source packages: Python's <code>lxml</code>, Java's <code>javax.xml.validation</code>, .NET's <code>System.Xml.Schema</code>, and PowerShell's access to the same .NET classes. Schematron validation is performed with <code>lxml.isoschematron</code> (Python), <code>ph-schematron</code> (Java), and the ISO Schematron XSLT stylesheets (C# and PowerShell). Appendix E lists the relevant installation paths for readers on other platforms; Chapter 11 treats the dedicated FundsXML tooling ecosystem (FreeXmlToolkit, Online Schema Viewer, and so on) that some readers may prefer for day-to-day work.</p>
<hr>
<h2>10.2 The Two-Stage Validation Model</h2>
<p>The central architectural claim of this chapter is that every production FundsXML pipeline should validate every outgoing document in <strong>two</strong> distinct stages, using two different technologies, checking two different classes of correctness. Combining them into a single stage is possible but costs the pipeline the ability to give clear diagnostics when things go wrong; skipping either stage entirely is a recurring source of production incidents.</p>
<p><strong>Stage 1 is schema validation.</strong> The input is the FundsXML file and the XSD schema (<code>FundsXML4.xsd</code> plus its included modules). The check is: does the file conform to the <em>structural</em> rules that XSD can express? Element names, element order, cardinality (which elements are required, which are optional, which are repeatable), data types (dates must look like dates, numbers must look like numbers, enumerations must take one of their allowed values), attribute types, and the basic hierarchical shape of the document. Stage 1 catches everything that can be expressed in XSD; the pass criterion is binary — the file either conforms or it does not.</p>
<p><strong>Stage 2 is business-rule validation.</strong> The input is the same FundsXML file, plus a separate rule set written in Schematron (or in an equivalent rule language). The check is: does the file conform to the <em>semantic</em> rules that XSD cannot express? "A <code>DELETE</code> operation must carry a <code>RelatedDocumentIDs</code> pointing at the delivery being retracted." "A share class's <code>NumberOfShares</code> must be a positive integer." "The sum of the position market values in a portfolio must equal the fund's <code>TotalNetAssetValue</code> within a rounding tolerance." "A <code>Document</code> of type <code>PRIIPS-KID</code> must reference at least one share class, not a fund-level identifier only." None of these rules can be expressed in XSD, because they depend on comparisons between elements, on arithmetic, or on knowledge of the business domain that the schema language cannot capture.</p>
<p>The two stages are complementary, and each one catches errors that the other cannot see:</p>
<ul>
<li>A file with <code>DataOperation=UPDATE</code> (an obsolete enum value — see Chapter 4's retroactive correction) fails <strong>Stage 1</strong>: the enumeration rule catches it immediately. Stage 2 would not catch it because Schematron assumes the underlying structure is schema-valid when it runs.</li>
<li>A file with <code>DataOperation=DELETE</code> and no <code>RelatedDocumentIDs</code> passes <strong>Stage 1</strong> (the schema allows <code>RelatedDocumentIDs</code> as optional even on <code>DELETE</code>) but fails <strong>Stage 2</strong> if the producer has written a Schematron rule that enforces the semantic constraint.</li>
</ul>
<p>The operational implication is that a production pipeline should run Stage 1 <em>first</em> — because its failures are easier to interpret and its runtime is faster — and then run Stage 2 only if Stage 1 passed. Running Stage 2 against a structurally broken file produces cascading Schematron errors that are harder to read than the underlying XSD failures. The complete workflow in §10.9 codifies this ordering.</p>
<p><strong>Figure 10.1 — The two-stage validation pipeline</strong></p>
<pre><code> FundsXML file
|
v
+-------------------+
| Stage 1: | -- FAIL --> Report XSD errors, stop
| xmllint --schema | (structural problem,
| (XSD) | see 10.4 for reading)
+-------------------+
| PASS
v
+-------------------+
| Stage 2: | -- FAIL --> Report business errors, stop
| Schematron | (semantic problem,
| (business rules) | see 10.8 for rule catalogue)
+-------------------+
| PASS
v
Delivery accepted; safe to emit</code></pre>
<hr>
<h2>10.3 Schema Validation with xmllint</h2>
<p><code>xmllint</code> is the command-line XML tool that ships with <code>libxml2</code>, the XML library underlying a significant fraction of the open-source XML ecosystem. It can parse, format, query with XPath, and — critically for this chapter — validate XML documents against an XSD schema. For FundsXML it is the default Stage 1 tool because it is free, widely installed, well-documented, and quick; the single command required for validation is short enough to embed in shell scripts, Makefiles, and CI pipelines without overhead.</p>
<p>The command that validates a FundsXML document against the schema is:</p>
<pre><code>xmllint --noout --schema FundsXML4.xsd delivery.xml</code></pre>
<p>The flags decompose as follows. <code>--schema FundsXML4.xsd</code> tells <code>xmllint</code> to validate against the named XSD file; it accepts a path, either relative to the current working directory or absolute. <code>--noout</code> suppresses the normal output of <code>xmllint</code> (which would otherwise dump the parsed document to standard output after validation); since we are interested only in the pass/fail result and any error messages, <code>--noout</code> keeps the terminal clean. The positional argument is the FundsXML file to validate.</p>
<p>On success, <code>xmllint</code> prints a single line to standard output:</p>
<pre><code>delivery.xml validates</code></pre>
<p>and exits with code <code>0</code>. On failure, it prints one or more error messages to standard error — each one naming the offending line and the nature of the violation — followed by a final line:</p>
<pre><code>delivery.xml fails to validate</code></pre>
<p>and exits with code <code>3</code> (the <code>libxml2</code> convention for schema-validation failures; other non-zero exit codes indicate different categories of error, such as missing files or malformed XML). A CI pipeline or shell script can branch on the exit code to decide whether to proceed.</p>
<p>A few practical notes before the error catalogue in §10.4.</p>
<p><strong>Schema location.</strong> The command above assumes that <code>FundsXML4.xsd</code> is in the current working directory. In production, the schema is almost always stored elsewhere — a shared schema directory, a container volume, a URL — and the command needs to point at it explicitly with a path. An equivalent invocation using an absolute path:</p>
<pre><code>xmllint --noout --schema /opt/fundsxml/4.2.8/FundsXML4.xsd delivery.xml</code></pre>
<p><strong>Included schemas.</strong> <code>FundsXML4.xsd</code> imports <code>xmldsig-core-schema.xsd</code> for the digital-signature element (§9.3). The imported file must be reachable from the main schema file — usually by being in the same directory, because the <code>import</code> in the XSD uses a relative path. A pipeline that copies <code>FundsXML4.xsd</code> without also copying <code>xmldsig-core-schema.xsd</code> will produce a confusing "cannot locate schema" error on any file that uses <code>ds:Signature</code>, even though the file itself appears complete.</p>
<p><strong>Validation speed.</strong> <code>xmllint</code> parses and validates at roughly 50 to 200 megabytes per second on a modern workstation, depending on the document's structural complexity. A typical month-end FundsXML delivery — 5 to 20 megabytes for a mid-sized asset manager — validates in well under one second. The performance is not usually a constraint; the failure diagnostics are the interesting part.</p>
<p><strong>Alternative tools.</strong> Other validators exist: Apache Xerces (via the Java command-line <code>xmlvalidator</code>), Oracle's XDK, .NET's <code>XmlReader</code> with <code>XmlReaderSettings.Schemas</code>, Python's <code>lxml</code>, Go's <code>encoding/xml</code>. All of them validate against the same XSD and should produce equivalent pass/fail results, though their error messages vary. §10.5 presents complete validation scripts in each of the four most common production languages so that the reader can choose the tool that fits their pipeline.</p>
<hr>
<h2>10.4 Reading xmllint Error Messages — A Catalogue</h2>
<p>Five classes of error account for the overwhelming majority of real-world FundsXML validation failures. This section walks through each class with a captured <code>xmllint</code> error message, an explanation of what the message means, and the fix. Every error shown in this section was produced by a real <code>xmllint</code> run against a real (deliberately broken) FundsXML file, and the output is reproduced verbatim.</p>
<h3>10.4.1 Invalid Enumeration Value</h3>
<p>A producer emits a file with <code>DataOperation=UPDATE</code>, a value that was legal in some older conventions (and appeared in early drafts of this book) but that is not in the current FundsXML 4.2.8 enumeration. The schema defines <a href="https://fundsxml.github.io/index.html?xpath=/FundsXML4/ControlData/DataOperation" target="_blank"><code>DataOperation</code></a> as an enumerated field with exactly three values: <code>INITIAL</code>, <code>AMEND</code>, <code>DELETE</code>. Running <code>xmllint</code> against the file produces:</p>
<pre><code>bad-enum.xml:15: element DataOperation: Schemas validity error :
Element 'DataOperation': [facet 'enumeration'] The value 'UPDATE' is
not an element of the set {'INITIAL', 'AMEND', 'DELETE'}.
bad-enum.xml fails to validate</code></pre>
<p>The message is unusually clear: it names the offending element, the exact line in the file, the nature of the constraint (<code>facet 'enumeration'</code>), the rejected value, and the full list of allowed values. A reader new to <code>xmllint</code> might expect every error message to be this helpful; most of them are.</p>
<p>The fix is to replace the enum value. In this case, <code>UPDATE</code> should become <code>AMEND</code>, following the correction that Chapter 4 was retroactively updated for. A producer pipeline that has shipped files with <code>UPDATE</code> in the past also needs to audit any downstream consumer that has been treating the invalid value permissively — production systems that silently coerce unknown enum values to a default (a bad practice, but a common one) may be silently misclassifying deliveries.</p>
<h3>10.4.2 Wrong Element Order</h3>
<p>The XSD <code>sequence</code> compositor requires children to appear in a specific order. <a href="https://fundsxml.github.io/index.html?xpath=/FundsXML4/ControlData" target="_blank"><code>ControlData</code></a>, for example, must have <code>UniqueDocumentID</code>, then <code>DocumentGenerated</code>, then optionally <code>Version</code>, then <code>ContentDate</code>, then <a href="https://fundsxml.github.io/index.html?xpath=/FundsXML4/ControlData/DataSupplier" target="_blank"><code>DataSupplier</code></a>, then further elements — in exactly that sequence. A producer who writes <code>ContentDate</code> before <code>DocumentGenerated</code> violates the order, even though both elements are present and the data is correct. Running <code>xmllint</code>:</p>
<pre><code>bad-order.xml:6: element ContentDate: Schemas validity error :
Element 'ContentDate': This element is not expected.
Expected is ( DocumentGenerated ).
bad-order.xml fails to validate</code></pre>
<p>The message "This element is not expected. Expected is (DocumentGenerated)" is the canonical <code>xmllint</code> wording for an order violation. The word <em>expected</em> is deliberately precise: the validator was halfway through parsing the <code>ControlData</code> sequence, had just finished <code>UniqueDocumentID</code>, and was looking for the next element in the sequence — which should have been <code>DocumentGenerated</code>. Instead it found <code>ContentDate</code>, an element that legally belongs later in the sequence but not yet.</p>
<p>The fix is to reorder the elements to match the XSD's declared sequence. The schema itself is the authoritative source; Appendix C's XSD quick reference lists the sequence for every major type.</p>
<h3>10.4.3 Missing Required Child</h3>
<p>The XSD distinguishes required children (those with no <code>minOccurs</code> attribute, or <code>minOccurs="1"</code>) from optional ones (<code>minOccurs="0"</code>). A producer who omits a required child — because they thought it was optional, or because their generator had a bug — produces a file that <code>xmllint</code> rejects with a "Missing child element(s)" message. A <code>DataSupplier</code> block, for example, requires a <code>Type</code> element. Omit it and you get:</p>
<pre><code>bad-missing.xml:9: element DataSupplier: Schemas validity error :
Element 'DataSupplier': Missing child element(s). Expected is ( Type ).
bad-missing.xml fails to validate</code></pre>
<p>The "Expected is (Type)" tells the reader exactly which required child was missing. When several children are missing, <code>xmllint</code> reports the <em>first</em> missing one it encounters rather than enumerating all of them; fixing that one and re-running the validation often reveals further missing children in subsequent runs. The iteration is mildly annoying but not difficult.</p>
<h3>10.4.4 Invalid Type</h3>
<p>XSD types enforce lexical constraints on the values of elements. A field declared as <code>xs:date</code> must carry a value that looks like <code>2026-03-31</code> (ISO 8601 date format); <code>xs:dateTime</code> requires a value like <code>2026-04-01T06:47:13Z</code>; <code>xs:integer</code> requires a string of digits; <code>xs:boolean</code> requires one of <code>true</code>, <code>false</code>, <code>1</code>, or <code>0</code>. A producer who writes a date in a local format — say, <code>31/03/2026</code> — breaks the type constraint:</p>
<pre><code>bad-type.xml:8: element ContentDate: Schemas validity error :
Element 'ContentDate': '31/03/2026' is not a valid value of the
atomic type 'xs:date'.
bad-type.xml fails to validate</code></pre>
<p>The fix is to convert the value to the expected ISO format. This error is particularly common in producers that have been built around European-locale date-picker libraries (which default to <code>DD/MM/YYYY</code>) without explicit format conversion at the XML-serialisation step. The producer's output layer should always emit ISO dates regardless of the system's display locale.</p>
<h3>10.4.5 Unknown Element</h3>
<p>The complement of the "wrong order" and "missing child" errors is the "unknown element" error: a producer emits an element that is not declared in the schema at all, at a position where the schema does not expect any element (or, more commonly, any element with that name). This is the error that revealed the <code>DataSupplier/LEI</code> inaccuracy in earlier drafts of this book. A producer who writes an <code>LEI</code> child inside <code>DataSupplier</code> — following the natural assumption that every organisation has an LEI — sees:</p>
<pre><code>bad-unknown.xml:14: element LEI: Schemas validity error :
Element 'LEI': This element is not expected. Expected is ( Contact ).
bad-unknown.xml fails to validate</code></pre>
<p>The surprise here is that <code>DataSupplierType</code> in the FundsXML 4.2.8 schema has no <code>LEI</code> field at all. The <code>SystemCountry</code>, <code>Short</code>, <code>Name</code>, <code>Type</code>, and optional <code>Contact</code> children are the only ones it accepts. A producer who wants to convey the supplier's LEI has to put it somewhere else — typically through <code>CustomAttributes</code> (Chapter 9.4), or through the supplier's <code>Short</code> code if the code is in a format that includes the LEI by convention. The lesson is general: <em>read the schema before assuming what fields exist</em>, because some fields that feel natural are not actually in the standard.</p>
<h3>10.4.6 What xmllint Does Not Catch</h3>
<p><code>xmllint</code> catches everything that XSD can express, which is a lot but not everything. Specifically, it does not check:</p>
<ul>
<li>Whether a <code>UniqueDocumentID</code> is actually unique across a producer's output stream (a cross-file semantic property).</li>
<li>Whether the sum of portfolio market values matches the fund's total net assets within a tolerance (an arithmetic cross-element property).</li>
<li>Whether a <code>DELETE</code> operation carries the <code>RelatedDocumentIDs</code> that the FundsXML documentation recommends (a conditional semantic rule; the schema leaves it optional).</li>
<li>Whether a <code>Document</code> of type <code>PRIIPS-KID</code> actually points at an existing share class (a cross-reference property).</li>
<li>Whether the PAI values in an EET block are consistent with the portfolio composition (a cross-module property).</li>
</ul>
<p>None of these are XSD-expressible, and none of them are <code>xmllint</code>'s fault to miss. They are the subject of Stage 2, which the rest of this chapter develops.</p>
<hr>
<h2>10.5 Schema Validation in Python, Java, C# and PowerShell</h2>
<p>While <code>xmllint</code> is the reference tool for XSD validation and the one this book recommends for interactive use, production pipelines are often built in general-purpose programming languages. A Java pipeline wants a Java validator; a .NET pipeline wants a C# validator; a Windows operations team wants a PowerShell script. This section presents a complete XSD validation script in each of the four most common production languages. Every script follows the same pattern as the <code>xmllint</code> command: it takes a schema path and a file path, reports errors with line numbers, and exits with a non-zero code on failure. Each script can be invoked directly from the command line — as a drop-in replacement for <code>xmllint</code> in the validation step — or imported as a module into a larger application.</p>
<p><strong>Table 10.1 — Schema validation commands at a glance</strong></p>
<table>
<thead>
<tr><th>Tool</th><th>Command</th></tr>
</thead>
<tbody>
<tr><td>xmllint</td><td><code>xmllint --noout --schema FundsXML4.xsd delivery.xml</code></td></tr>
<tr><td>Python</td><td><code>python3 validate-xsd.py FundsXML4.xsd delivery.xml</code></td></tr>
<tr><td>Java</td><td><code>java ValidateXsd FundsXML4.xsd delivery.xml</code></td></tr>
<tr><td>C#</td><td><code>dotnet run -- FundsXML4.xsd delivery.xml</code></td></tr>
<tr><td>PowerShell</td><td><code>.\Validate-XsdSchema.ps1 -SchemaPath FundsXML4.xsd -XmlPath delivery.xml</code></td></tr>
</tbody>
</table>
<h3>10.5.1 Python (lxml)</h3>
<p>Python's <code>lxml</code> library wraps <code>libxml2</code> — the same library behind <code>xmllint</code> — in a Pythonic API. Schema validation is a two-step process: parse the XSD into an <code>XMLSchema</code> object, then call <code>validate()</code> on the target document. Errors are available in the schema's <code>error_log</code>, with line numbers and messages that closely mirror <code>xmllint</code>'s output.</p>
<pre><code>#!/usr/bin/env python3
"""validate-xsd.py — XSD schema validation for FundsXML files."""
import sys
from lxml import etree
if len(sys.argv) != 3:
print("usage: validate-xsd.py <schema.xsd> <file.xml>", file=sys.stderr)
sys.exit(2)
schema_path, xml_path = sys.argv[1], sys.argv[2]
schema_doc = etree.parse(schema_path)
schema = etree.XMLSchema(schema_doc)
doc = etree.parse(xml_path)
if schema.validate(doc):
print(f"{xml_path} validates")
sys.exit(0)
for error in schema.error_log:
print(f" line {error.line}: {error.message}")
print(f"{xml_path} fails to validate")
sys.exit(1)</code></pre>
<p>The script is self-contained and can be run from the command line with <code>python3 validate-xsd.py FundsXML4.xsd delivery.xml</code>. The prerequisite is <code>lxml</code>, which is installed via <code>pip install lxml</code> (or <code>apt install python3-lxml</code> on Debian/Ubuntu).</p>
<p>To use the same logic in a larger application — say, a Django-based upload portal that validates incoming FundsXML deliveries — extract the core into a function:</p>
<pre><code>def validate_xsd(schema_path: str, xml_path: str) -> list[str]:
"""Return a list of error messages, empty on success."""
schema = etree.XMLSchema(etree.parse(schema_path))
doc = etree.parse(xml_path)
schema.validate(doc)
return [str(e) for e in schema.error_log]</code></pre>
<h3>10.5.2 Java (javax.xml.validation)</h3>
<p>Java's standard library includes a full XSD validation API in the <code>javax.xml.validation</code> package, available in every JDK since Java 5. No third-party dependency is required. The validator is built from a <code>SchemaFactory</code>, which parses the XSD into a <code>Schema</code> object, and a <code>Validator</code>, which checks the target document against the schema. Errors are reported through an <code>ErrorHandler</code> callback.</p>
<pre><code>// ValidateXsd.java — XSD schema validation for FundsXML files
import javax.xml.XMLConstants;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class ValidateXsd {
public static void main(String[] args) {
if (args.length != 2) {
System.err.println(
"usage: java ValidateXsd <schema.xsd> <file.xml>");
System.exit(2);
}
try {
SchemaFactory factory = SchemaFactory.newInstance(
XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = factory.newSchema(new File(args[0]));
Validator validator = schema.newValidator();
List<String> errors = new ArrayList<>();
validator.setErrorHandler(new ErrorHandler() {
@Override
public void warning(SAXParseException e) { }
@Override
public void error(SAXParseException e) {
errors.add("line " + e.getLineNumber()
+ ": " + e.getMessage());
}
@Override
public void fatalError(SAXParseException e) {
errors.add("line " + e.getLineNumber()
+ ": " + e.getMessage());
}
});
validator.validate(new StreamSource(new File(args[1])));
if (errors.isEmpty()) {
System.out.println(args[1] + " validates");
} else {
for (String err : errors) {
System.out.println(" " + err);
}
System.out.println(args[1] + " fails to validate");
System.exit(1);
}
} catch (Exception e) {
System.err.println("error: " + e.getMessage());
System.exit(2);
}
}
}</code></pre>
<p>Compile and run with:</p>
<pre><code>javac ValidateXsd.java
java ValidateXsd FundsXML4.xsd delivery.xml</code></pre>
<p>No external library is needed — the JDK's built-in Xerces implementation handles the XSD parsing and validation. For larger applications, extract the validation logic into a utility method that returns the list of errors, and call it from wherever the pipeline needs a Stage 1 check.</p>
<h3>10.5.3 C# (.NET)</h3>
<p>.NET provides XSD validation through the <code>System.Xml.Schema</code> namespace. The pattern mirrors the Java approach: load the schema into an <code>XmlSchemaSet</code>, configure an <code>XmlReaderSettings</code> with that schema set and a <code>ValidationType</code> of <code>Schema</code>, then read the document through the validating reader. Errors are reported through the <code>ValidationEventHandler</code> delegate.</p>
<pre><code>// ValidateXsd.cs — XSD schema validation for FundsXML files
using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Schema;
class ValidateXsd
{
static int Main(string[] args)
{
if (args.Length != 2)
{
Console.Error.WriteLine(
"usage: ValidateXsd <schema.xsd> <file.xml>");
return 2;
}
var schemas = new XmlSchemaSet();
schemas.Add(null, args[0]);
var settings = new XmlReaderSettings
{
Schemas = schemas,
ValidationType = ValidationType.Schema
};
var errors = new List<string>();
settings.ValidationEventHandler += (sender, e) =>
errors.Add($"line {e.Exception.LineNumber}: {e.Message}");
using (var reader = XmlReader.Create(args[1], settings))
{
while (reader.Read()) { }
}
if (errors.Count == 0)
{
Console.WriteLine($"{args[1]} validates");
return 0;
}
foreach (var err in errors)
Console.WriteLine($" {err}");
Console.WriteLine($"{args[1]} fails to validate");
return 1;
}
}</code></pre>
<p>To compile and run as a standalone console application:</p>
<pre><code>dotnet new console -n ValidateXsd
# replace Program.cs with the code above
dotnet run --project ValidateXsd -- FundsXML4.xsd delivery.xml</code></pre>
<p>No NuGet package is needed — <code>System.Xml</code> ships with every .NET installation. For integration into a larger application (an ASP.NET Core service, a WPF desktop tool), the same <code>XmlSchemaSet</code>/<code>XmlReaderSettings</code> pattern works as a library call.</p>
<h3>10.5.4 PowerShell</h3>
<p>PowerShell has native access to the .NET <code>System.Xml</code> classes, so XSD validation requires no external module. The script below uses the same <code>XmlSchemaSet</code> and <code>XmlReaderSettings</code> pattern as the C# example, wrapped in PowerShell syntax. It is the natural choice for Windows operations teams and for pipelines orchestrated with PowerShell scripts.</p>
<pre><code># Validate-XsdSchema.ps1 — XSD schema validation for FundsXML files
# Usage: .\Validate-XsdSchema.ps1 -SchemaPath FundsXML4.xsd -XmlPath delivery.xml
param(
[Parameter(Mandatory)][string]$SchemaPath,
[Parameter(Mandatory)][string]$XmlPath
)