xrust 2.0.3

Support for XPath and XSLT
Documentation
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
/*

Sun Microsystems test cases

*/
#[cfg(all(test, feature = "test-conformance-xml"))]
use std::fs;
#[cfg(all(test, feature = "test-conformance-xml"))]
use xrust::item::Node;
#[cfg(all(test, feature = "test-conformance-xml"))]
use xrust::parser::{ParseError, xml};
#[cfg(all(test, feature = "test-conformance-xml"))]
use xrust::trees::smite::RNode;
#[cfg(all(test, feature = "test-conformance-xml"))]
use xrust::validators::Schema;

#[cfg(all(test, feature = "test-conformance-xml"))]
fn test_xmltest_sun_valid(xmldoc: &str, xmlcanondoc: &str) {
    let testxml = RNode::new_document();
    let parseresult = xml::parse(
        testxml,
        xmldoc,
        Some(|_: &_| Err(ParseError::MissingNameSpace)),
    );
    let canonicalxml = RNode::new_document();
    let canonicalparseresult = xml::parse(
        canonicalxml,
        xmlcanondoc,
        Some(|_: &_| Err(ParseError::MissingNameSpace)),
    );

    assert!(parseresult.is_ok());
    assert!(canonicalparseresult.is_ok());

    let doc = parseresult.unwrap();

    let validation = doc.validate(Schema::DTD);
    assert!(validation.is_ok());

    assert_eq!(doc.get_canonical().unwrap(), canonicalparseresult.unwrap());
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn pe01() {
    /*
        Test ID:pe01
        Test URI:valid/pe01.xml
        Spec Sections:2.8
        Description:    Parameter entities references are NOT RECOGNIZED in default attribute    values.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/pe01.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/pe01.dtd")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn dtd00() {
    /*
        Test ID:dtd00
        Test URI:valid/dtd00.xml
        Spec Sections:3.2.2 [51]
        Description:Tests parsing of alternative forms of text-only mixedcontent declaration.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/dtd00.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/dtd00.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn dtd01() {
    /*
        Test ID:dtd01
        Test URI:valid/dtd01.xml
        Spec Sections:2.5 [15]
        Description:Comments don't get parameter entity expansion
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/dtd01.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/dtd01.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn element() {
    /*
        Test ID:element
        Test URI:valid/element.xml
        Spec Sections:3
        Description:Tests clauses 1, 3, and 4 of the Element Validvalidity constraint.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/element.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/element.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn ext01() {
    /*
        Test ID:ext01
        Test URI:valid/ext01.xml
        Spec Sections:4.3.1 4.3.2 [77] [78]
        Description:Tests use of external parsed entities with and without content.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/ext01.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/ext01.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn ext02() {
    /*
        Test ID:ext02
        Test URI:valid/ext02.xml
        Spec Sections:4.3.2 [78]
        Description:Tests use of external parsed entities with differentencodings than the base document.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/ext02.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/ext02.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn notsa01() {
    /*
        Test ID:not-sa01
        Test URI:valid/not-sa01.xml
        Spec Sections:2.9
        Description:A non-standalone document is valid if declared as such.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/not-sa01.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/not-sa01.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn notsa02() {
    /*
        Test ID:not-sa02
        Test URI:valid/not-sa02.xml
        Spec Sections:2.9
        Description:A non-standalone document is valid if declared as such.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/not-sa02.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/not-sa02.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn notsa03() {
    /*
        Test ID:not-sa03
        Test URI:valid/not-sa03.xml
        Spec Sections:2.9
        Description:A non-standalone document is valid if declared as such.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/not-sa03.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/not-sa03.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn notsa04() {
    /*
        Test ID:not-sa04
        Test URI:valid/not-sa04.xml
        Spec Sections:2.9
        Description:A non-standalone document is valid if declared as such.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/not-sa04.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/not-sa04.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn notation01() {
    /*
        Test ID:notation01
        Test URI:valid/notation01.xml
        Spec Sections:4.7 [82]
        Description:NOTATION declarations don't need SYSTEM IDs; andexternally declared notations may be used to declareunparsed entities in the internal DTD subset.The notation must be reported to the application.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/notation01.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/notation01.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn optional() {
    /*
        Test ID:optional
        Test URI:valid/optional.xml
        Spec Sections:3 3.2.1 [47]
        Description:Tests declarations of "children" content models, andthe validity constraints associated with them.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/optional.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/optional.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn required00() {
    /*
        Test ID:required00
        Test URI:valid/required00.xml
        Spec Sections:3.3.2 [60]
        Description:Tests the #REQUIRED attribute declaration syntax, andthe associated validity constraint.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/required00.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/required00.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn sa01() {
    /*
        Test ID:sa01
        Test URI:valid/sa01.xml
        Spec Sections:2.9 [32]
        Description:A document may be marked 'standalone' if any optional whitespace is defined within the internal DTD subset.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/sa01.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/sa01.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn sa02() {
    /*
        Test ID:sa02
        Test URI:valid/sa02.xml
        Spec Sections:2.9 [32]
        Description:A document may be marked 'standalone' if anyattributes that need normalization aredefined within the internal DTD subset.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/sa02.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/sa02.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn sa03() {
    /*
        Test ID:sa03
        Test URI:valid/sa03.xml
        Spec Sections:2.9 [32]
        Description:A document may be marked 'standalone' if anythe defined entities need expanding are internal,and no attributes need defaulting or normalization.On output, requires notations to be correctly reported.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/sa03.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/sa03.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn sa04() {
    /*
        Test ID:sa04
        Test URI:valid/sa04.xml
        Spec Sections:2.9 [32]
        Description:Like sa03 but relies on attributedefaulting defined in the internal subset.On output, requires notations to be correctly reported.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/sa04.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/sa04.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn sa05() {
    /*
        Test ID:sa05
        Test URI:valid/sa05.xml
        Spec Sections:2.9 [32]
        Description:Like sa01 but this document is standalone since it has no optional whitespace.On output, requires notations to be correctly reported.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/sa05.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/sa05.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn vsgml01() {
    /*
        Test ID:v-sgml01
        Test URI:valid/sgml01.xml
        Spec Sections:3.3.1 [59]
        Description:XML permits token reuse, while SGML does not.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/sgml01.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/sgml01.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn vlang01() {
    /*
        Test ID:v-lang01
        Test URI:valid/v-lang01.xml
        Spec Sections:2.12 [35]
        Description:Tests a lowercase ISO language code.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/v-lang01.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/v-lang01.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn vlang02() {
    /*
        Test ID:v-lang02
        Test URI:valid/v-lang02.xml
        Spec Sections:2.12 [35]
        Description:Tests a ISO language code with a subcode.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/v-lang02.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/v-lang02.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn vlang03() {
    /*
        Test ID:v-lang03
        Test URI:valid/v-lang03.xml
        Spec Sections:2.12 [36]
        Description:Tests a IANA language code with a subcode.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/v-lang03.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/v-lang03.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn vlang04() {
    /*
        Test ID:v-lang04
        Test URI:valid/v-lang04.xml
        Spec Sections:2.12 [37]
        Description:Tests a user language code with a subcode.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/v-lang04.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/v-lang04.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn vlang05() {
    /*
        Test ID:v-lang05
        Test URI:valid/v-lang05.xml
        Spec Sections:2.12 [35]
        Description:Tests an uppercase ISO language code.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/v-lang05.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/v-lang05.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn vlang06() {
    /*
        Test ID:v-lang06
        Test URI:valid/v-lang06.xml
        Spec Sections:2.12 [37]
        Description:Tests a user language code.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/v-lang06.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/v-lang06.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn vpe00() {
    /*
        Test ID:v-pe00
        Test URI:valid/pe00.xml
        Spec Sections:4.5
        Description:Tests construction of internal entity replacement text, usingan example in the XML specification.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/pe00.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/pe00.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn vpe03() {
    /*
        Test ID:v-pe03
        Test URI:valid/pe03.xml
        Spec Sections:4.5
        Description:Tests construction of internal entity replacement text, usingan example in the XML specification.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/pe03.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/pe03.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn vpe02() {
    /*
        Test ID:v-pe02
        Test URI:valid/pe02.xml
        Spec Sections:4.5
        Description:Tests construction of internal entity replacement text, usinga complex example in the XML specification.
    */

    test_xmltest_sun_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/pe02.xml")
            .unwrap()
            .as_str(),
        fs::read_to_string("tests/conformance/xml/xmlconf/sun/valid/out/pe02.xml")
            .unwrap()
            .as_str(),
    );
}