-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
895 lines (891 loc) · 49.4 KB
/
index.html
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
<?xml version="1.0"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XPathle</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes" />
<script src="saxon-js/SaxonJS2.js"></script>
<script>
window.onload = function () {
SaxonJS.transform({
stylesheetLocation: "xpathle.sef.json",
initialTemplate: "main"
},
"async");
}</script>
<link type="text/css" rel="stylesheet" href="xpathle.css" />
</head>
<body>
<div id="header">
<h1 id="title"><span class="dFar">X</span><span class="d10">P</span><span class="d8">a</span><span
class="d6">t</span><span class="d4">h</span><span class="d2">l</span><span class="d0">e</span></h1>
</div>
<details id="help">
<summary>How to play</summary>
<p>Select one of the examples. The corresponding XML file will be rendered. Each XML file
is associated with a secret XPath expression that selects some nodes (elements, text nodes,
comments, processing instructions, and/or attributes).
You need to enter an XPath expression such as <code>/*</code> in order to make a first guess.</p>
<p>For selecting namespaced elements with a prefix, such as <code>xsl:for-each</code> in the XSLT example,
you can enter <code>//xsl:for-each</code>, <code>//Q{http://www.w3.org/1999/XSL/Transform}for-each</code>,
or <code>//*:for-each</code>. Elements without a prefix can be selected without namespace if they
are in the same namespace as the top-level element. If a prefix is declared on any
element, you can also use this prefix in the expression. An example is the Atom/CAP feed in the
<a href="#daily_2022-06-24">2022-06-24 daily challenge</a> where you can use <code>cap:*</code>.
The prefix <code>xs</code> with a binding for <code>http://www.w3.org/2001/XMLSchema</code>
is always available, no matter whether declared in the document or not.</p>
<p>You cannot select <code>//namespace-node()</code> (well, you can, but they won’t be displayed).
You cannot select processing instructions or comments that are outside the top-level element, either.</p>
<p>As a result of evaluating your guess, the number of selected items will be displayed so you can
see whether at least the item count matches. But you are not finished until you selected exactly
the same items that the secret expression selected, or until you run out of attempts.</p>
<p>In order to see how well your guess-selected items match, the items will be highlighted in the rendered
XML (you might need to click into the rendering area and scroll down or sideways). The match quality
will be signalled by color code and by tool tip. The tool tip contains both the hierarchical XPath to
the item and the distance to the closest target item.</p>
<p id="highlight_formula">The number of items highlighted is limited to <code>min((max((2 * count($secret-items), 4)), 20))</code>
(that is, normally double the secret count; minimum of 4 items, maximum of 20).
Otherwise you’d be able to select every node and quickly come up with an XPath expression that
selects only the green ones. Only when your guess selects the same items as the secret expression,
the number of highlighted items won’t be limited any more.</p>
<p>If you check the “Format & indent” box, the input document will be serialized with <code>indent=true</code>
and parsed again. This might lead to a code rendition that is easier graspable. You can try this feature
on <a href="#daily_2022-06-28">the Saxonica Blog Atom feed</a>.</p>
<p>Be aware that checking/unchecking the format & indent box after changing the XPath guess will increase
your guess count. If you don’t change the guess, the guess count won’t change when you check/uncheck the box (or
when you hit Submit).</p>
<h3>Performance</h3>
<p>The distance calculation scales with the product of secretly selected items and the
items you guess. Therefore it can take a couple of seconds if these counts are around 30 or higher,
depending on your computer. All calculations will be carried out by XSLT 3.0 in the browser (see the
links at the bottom of the page).</p>
<h3>Distance metric</h3>
<p>The distance “metric” (which is not a metric, see below) works as follows for a given pair of items:</p>
<ul>
<li>Find the common ancestor element of both items</li>
<li>If one item is ancestor of the other, the element distance is the number of steps you need to climb up on
the ancestor axis</li>
<li>If an item is an attribute, text node, comment, or PI, calculate the element distance for its parent
first and add 1 to the calculated distance later</li>
<li>The distance is the number of steps up to the common ancestor plus the number of steps down to the
other element.</li>
<li>When the nodes below the common ancestor are siblings, count the number of siblings that you
need to visit until you reach the other node, skipping intermediate whitespace-only text nodes.</li>
<li>Then don’t take the two steps to the common ancestor and down to the other node, but take the
sibling path instead.</li>
</ul>
<p>The following diagram shows several paths between nodes and indicates the corresponding distances
using the same color.</p>
<p id="distance_diagram"><svg
width="100%"
viewBox="0 0 297 140"
version="1.1"
id="svg5"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs2" />
<g
id="layer1">
<g
id="g20205"
transform="translate(79.429163,-15.305148)">
<ellipse
style="fill:#fff6d5;stroke:#000000;stroke-width:0.264583"
id="ellipse20199"
cx="19.969437"
cy="54.462101"
rx="15.61247"
ry="5.0831294" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:8.46667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="11.981662"
y="57.003662"
id="text20203"><tspan
id="tspan20201"
style="font-size:8.46667px;stroke-width:0.264583"
x="11.981662"
y="57.003662">WS</tspan></text>
</g>
<g
id="g24889"
transform="translate(-6.5833035,-41.475267)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.168893"
id="rect6993"
width="24.785177"
height="10.988111"
x="40.254112"
y="72.931374" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="47.152645"
y="82.10408"
id="text6997"><tspan
id="tspan6995"
style="stroke-width:0.264583"
x="47.152645"
y="82.10408">ul</tspan></text>
</g>
<g
id="g24912"
transform="translate(34.492665,-31.672084)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.168893"
id="rect6999"
width="24.785177"
height="10.988111"
x="62.402035"
y="36.986385" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="67.122086"
y="46.159092"
id="text7003"><tspan
id="tspan7001"
style="stroke-width:0.264583"
x="67.122086"
y="46.159092">div</tspan></text>
</g>
<g
id="g24866"
transform="translate(90.770171,-13.890189)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.143919"
id="rect13313"
width="17.96752"
height="11.006228"
x="96.822884"
y="71.469994" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="102.34091"
y="81.014839"
id="text13317"><tspan
id="tspan13315"
style="stroke-width:0.264583"
x="102.34091"
y="81.014839">li</tspan></text>
</g>
<g
id="g24843"
transform="translate(5.809291,40.9351)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.123546"
id="rect17984"
width="13.241167"
height="11.006019"
x="116.43545"
y="44.239044" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="119.76878"
y="52.694546"
id="text17988"><tspan
id="tspan17986"
style="stroke-width:0.264583"
x="119.76878"
y="52.694546">a</tspan></text>
</g>
<g
id="g24926"
transform="translate(-39.623647,12.26068)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.168893"
id="rect24920"
width="24.785177"
height="10.988111"
x="40.254112"
y="72.931374" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="47.152645"
y="82.10408"
id="text24924"><tspan
id="tspan24922"
style="stroke-width:0.264583"
x="47.152645"
y="82.10408">ul</tspan></text>
</g>
<g
id="g24934"
transform="translate(-88.228606,-13.890189)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.143919"
id="rect24928"
width="17.96752"
height="11.006228"
x="96.822884"
y="71.469994" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="102.34091"
y="81.014839"
id="text24932"><tspan
id="tspan24930"
style="stroke-width:0.264583"
x="102.34091"
y="81.014839">li</tspan></text>
</g>
<g
id="g24942"
transform="translate(-15.306299,-14.25327)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.143919"
id="rect24936"
width="17.96752"
height="11.006228"
x="96.822884"
y="71.469994" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="102.34091"
y="81.014839"
id="text24940"><tspan
id="tspan24938"
style="stroke-width:0.264583"
x="102.34091"
y="81.014839">li</tspan></text>
</g>
<g
id="g24960"
transform="translate(145.18292,-41.110114)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.168893"
id="rect24954"
width="24.785177"
height="10.988111"
x="40.254112"
y="72.931374" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="47.152645"
y="82.10408"
id="text24958"><tspan
id="tspan24956"
style="stroke-width:0.264583"
x="47.152645"
y="82.10408">ul</tspan></text>
</g>
<g
id="g24968"
transform="translate(56.760244,-13.890189)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.143919"
id="rect24962"
width="17.96752"
height="11.006228"
x="96.822884"
y="71.469994" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="102.34091"
y="81.014839"
id="text24966"><tspan
id="tspan24964"
style="stroke-width:0.264583"
x="102.34091"
y="81.014839">li</tspan></text>
</g>
<g
id="g24976"
transform="translate(21.541418,-13.890189)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.143919"
id="rect24970"
width="17.96752"
height="11.006228"
x="96.822884"
y="71.469994" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="102.34091"
y="81.014839"
id="text24974"><tspan
id="tspan24972"
style="stroke-width:0.264583"
x="102.34091"
y="81.014839">li</tspan></text>
</g>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 58.455986,31.4561 96.894699,16.30241"
id="path25000" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.444913px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 121.68139,16.30034 63.75564,15.52092"
id="path25002" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 33.670807,42.44422 26.561799,57.5798"
id="path25004" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 26.561799,68.58603 25.415643,85.19205"
id="path25298" />
<g
id="g25386"
transform="translate(40.301956,40.9351)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.123546"
id="rect25380"
width="13.241167"
height="11.006019"
x="116.43545"
y="44.239044" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="119.76878"
y="52.694546"
id="text25384"><tspan
id="tspan25382"
style="stroke-width:0.264583"
x="119.76878"
y="52.694546">a</tspan></text>
</g>
<g
id="g25394"
transform="translate(-53.735941,40.9351)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.123546"
id="rect25388"
width="13.241167"
height="11.006019"
x="116.43545"
y="44.239044" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="119.76878"
y="52.694546"
id="text25392"><tspan
id="tspan25390"
style="stroke-width:0.264583"
x="119.76878"
y="52.694546">a</tspan></text>
</g>
<g
id="g42545"
transform="translate(47.92665,62.05058)">
<ellipse
style="fill:#fff6d5;stroke:#000000;stroke-width:0.264583"
id="path25418"
cx="19.969437"
cy="54.462101"
rx="15.61247"
ry="5.0831294" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:8.46667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="11.981662"
y="57.003662"
id="text27446"><tspan
id="tspan27444"
style="font-size:8.46667px;stroke-width:0.264583"
x="11.981662"
y="57.003662">text</tspan></text>
</g>
<g
id="g42553"
transform="translate(30.135694,8.3146389)">
<ellipse
style="fill:#fff6d5;stroke:#000000;stroke-width:0.264583"
id="ellipse42547"
cx="19.969437"
cy="54.462101"
rx="15.61247"
ry="5.0831294" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:8.46667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="11.981662"
y="57.003662"
id="text42551"><tspan
id="tspan42549"
style="font-size:8.46667px;stroke-width:0.264583"
x="11.981662"
y="57.003662">WS</tspan></text>
</g>
<g
id="g42561"
transform="translate(260.32885,64.59214)">
<ellipse
style="fill:#fff6d5;stroke:#000000;stroke-width:0.264583"
id="ellipse42555"
cx="19.969437"
cy="54.462101"
rx="15.61247"
ry="5.0831294" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:8.46667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="11.981662"
y="57.003662"
id="text42559"><tspan
id="tspan42557"
style="font-size:8.46667px;stroke-width:0.264583"
x="11.981662"
y="57.003662">text</tspan></text>
</g>
<g
id="g42561-5"
transform="translate(143.31517,64.407045)">
<ellipse
style="fill:#fff6d5;stroke:#000000;stroke-width:0.264583"
id="ellipse42555-9"
cx="19.969437"
cy="54.462101"
rx="15.61247"
ry="5.0831294" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:8.46667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="11.981662"
y="57.003662"
id="text42559-0"><tspan
id="tspan42557-9"
style="font-size:8.46667px;stroke-width:0.264583"
x="11.981662"
y="57.003662">text</tspan></text>
</g>
<g
id="g42675"
transform="translate(153.58313,-13.890189)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.143919"
id="rect42669"
width="17.96752"
height="11.006228"
x="96.822884"
y="71.469994" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="102.34091"
y="81.014839"
id="text42673"><tspan
id="tspan42671"
style="stroke-width:0.264583"
x="102.34091"
y="81.014839">li</tspan></text>
</g>
<g
id="g42683"
transform="translate(122.72127,-13.890189)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.143919"
id="rect42677"
width="17.96752"
height="11.006228"
x="96.822884"
y="71.469994" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="102.34091"
y="81.014839"
id="text42681"><tspan
id="tspan42679"
style="stroke-width:0.264583"
x="102.34091"
y="81.014839">li</tspan></text>
</g>
<g
id="g42691"
transform="translate(137.60758,40.9351)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.123546"
id="rect42685"
width="13.241167"
height="11.006019"
x="116.43545"
y="44.239044" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="119.76878"
y="52.694546"
id="text42689"><tspan
id="tspan42687"
style="stroke-width:0.264583"
x="119.76878"
y="52.694546">a</tspan></text>
</g>
<g
id="g42699"
transform="translate(105.65648,40.9351)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.123546"
id="rect42693"
width="13.241167"
height="11.006019"
x="116.43545"
y="44.239044" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="119.76878"
y="52.694546"
id="text42697"><tspan
id="tspan42695"
style="stroke-width:0.264583"
x="119.76878"
y="52.694546">a</tspan></text>
</g>
<g
id="g42707"
transform="translate(72.979218,40.9351)">
<rect
style="fill:#e3dbdb;stroke:#000000;stroke-width:0.123546"
id="rect42701"
width="13.241167"
height="11.006019"
x="116.43545"
y="44.239044" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="119.76878"
y="52.694546"
id="text42705"><tspan
id="tspan42703"
style="stroke-width:0.264583"
x="119.76878"
y="52.694546">a</tspan></text>
</g>
<g
id="g51326"
transform="translate(313.33863,58.81907)">
<path
style="fill:#d7e3f4;stroke:#000000"
id="path42587"
d="m -209.95784,266.22105 -22.75406,-13.15944 -23.74005,11.28397 5.48397,-25.70689 -18.06776,-19.09119 26.14334,-2.7283 12.57355,-23.08297 10.6735,24.02071 25.83866,4.82513 -19.54676,17.57391 z"
transform="scale(0.26458333)" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:7.05556px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-68.580421"
y="63.502899"
id="text44449"><tspan
id="tspan44447"
style="font-size:7.05556px;stroke-width:0.264583"
x="-68.580421"
y="63.502899">href</tspan></text>
</g>
<g
id="g51326-1"
transform="translate(255.83298,58.994653)">
<path
style="fill:#d7e3f4;stroke:#000000"
id="path42587-0"
transform="scale(0.26458333)"
d="m -209.95784,266.22105 -22.75406,-13.15944 -23.74005,11.28397 5.48397,-25.70689 -18.06776,-19.09119 26.14334,-2.7283 12.57355,-23.08297 10.6735,24.02071 25.83866,4.82513 -19.54676,17.57391 z" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:7.05556px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-68.580421"
y="63.502899"
id="text44449-4"><tspan
id="tspan44447-4"
style="font-size:7.05556px;stroke-width:0.264583"
x="-68.580421"
y="63.502899">href</tspan></text>
</g>
<g
id="g56298"
transform="translate(-5.809291,-112.95431)">
<path
style="fill:#d7e3f4;stroke:#000000"
id="path51328"
transform="matrix(0.26458333,0,0,0.26458333,299.24357,170.97048)"
d="m -209.95784,266.22105 -22.75406,-13.15944 -23.74005,11.28397 5.48397,-25.70689 -18.06776,-19.09119 26.14334,-2.7283 12.57355,-23.08297 10.6735,24.02071 25.83866,4.82513 -19.54676,17.57391 z" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:7.05556px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="234.77094"
y="234.98685"
id="text51332"><tspan
id="tspan51330"
style="font-size:7.05556px;stroke-width:0.264583"
x="234.77094"
y="234.98685">id</tspan></text>
</g>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 198.03974,42.44422 -1.02695,16.10166"
id="path56322" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 196.24258,68.58603 0.25674,16.66048"
id="path56324" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 210.22221,42.80937 18.11247,14.70956"
id="path56326" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 229.36163,68.58603 229.8751,84.4763"
id="path56328" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.200916px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 210.22221,42.80937 47.63721,14.9663"
id="path56330" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 259.65658,68.58603 1.54041,18.2009"
id="path56332" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 185.43703,42.80937 171.55065,57.5798"
id="path56334" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 163.38027,68.58603 0.25674,15.89027"
id="path56338" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 127.43712,68.58603 0.77021,15.63353"
id="path56340" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 185.43703,42.80937 -58.51339,14.9663"
id="path56342" />
<path
style="display:inline;fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 254.04303,96.180164 232.49575,109.27554"
id="path56446" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 252.4001,110.07844 1.64293,-13.89828"
id="path56472" />
<path
style="display:inline;fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 267.2842,96.18016 12.65458,17.82088"
id="path56474" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 58.455988,42.44422 81.516584,57.216722"
id="path56797" />
<path
style="display:inline;fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 49.742052,42.843521 1.270784,14.523227"
id="path56949" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 194.89445,110.25403 1.50921,-15.713691"
id="path177" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 68.291992,94.540339 0.77021,17.140171"
id="path203" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:8.46667px;line-height:1.25;font-family:sans-serif;fill:#00aa00;fill-opacity:1;stroke:none;stroke-width:0.265;stroke-miterlimit:4;stroke-dasharray:none"
x="277.78925"
y="101.15429"
id="text2717"><tspan
id="tspan2715"
style="font-size:8.46667px;fill:#00aa00;stroke-width:0.265;stroke-miterlimit:4;stroke-dasharray:none"
x="277.78925"
y="101.15429">2</tspan></text>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 81.516584,68.222949 75.940678,85.174144"
id="path12329" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 162.5144,94.540339 1.02695,19.194071"
id="path12472" />
<path
style="fill:none;stroke:#00ffff;stroke-width:0.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.66004407;stroke-miterlimit:4;stroke-dasharray:none"
d="m 163.54135,113.73441 c 1.45484,-0.51347 3.00102,-0.81857 4.36453,-1.54042 0.36262,-0.19198 -0.44617,-1.86606 -0.77021,-3.59432 -0.0789,-0.42056 0.0531,-0.85909 0,-1.28368 -0.52743,-4.21939 -1.20059,-8.332197 -1.54043,-12.580106 -0.27426,-3.428351 -0.78216,-6.842463 -1.02694,-10.269474 -0.088,-1.231347 -0.15046,-2.062189 -0.25674,-3.337578 -0.0744,-0.893297 0.17673,-1.940433 0,-2.824104 -0.3627,-1.813497 -0.62278,-4.331483 -0.25674,-6.161683 0.35377,-1.768856 1.09324,-3.346008 1.54042,-5.134737 0.27416,-1.096624 0.45509,-2.641206 1.02695,-3.594317 0.3277,-0.546161 1.12257,-1.409459 1.28369,-2.053894 0.14664,-0.586573 0.0841,-1.111041 0.51347,-1.54042 0.1488,-0.148804 0.87814,-0.36467 1.02695,-0.513474 0.13531,-0.135311 0.10364,-0.398656 0.25673,-0.513472 0.76479,-0.573593 2.50236,-0.420672 3.33758,-0.513474 0.8609,-0.09566 1.70938,-0.390906 2.56737,-0.513474 2.26225,-0.323178 4.65642,0.227547 6.93189,0 5.32441,-0.532443 10.80648,-0.256736 16.17442,-0.256736 4.36453,0 8.72905,0 13.09358,0 1.73316,0 3.67408,-0.190823 5.39147,0 1.61096,0.178996 3.26617,0.406016 4.878,0.513471 1.02095,0.192178 2.0559,-0.06406 3.08084,0 4.28411,0.267759 8.5948,0.753431 12.83684,1.283685 3.12357,0.390445 6.59916,0 9.756,0 0.24588,0 3.56918,-0.02514 3.59432,0 0.0228,0.02283 0.23589,1.734619 0.25674,1.797158 0.46183,1.385493 0.74577,1.690203 1.54042,3.080843 1.52806,2.67412 3.15519,5.614514 4.10778,8.472313 0.56352,1.690557 -1.07148,4.777157 -1.54042,6.418421 -0.60494,2.117315 -0.49978,4.255 -0.77021,6.418421 -0.19631,1.570487 0,3.284297 0,4.877998 0,3.193831 -0.008,6.327048 0.25674,9.499262 0.28825,3.458951 0,7.053301 0,10.526211 0,2.67311 0.25674,5.27359 0.25674,7.95884 0,0.52861 -0.12426,2.04567 -0.25674,2.31063 -0.006,0.0124 -0.47669,0.35129 -0.25674,0.51347 0.61138,0.45082 1.29948,0.78705 1.94921,1.18057"
id="path12834" />
<path
style="fill:none;stroke:#0000b8;stroke-width:0.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.64017659;stroke-miterlimit:4;stroke-dasharray:none"
d="m 231.86259,124.97205 c -1.06549,4.92823 2.00451,-2.26192 3.05159,-1.73838 1.24894,0.62447 2.714,0.45842 3.85106,1.02695 0.41077,0.20539 1.12964,-0.20539 1.54042,0 1.49925,0.74962 3.32282,0.77021 5.13473,0.77021 0.80895,0 2.62974,-0.35392 3.33758,0 0.40386,0.20193 0.29108,0.25673 0.77021,0.25673 0.77021,0 1.54042,0 2.31063,0 0.0856,0 0.27259,-0.0841 0.25674,0 -0.037,0.19629 -0.23241,0.32493 -0.34861,0.48739"
id="path13851" />
<path
style="fill:none;stroke:#00b600;stroke-width:0.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.6754967;stroke-miterlimit:4;stroke-dasharray:none"
d="m 235.31978,115.63102 c -0.5631,-0.54662 -1.17298,-1.04885 -1.68928,-1.63987 -0.0563,-0.0645 0.19622,0.0605 0.25673,0 0.0605,-0.0605 -0.0383,-0.1802 0,-0.25674 0.36658,-0.73315 1.39932,-1.36077 2.0539,-1.79716 1.75387,-1.16925 3.04777,-2.59226 4.62126,-3.85105 0.90153,-0.72122 1.53629,-1.79302 2.31063,-2.56737 0.54877,-0.54877 1.61513,-1.21214 2.0539,-1.79716 0.96224,-1.28299 1.96513,-2.73534 3.08084,-3.851051 1.41913,-1.41913 4.5239,-3.34998 6.41842,-4.107789 1.35732,-0.542928 2.20174,-1.696011 3.85105,-1.283684 3.67202,0.918006 7.04651,2.972641 10.5262,4.364527 0.84524,0.338095 1.96488,0.447998 2.82411,0.77021 0.80278,0.301043 3.6299,2.226727 4.10779,2.824107 1.05423,1.3178 1.42738,3.31168 2.05391,4.878 0.33324,0.83311 0.56047,1.72839 0.7702,2.56736 0.16751,0.67 0.67469,1.01203 1.02696,1.54043 0.11178,0.16767 0.90844,2.21185 1.02692,2.56737 0.21529,0.64582 0.82669,1.19638 1.02696,1.79715 0.0541,0.16238 -0.0541,0.3511 0,0.51348 0.0605,0.18154 0.37309,0.66541 0.25675,0.51347 -0.6948,-0.90738 -1.30551,-1.87614 -1.95826,-2.81421"
id="path13919" />
<path
style="fill:none;stroke:#d75b00;stroke-width:0.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.65121412;stroke-miterlimit:4;stroke-dasharray:none"
d="m 23.876524,62.387045 c 4.508735,-0.0098 8.951351,0.660628 13.350313,1.54042 0.302557,0.06051 0.757659,-0.134643 1.026949,0 0.108249,0.05413 0.13806,0.233003 0.256736,0.256739 1.003948,0.200789 1.854126,-0.06659 2.824104,0.256736 0.301961,0.100652 2.80997,0.05296 2.824104,0.256735 0.08538,1.230662 0,2.467237 0,3.700854"
id="path13987" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:8.46667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="30.808424"
y="61.103344"
id="text19497"><tspan
style="font-size:8.46667px;fill:#ff7f2a;stroke-width:0.264583"
x="30.808424"
y="61.103344"
id="tspan7798">1</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:8.46667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="127.5982"
y="47.239559"
id="text28349"><tspan
id="tspan28347"
style="font-size:8.46667px;fill:#d40000;stroke-width:0.264583"
x="127.5982"
y="47.239559">6</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:8.46667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="238.25177"
y="137.61092"
id="text34031"><tspan
id="tspan34029"
style="font-size:8.46667px;fill:#0000ff;stroke-width:0.264583"
x="238.25177"
y="137.61092">1</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:8.46667px;line-height:1.25;font-family:sans-serif;fill:#00ccff;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="167.64914"
y="81.899033"
id="text40367"><tspan
id="tspan40365"
style="font-size:8.46667px;fill:#00ccff;stroke-width:0.264583"
x="167.64914"
y="81.899033">7</tspan></text>
<path
style="fill:none;stroke:#bd0000;stroke-width:0.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.69315672;stroke-miterlimit:4;stroke-dasharray:none"
d="m 68.291992,94.540339 c 0.941367,-1.56082 1.820934,-3.160623 2.824104,-4.682456 0.43424,-0.658751 1.087959,-1.150784 1.540421,-1.797156 2.028877,-2.898396 3.923876,-5.737217 6.161685,-8.472315 2.962307,-3.620598 5.398868,-6.183871 6.931893,-10.782946 0.619884,-1.859653 -0.07402,0.404773 0.513474,-0.770212 0.365334,-0.730666 1.856597,-5.559052 1.283684,-6.418419 -1.144757,-1.717132 -6.885956,-4.058846 -8.729051,-4.878001 -2.589699,-1.150977 -5.033912,-2.623815 -7.44537,-4.107788 -1.996088,-1.228363 -4.216934,-2.163041 -5.904944,-3.851053 -0.665758,-0.665755 -1.464633,-1.060577 -2.053897,-1.797156 -0.716806,-0.896011 -1.229693,-2.087782 -1.797156,-3.080843 -0.495837,-0.867714 -1.256797,-1.500089 -1.797158,-2.31063 -0.500655,-0.750982 -0.570204,-1.597152 -1.283684,-2.310632 -0.3429,-0.3429 -1.583278,-1.904098 -0.77021,-2.31063 0.617119,-0.30856 1.372377,-0.14913 2.053894,-0.256739 3.689535,-0.582557 7.347161,-1.036894 11.039684,-1.54042 0.864732,-0.117919 1.704284,-0.384011 2.567368,-0.513474 2.219386,-0.332907 4.464145,-0.355645 6.675157,-0.77021 3.404182,-0.638283 6.835447,-1.367904 10.269471,-1.797158 2.586101,-0.323263 6.45087,-0.140828 8.98579,0 8.631713,0.479541 16.836833,3.506514 25.416943,4.364526 2.88959,0.28896 5.84018,0.325769 8.72905,0.77021 2.04871,0.315185 4.0781,0.81859 6.16168,1.026949 3.91376,0.391374 7.76647,-0.229256 11.55316,-0.770213 1.1447,-0.163525 2.46689,0.09395 3.59432,0 0.35163,-0.0293 0.67682,-0.212971 1.02695,-0.256736 1.73444,-0.216804 3.64276,0 5.39147,0 3.67989,0 7.35979,0 11.03968,0 4.45011,0 8.90021,0 13.35031,0 2.14283,0 6.76912,-0.189626 8.47232,1.026949 2.92132,2.086652 4.06016,5.24859 5.13474,8.472313 0.18031,0.540959 0.61105,1.062958 0.77021,1.540422 0.17723,0.531691 0,1.481775 0,2.053895 0,1.500235 -0.0334,2.913864 0.25673,4.364524 0.19618,0.980916 -0.2419,2.113211 0,3.080843 0.31532,1.261258 -0.14092,2.914798 0.25674,4.107788 0.67404,2.02211 0.41391,5.375802 0,7.445367 -0.29922,1.496092 0.0392,3.141768 -0.25674,4.621263 -0.19001,0.950044 0,2.109843 0,3.080842 0,2.824105 0,5.648209 0,8.472316 0,0.790199 0.19017,1.806683 0,2.567368 -0.1452,0.5808 -0.35193,2.757768 -0.51347,3.08084 -0.18903,0.378061 -0.34064,0.340636 -0.51347,0.513475 -0.083,0.08299 -0.46427,1.91699 -0.51348,2.31063 -0.44384,3.550756 0.18846,7.221408 -0.25673,10.782948 -0.2303,1.84234 0.30508,3.81769 0,5.64821 -0.30149,1.80893 -0.67225,3.61794 -1.02695,5.39147 -0.15922,0.79611 -0.59409,1.51809 -0.77021,2.31063 -0.22585,1.01633 -0.32089,2.18219 -0.77021,3.08084 -0.55858,1.11716 2.27884,1.06323 3.49302,1.35615"
id="path40786" />
<path
style="fill:none;stroke:#d75b00;stroke-width:0.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.651214"
d="m 61.774027,62.387046 c 4.508735,-0.0098 8.951351,0.660628 13.350313,1.54042 0.302557,0.06051 0.757659,-0.134643 1.026949,0 0.108249,0.05413 0.13806,0.233003 0.256736,0.256739 1.003948,0.200789 1.854126,-0.06659 2.824104,0.256736 0.301961,0.100652 2.80997,0.05296 2.824104,0.256735 0.08538,1.230662 0,2.467237 0,3.700854"
id="path12234" />
<path
style="fill:none;stroke:#ff00ff;stroke-width:0.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="m 26.561798,68.586029 c 0.303014,1.185672 0.505309,2.40175 0.90904,3.557016 0.07986,0.228502 0.38894,0.305914 0.513474,0.513472 0.517774,0.862957 -0.0061,0.590944 0.513474,1.283684 0.620483,0.827312 2.653755,3.02406 3.594315,3.337578 1.820515,0.606838 3.972221,0.961565 5.904947,1.283684 1.732155,0.288693 4.924848,-0.116654 6.418421,0.256739 2.675696,0.668925 5.931061,0.256736 8.729051,0.256736 2.651752,0 5.113335,-0.08201 7.702105,-0.513475 0.7468,-0.124465 1.561732,0.106987 2.31063,0 1.675196,-0.239313 3.807479,-0.604829 5.391473,-1.283684 0.386527,-0.165653 0.830921,-0.657018 1.283684,-0.77021 0.818775,-0.204692 1.787946,-0.581562 2.567369,-1.026946 0.210161,-0.120094 0.342315,-0.342317 0.513474,-0.513474 0.256736,-0.171159 0.494226,-0.375481 0.77021,-0.513474 0.890032,-0.445016 1.741233,-0.920819 2.567368,-1.54042 0.906376,-0.679783 2.378446,-2.601278 3.337579,-3.080843 0.894482,-0.447241 1.676466,-0.655894 2.467819,-1.433883"
id="path12291" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:8.46667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="66.238106"
y="70.859344"
id="text12521"><tspan
style="font-size:8.46667px;fill:#ff7f2a;stroke-width:0.264583"
x="66.238106"
y="70.859344"
id="tspan12519">1</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:8.46667px;line-height:1.25;font-family:sans-serif;fill:#ff00ff;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="38.767265"
y="88.060707"
id="text15933"><tspan
style="font-size:8.46667px;fill:#ff00ff;stroke-width:0.264583"
x="38.767265"
y="88.060707"
id="tspan15931">1</tspan></text>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 109.62662,16.687893 101.1543,35.172944"
id="path20229" />
</g>
</svg></p>
<p>The last requirement makes this a non-metric because it violates the triangle inequality. Suppose you have
a list with 5 items. If it weren’t for the last requirement, the distance between the first and the last item
would be 2: Go up one step to the list element, go down one step to the fifth item. Applying the last requirement,
you won’t go up because the first item is already the penultimate element on its <code>ancestor-or-self</code>
axis. Instead, you go sideways to the fifth item, and the distance then is 4. The individual distances for
each list item to the list element equal 1, so the sum of both distances is 2. This violates the triangle
inequality that says that the sum of the distances to some third point is at least as large as the direct
distance between two points.</p>
<p>This non-metric was chosen because it seemed counter-intuitive that, for example, the first and the last
paragraph of a novel have a distance of 4: Go up to the common ancestor, which might be <code>body</code>,
passing a <code>chapter</code> element, then go down through another <code>chapter</code> to the last paragraph
of the novel. On the other hand, using the number of intermediate nodes as a metric would make guessing a secretly
selected item much easier: You take your first guess and go that many nodes back or forth, like in
<code>let $guess := //p[10] return (//node()[$guess << .])[24]</code> where your initial guess
was <code>//p[10]</code>, the reported distance was 24 and you move 24 nodes forward in order to select
an item of the secret set.</p>
<p>The “metric” applied here seeks to strike the balance between being intuitive and being ambiguous enough
to avoid easy wins.</p>
<h3>Tips</h3>
<h4 id="tips_query">Query the document</h4>
<p>Querying the document without selecting any nodes yields a warning, but doesn’t count as an attempt.</p>
<p>Try this expression in order to get a list of element names and their frequencies, name and frequency
separated by <code>~</code>, sorted by frequency:</p>
<p><input type="text" size="140" value="sort(for $n in distinct-values(//*/name()) return $n || '~' || count(//*[name()=$n]), (), function($i) {-number(substring-after($i, '~'))})"/></p>
<p>might yield (when applied to this HTML document):</p>
<p class="warning" id="xpathle_error3"> Warning (code XPathle03): <code>path~31 text~29 tspan~29 g~25 p~19 rect~17 code~15 li~10 span~7 a~7 div~6 h3~5 ellipse~4 ul~3 script~2 html~1 head~1 title~1 meta~1 link~1 body~1 h1~1 details~1 summary~1 svg~1 defs~1 input~1</code> is not a node from the document.</p>
<h4 id="tips_scatter">Scatter your first shots evenly</h4>
<p>It has been said that at most two times the secretly selected items (or 20, whatever is the lower number; at least 4) will be highlighted.
Suppose that, as it is in the “HTML landing page for the transpect documentation” case, 33 items have been secretly selected.
Then you can get hints for at most 20 guessed items. You can select 20 evenly spaced (in terms of <code>position()</code>) elements
below the document node:</p>
<p><input type="text" size="170" value="let $start := /*, $count := count($start/descendant-or-self::*), $dist := max(($count idiv 20, 1)) return $start/descendant-or-self::*[position() mod $dist = $dist idiv 2]"/></p>
<p>In that expression, replace 20 by two times the secret items if they are fewer than 10.</p>
<p>Once you identify a specific element as the common ancestor of the candidates, you can set <code>$start</code> to that element.
In the landing page example, this common ancestor might be <code>//body</code> but this wouldn’t be a significant improvement over <code>/</code>.
In other documents, the situation may be different.</p>
<p>The scatter method doesn’t work well in large documents with few secret items. If there’s just one secret item, you can randomly select
an element at about a third of the document and another guess at two thirds. But it might be as good a first guess as anything else.</p>
<h4 id="tips_siblings">Draw distance samples among siblings</h4>
<p>If the document contains many siblings on the same level, for example <code>xs:element</code>, <code>xs:simpleType</code>,
and <code>xs:complexType</code> in the XSD that is the <a href="#daily_2022-06-23">2022-06-23 daily challenge</a>,
you can select as many of them as can be highlighted and see whether some of them are closer to target items than others.</p>
<p>A modified scatter expression might look like this:</p>
<p><input type="text" size="120" value="let $start := /*, $count := count($start/*), $dist := max(($count idiv 4, 1)) return $start/*[position() mod $dist = 0]"/></p>
<p>In this expression, we want to skip initial <code>xs:annotation</code> and <code>xs:import</code> elements. Therefore
we don’t use <code>mod $dist = $dist idiv 2</code> which would select an item in the middle of each evenly spaced selected item groups. Specifying
<code>mod $dist = 0</code> instead causes the first <code>$dist</code> elements to be skipped.</p>
<p>Also note that <code>$dist := $count idiv 4</code> although only one item has been selected by the secret
expression. We didn’t use two times this count, which would amount to just two items, because the minimum number
of highlighted items is set to <code>4</code>, see <a href="#highlight_formula">above</a>.</p>
<p>Once you have a candidate item that has the shortest distance of all equally scattered candidates, you can look at the
preceding or following siblings whether one of them is even closer, like so:</p>
<p><input type="text" size="140" value="let $start := /*, $count := count($start/*), $dist := max(($count idiv 4, 1)) return $start/*[position() mod $dist = 0]/following-sibling::*[1]"/></p>
<p>Then you can either reassign <code>$start</code> to that candidate and apply the same procedure to its children or grandchildren,
or you can enter a new expression that addresses the candidate more directly, such as:</p>
<p><input type="text" size="50" value="/*/*:complexType[@name = 'KeyCodeType']/*/*"/></p>
<p>Then you are only 2 items away from the solution (in <a href="#daily_2022-06-23">that example</a>).</p>
<h3>Known Issues</h3>
<ul>
<li>Multiline attribute values, as they may appear in XPath expressions in XSLT <code>@select</code> attributes,
might not be reproduced correctly. This is because XML parsers are required to turn newlines in attributes into
plain spaces, which is a pity. As a heuristic, if there are at least 5 spaces in a row in an attribute value,
it is assumed that the first space used to be a newline prior to parsing, and it will be converted to
a newline in the rendered XML. Of course this heuristic may fail if indentation was done using tabs,
if there were spaces before the newlines, or if there was no newline at all.</li>
</ul>
<h3>To Do</h3>
<ul>
<li>Obfuscate the configuration and the current attempt number better. Or leave it as weakly secure as it is.</li>
<li>Let users resume the game by storing session data in the browser.</li>
</ul>
</details>
<div id="controls"></div>
<div id="controls2"></div>
<div id="rendition"></div>
<div id="footer">
<p>XML+XSLT in the browser using <a href="http://www.saxonica.com/saxon-js/index.xml">SaxonJS</a>, from <a
href="https://www.saxonica.com">Saxonica</a>. View the <a href="https://github.com/gimsieke/xpathle/blob/main/xpathle.xsl">XSLT source</a> and the <a
href="https://github.com/gimsieke/xpathle/blob/main/xpathle-lib.xsl">XPathle XSLT library</a> that can also run on the command line.</p>
<p>© 2022 <a href="https://twitter.com/gimsieke">Gerrit Imsieke</a>. Released under a <a
href="https://github.com/gimsieke/xpathle/blob/main/LICENSE">BSD 2-clause license</a>.
File a bug report <a href="https://github.com/gimsieke/xpathle/issues">here</a>.</p>
</div>
<div id="config"></div>
</body>
</html>