-
Notifications
You must be signed in to change notification settings - Fork 12
/
stix_common.xsl
1660 lines (1457 loc) · 68.7 KB
/
stix_common.xsl
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015 – The MITRE Corporation
All rights reserved. See LICENSE.txt for complete terms.
This styleshseet has logic that can be reused by various components in the
stix-to-html transformation.
-->
<xsl:stylesheet
version="2.0"
xmlns:stix="http://stix.mitre.org/stix-1"
xmlns:cybox="http://cybox.mitre.org/cybox-2"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:stixCommon="http://stix.mitre.org/common-1"
xmlns:indicator="http://stix.mitre.org/Indicator-2"
xmlns:campaign="http://stix.mitre.org/Campaign-1"
xmlns:incident="http://stix.mitre.org/Incident-1"
xmlns:ta="http://stix.mitre.org/ThreatActor-1"
xmlns:et="http://stix.mitre.org/ExploitTarget-1"
xmlns:TTP="http://stix.mitre.org/TTP-1"
xmlns:COA="http://stix.mitre.org/CourseOfAction-1"
xmlns:capec="http://stix.mitre.org/extensions/AP#CAPEC2.5-1"
xmlns:marking="http://data-marking.mitre.org/Marking-1"
xmlns:tlpMarking="http://data-marking.mitre.org/extensions/MarkingStructure#TLP-1"
xmlns:stixVocabs="http://stix.mitre.org/default_vocabularies-1"
xmlns:cyboxCommon="http://cybox.mitre.org/common-2"
xmlns:cyboxVocabs="http://cybox.mitre.org/default_vocabularies-2"
xmlns:simpleMarking="http://data-marking.mitre.org/extensions/MarkingStructure#Simple-1"
xmlns:terms="http://data-marking.mitre.org/extensions/MarkingStructure#Terms_Of_Use-1"
xmlns:ttp='http://stix.mitre.org/TTP-1'
xmlns:maecBundle="http://maec.mitre.org/XMLSchema/maec-bundle-4"
xmlns:maecPackage="http://maec.mitre.org/XMLSchema/maec-package-2"
>
<xsl:output method="html" omit-xml-declaration="yes" indent="yes" media-type="text/html" version="4.0" />
<!-- this depends on some of the templates in the cybox-to-html transform -->
<xsl:include href="cybox_common.xsl"/>
<xsl:include href="stix_objects.xsl" />
<xsl:include href="stix_objects__customized.xsl" />
<!--
Print the "stix header" table (this shows up in the output below the
metadata table).
-->
<xsl:template name="processHeader">
<xsl:for-each select="//stix:STIX_Package/stix:STIX_Header|/maecBundle:MAEC_Bundle/maecBundle:Malware_Instance_Object_Attributes">
<div class="stixHeader">
<table class="grid topLevelCategory tablesorter" cellspacing="0">
<colgroup>
<col class="stixHeaderColumnHeadings" />
<col class="stixHeaderColumnValues" />
</colgroup>
<thead>
<!--
<tr>
<th class="header"></th>
<th class="header"></th>
</tr>
-->
</thead>
<tbody>
<xsl:variable name="evenOrOdd" select="if(position() mod 2 = 0) then 'even' else 'odd'" />
<xsl:for-each select="child::*">
<xsl:call-template name="processStixHeaderNameValue"><xsl:with-param name="evenOrOdd" select="$evenOrOdd"/></xsl:call-template>
</xsl:for-each>
</tbody>
</table>
</div>
</xsl:for-each>
</xsl:template>
<!--
Designed for use in the STIX_HEADER, at least.
Does not yet take into consideration Handling/Marking complexity.
For handling, the text value of simpleMarking:Statement is printed.
For information source, the whole element is printed out in
cyboxProperties mode.
-->
<xsl:template name="processStixHeaderNameValue">
<xsl:param name="evenOrOdd" />
<tr><xsl:attribute name="class"><xsl:value-of select="$evenOrOdd" /></xsl:attribute>
<td class="Stix{local-name()}Name">
<xsl:value-of select="if(../self::maecBundle:Malware_Instance_Object_Attributes) then 'Malware Instance Object Attributes' else fn:local-name(.)"/>
</td>
<td class="Stix{local-name()}Value">
<xsl:variable name="class" select="if (self::stix:Description) then ('longText expandableContainer expandableToggle expandableContents expandableSame collapsed') else ('') " />
<div>
<xsl:if test="$class">
<xsl:attribute name="class" select="$class"/>
<xsl:attribute name="onclick">toggle(this);</xsl:attribute>
</xsl:if>
<!--
for now, just show the text of simpleMarking:Statement & TLP
<marking:Marking_Structure color="GREEN" xsi:type="tlpMarking:TLPMarkingStructureType"/>
TODO: customization toggle whether to show simpleMarking
-->
<xsl:choose>
<xsl:when test="self::stix:Handling">
<xsl:apply-templates select="."/>
</xsl:when>
<xsl:when test="self::stix:Information_Source">
<xsl:apply-templates mode="cyboxProperties" />
</xsl:when>
<!--
html content is saved as an escaped attribute
"data-stix-content" and will be later parsed and
expanded via javascript
-->
<xsl:when test="self::*[@structuring_format='HTML5']">
<xsl:variable name="content" select="./text()" />
<div class="htmlContainer" data-stix-content="{$content}" />
</xsl:when>
<xsl:when test="self::cybox:Properties">
<xsl:apply-templates select="." mode="cyboxProperties" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="self::node()[text()]"/>
</xsl:otherwise>
</xsl:choose>
</div>
</td>
</tr>
</xsl:template>
<xsl:template match="stix:Handling|indicator:Handling">
<xsl:if test="marking:Marking">
<div class="cyboxPropertiesConstraints">WARNING: Handling of marking data is not fully supported in stix-to-html yet.</div>
</xsl:if>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="marking:Marking">
<div class="marking">
<xsl:apply-templates select="marking:Marking_Structure" />
</div>
</xsl:template>
<xsl:template match="marking:Marking_Structure">
<xsl:if test=".[fn:resolve-QName(fn:data(@xsi:type), .)=fn:QName('http://data-marking.mitre.org/extensions/MarkingStructure#Simple-1', 'SimpleMarkingStructureType')]">
<div class="markingSimple">
<xsl:apply-templates select="simpleMarking:Statement"/>
</div>
</xsl:if>
<xsl:if test=".[fn:resolve-QName(fn:data(@xsi:type), .)=fn:QName('http://data-marking.mitre.org/extensions/MarkingStructure#TLP-1', 'TLPMarkingStructureType')]">
<div class="markingTlp">
<xsl:if test="lower-case(@color)='red'"><xsl:attribute name="class" select="'tlpred'"/></xsl:if>
<xsl:if test="lower-case(@color)='amber'"><xsl:attribute name="class" select="'tlpamber'"/></xsl:if>
<xsl:if test="lower-case(@color)='green'"><xsl:attribute name="class" select="'tlpgreen'"/></xsl:if>
<xsl:if test="lower-case(@color)='white'"><xsl:attribute name="class" select="'tlpwhite'"/></xsl:if>
Traffic Light Protocol (TLP): <xsl:value-of select="@color"/>
<xsl:apply-templates select="../marking:Controlled_Structure" />
</div>
</xsl:if>
<xsl:if test=".[fn:resolve-QName(fn:data(@xsi:type), .)=fn:QName('http://data-marking.mitre.org/extensions/MarkingStructure#Terms_Of_Use-1', 'TermsOfUseMarkingStructureType')]">
<div class="markingTermsOfUse">
<xsl:apply-templates select="terms:Terms_Of_Use"/>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="simpleMarking:Statement">
<div class="simpleMarkingStatment container">
<div class="simpleMarkingStatement heading">Simple Marking Statement <xsl:apply-templates select="../../marking:Controlled_Structure" />:</div>
<div class="simpleMarkingStatement contents">
<xsl:value-of select="text()" />
</div>
</div>
</xsl:template>
<xsl:template match="terms:Terms_Of_Use">
<div class="simpleMarkingStatment container">
<div class="simpleMarkingStatement heading">Terms of Use <xsl:apply-templates select="../../marking:Controlled_Structure" />:</div>
<div class="simpleMarkingStatement contents">
<xsl:apply-templates />
</div>
</div>
</xsl:template>
<xsl:template match="marking:Controlled_Structure">
<span class="markingControlStructure cyboxPropertiesConstraints">
[<xsl:choose>
<xsl:when test="text() = '//node()'">marking for whole document</xsl:when>
<xsl:when test="not(text()) or (fn:normalize-space(text()) = '')">no marking control structure specified</xsl:when>
<xsl:otherwise>marking for (xpath): <xsl:value-of select="." /></xsl:otherwise>
</xsl:choose>]
</span>
</xsl:template>
<!--
The process*Contents templates are used to convert the top level catgory "items" into html.
This one processes campaigns.
-->
<xsl:template name="processCampaignContents">
<div>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<!--
<xsl:attribute name="class">
<xsl:if test="@id">container baseobj</xsl:if>
</xsl:attribute>
-->
<xsl:if test="campaign:Names">
<xsl:variable name="contents">
<xsl:apply-templates select="campaign:Names" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Names', $contents)" />
</xsl:if>
<xsl:if test="campaign:Status">
<xsl:copy-of select="stix:printNameValueTable('Status', campaign:Status)" />
</xsl:if>
<xsl:if test="campaign:Intended_Effect">
<xsl:variable name="contents">
<xsl:apply-templates select="campaign:Intended_Effect" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Intended Effect', $contents)" />
</xsl:if>
<xsl:if test="campaign:Related_Incidents/campaign:Related_Incident">
<xsl:variable name="contents">
<xsl:apply-templates select="campaign:Related_Incidents/campaign:Related_Incident" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Related Incidents', $contents)" />
</xsl:if>
<xsl:if test="campaign:Related_TTPs/campaign:Related_TTP">
<xsl:variable name="contents">
<xsl:apply-templates select="campaign:Related_TTPs/campaign:Related_TTP" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Related TTPs', $contents)" />
</xsl:if>
<xsl:if test="campaign:Related_Indicators/campaign:Related_Indicator">
<xsl:variable name="contents">
<xsl:apply-templates select="campaign:Related_Indicators/campaign:Related_Indicator" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Related Indicators', $contents)" />
</xsl:if>
<xsl:if test="campaign:Attribution/*">
<xsl:variable name="contents">
<xsl:apply-templates select="campaign:Attribution" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Attribution', $contents)" />
</xsl:if>
<xsl:if test="campaign:Associated_Campaigns">
<xsl:variable name="contents">
<xsl:apply-templates select="campaign:Associated_Campaigns" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Associated Campaigns', $contents)" />
</xsl:if>
<xsl:if test="campaign:Confidence">
<xsl:variable name="contents">
<xsl:apply-templates select="campaign:Confidence" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Confidence', $contents)" />
</xsl:if>
<xsl:if test="campaign:Activity">
<xsl:variable name="contents">
<xsl:apply-templates select="campaign:Activity" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Activity', $contents)" />
</xsl:if>
<xsl:if test="campaign:Information_Source">
<xsl:variable name="contents">
<xsl:apply-templates select="campaign:Information_Source" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Information Source', $contents)" />
</xsl:if>
<xsl:if test="campaign:Handling">
<xsl:variable name="contents">
<xsl:apply-templates select="campaign:Handling" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Handling', $contents)" />
</xsl:if>
</div>
</xsl:template>
<xsl:template match="stixCommon:Relationship">
<div>Relationship: <xsl:apply-templates /></div>
</xsl:template>
<xsl:template match="cybox:Related_Object/cybox:Relationship">
<div>Relationship: <xsl:apply-templates /></div>
</xsl:template>
<xsl:template match="*:Intended_Effect">
<div class="stixCommonValue">
<xsl:apply-templates select="stixCommon:Value" />
</div>
<div class="stixCommonDescription">
<xsl:apply-templates select="stixCommon:Description" />
</div>
</xsl:template>
<xsl:template match="campaign:Attribution">
<xsl:variable name="threatActorCount" select="count(campaign:Attributed_Threat_Actor/stixCommon:Threat_Actor)" />
<xsl:if test="$threatActorCount gt 0">
<div class="stixSectionTitle">Attributed Threat Actor<xsl:if test="$threatActorCount ge 2">s</xsl:if></div>
</xsl:if>
<xsl:apply-templates select="campaign:Attributed_Threat_Actor/stixCommon:Threat_Actor"/>
</xsl:template>
<xsl:template match="campaign:Associated_Campaigns">
<xsl:variable name="associatedCampaignCount" select="count(campaign:Associated_Campaign/stixCommon:Campaign)" />
<xsl:if test="$associatedCampaignCount gt 0">
<div class="stixSectionTitle">Associated Campaign<xsl:if test="$associatedCampaignCount ge 2">s</xsl:if></div>
</xsl:if>
<xsl:apply-templates select="campaign:Associated_Campaign/stixCommon:Campaign"/>
</xsl:template>
<xsl:template match="stixCommon:Threat_Actor[@idref]|stixCommon:Campaign[@idref]|marking:Marking[@idref]|incident:Victim[@idref]">
<div class="">
<xsl:variable name="targetId" select="string(@idref)"/>
<xsl:variable name="relationshipOrAssociationType" select="''" />
<!-- (indicator within composition - - idref: <xsl:value-of select="fn:data(@idref)"/>) -->
<xsl:call-template name="headerAndExpandableContent">
<xsl:with-param name="targetId" select="$targetId"/>
<xsl:with-param name="isComposition" select="fn:false()"/>
<xsl:with-param name="relationshipOrAssociationType" select="''" />
</xsl:call-template>
</div>
</xsl:template>
<!--
The process*Contents templates are used to convert the top level catgory "items" into html.
This one processes incidents.
-->
<xsl:template name="processIncidentContents">
<div>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<!--
<xsl:attribute name="class">
<xsl:if test="@id">container baseobj</xsl:if>
</xsl:attribute>
-->
<xsl:if test="incident:Time">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Time/*" mode="cyboxProperties" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Time', $contents)" />
</xsl:if>
<xsl:if test="incident:External_ID">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:External_ID" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('External ID', $contents)" />
</xsl:if>
<xsl:if test="incident:Description">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Description" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Description', $contents)" />
</xsl:if>
<xsl:if test="incident:Categories/incident:Category">
<xsl:variable name="label" select="if (count(incident:Categories/incident:Category) ge 2) then ('Categories') else ('Category')" />
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Categories/incident:Category" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable($label, $contents)" />
</xsl:if>
<xsl:if test="incident:Reporter">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Reporter" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Reporter', $contents)" />
</xsl:if>
<xsl:if test="incident:Responder">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Responder" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Responder', $contents)" />
</xsl:if>
<xsl:if test="incident:Coordinator">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Coordinator" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Coordinator', $contents)" />
</xsl:if>
<xsl:if test="incident:Victim">
<xsl:variable name="label" select="if (count(incident:Victim) ge 2) then ('Victims') else ('Victim')" />
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Victim" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable($label, $contents)" />
</xsl:if>
<xsl:if test="incident:Affected_Assets">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Affected_Assets" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Affected Assets', $contents)" />
</xsl:if>
<xsl:if test="incident:Impact_Assessment">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Impact_Assessment" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Impact Assessment', $contents)" />
</xsl:if>
<xsl:if test="incident:Status">
<xsl:copy-of select="stix:printNameValueTable('Status', incident:Status)" />
</xsl:if>
<xsl:if test="incident:Related_Indicators/*">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Related_Indicators/*" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Related Indicators', $contents)" />
</xsl:if>
<xsl:if test="incident:Related_Observables/incident:Related_Observable">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Related_Observables/incident:Related_Observable" mode="cyboxProperties" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Related Observables', $contents)" />
</xsl:if>
<xsl:if test="incident:Leveraged_TTPs/incident:Leveraged_TTP">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Leveraged_TTPs/incident:Leveraged_TTP" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Leveraged TTPs', $contents)" />
</xsl:if>
<xsl:if test="incident:Attributed_Threat_Actors/incident:Threat_Actor">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Attributed_Threat_Actors/incident:Threat_Actor" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Attributed Threat Actors', $contents)" />
</xsl:if>
<xsl:if test="incident:Intended_Effect">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Intended_Effect" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Intended Effect', $contents)" />
</xsl:if>
<xsl:if test="incident:Security_Compromise">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Security_Compromise" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Security Compromise', $contents)" />
</xsl:if>
<xsl:if test="incident:Discovery_Method">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Discovery_Method" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Discovery Method', $contents)" />
</xsl:if>
<xsl:if test="incident:Related_Incidents/*">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Related_Incidents" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Related Incidents', $contents)" />
</xsl:if>
<xsl:if test="incident:COA_Requested">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:COA_Requested" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('COA Requested', $contents)" />
</xsl:if>
<xsl:if test="incident:COA_Taken">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:COA_Taken" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('COA Taken', $contents)" />
</xsl:if>
<xsl:if test="incident:Confidence">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Confidence" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Confidence', $contents)" />
</xsl:if>
<xsl:if test="incident:Contact">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Contact" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Contact', $contents)" />
</xsl:if>
<xsl:if test="incident:History">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:History" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('History', $contents)" />
</xsl:if>
<xsl:if test="incident:Handling">
<xsl:variable name="contents">
<xsl:apply-templates select="incident:Handling" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Handling', $contents)" />
</xsl:if>
</div>
</xsl:template>
<xsl:template match="cybox:Observable[not(@id) and not(@idref)]|stixCommon:Observable[not(@id) and not(@idref)]">
<xsl:call-template name="processObservableContents"/>
</xsl:template>
<xsl:template match="incident:Related_Observable">
<div>
<xsl:call-template name="processObservableContents" />
</div>
</xsl:template>
<xsl:template match="incident:Leveraged_TTP">
<div>
<xsl:apply-templates select="stixCommon:TTP" />
</div>
</xsl:template>
<!--
The process*Contents templates are used to convert the top level catgory "items" into html.
This one processes threat actors.
-->
<xsl:template name="processThreatActorContents">
<div>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<!--
<xsl:attribute name="class">
<xsl:if test="@id">container baseobj</xsl:if>
</xsl:attribute>
-->
<xsl:if test="ta:Identity">
<xsl:variable name="contents">
<xsl:apply-templates select="ta:Identity" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Identity', $contents)" />
</xsl:if>
<xsl:if test="ta:Type">
<xsl:variable name="contents">
<xsl:apply-templates select="ta:Type" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Types', $contents)" />
</xsl:if>
<xsl:if test="ta:Motivation">
<xsl:variable name="contents">
<xsl:apply-templates select="ta:Motivation" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Motivations', $contents)" />
</xsl:if>
<xsl:if test="ta:Intended_Effect">
<xsl:variable name="contents">
<xsl:apply-templates select="ta:Intended_Effect" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Intended Effect', $contents)" />
</xsl:if>
<xsl:if test="ta:Planning_And_Operational_Support">
<xsl:variable name="contents">
<xsl:apply-templates select="ta:Planning_And_Operational_Support" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Planning And Operational Support', $contents)" />
</xsl:if>
<xsl:if test="ta:Observed_TTPs/ta:Observed_TTP">
<xsl:variable name="contents">
<xsl:apply-templates select="ta:Observed_TTPs/ta:Observed_TTP" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Observed TTPs', $contents)" />
</xsl:if>
<xsl:if test="ta:Associated_Campaigns/ta:Associated_Campaign">
<xsl:variable name="contents">
<xsl:apply-templates select="ta:Associated_Campaigns/ta:Associated_Campaign" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Associated Campaigns', $contents)" />
</xsl:if>
<xsl:if test="ta:Associated_Actors/ta:Associated_Actor/stixCommon:Threat_Actor">
<xsl:variable name="contents">
<xsl:apply-templates select="ta:Associated_Actors/ta:Associated_Actor/stixCommon:Threat_Actor" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Associated Actors', $contents)" />
</xsl:if>
<xsl:if test="ta:Handling">
<xsl:variable name="contents">
<xsl:apply-templates select="ta:Handling" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Handling', $contents)" />
</xsl:if>
<xsl:if test="ta:Confidence">
<xsl:variable name="contents">
<xsl:apply-templates select="ta:Confidence" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Confidence', $contents)" />
</xsl:if>
<xsl:if test="ta:Information_Source">
<xsl:variable name="contents">
<xsl:apply-templates select="ta:Information_Source" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Information Source', $contents)" />
</xsl:if>
</div>
</xsl:template>
<xsl:template match="ta:Observed_TTP">
<div>
<xsl:apply-templates select="stixCommon:TTP" />
</div>
</xsl:template>
<!--
The process*Contents templates are used to convert the top level catgory "items" into html.
This one processes exploit targets.
-->
<xsl:template name="processExploitTargetContents">
<div>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<!--
<xsl:attribute name="class">
<xsl:if test="@id">container baseobj</xsl:if>
</xsl:attribute>
-->
<xsl:if test="et:Vulnerability">
<xsl:variable name="contents">
<xsl:apply-templates select="et:Vulnerability" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Vulnerabilities', $contents)" />
</xsl:if>
<xsl:if test="et:Weakness">
<xsl:variable name="contents">
<xsl:apply-templates select="et:Weakness" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Weakness', $contents)" />
</xsl:if>
<xsl:if test="et:Configuration">
<xsl:variable name="contents">
<xsl:apply-templates select="et:Configuration" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Configuration', $contents)" />
</xsl:if>
<xsl:if test="et:Potential_COAs">
<xsl:variable name="contents">
<xsl:apply-templates select="et:Potential_COAs" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Potential COAs', $contents)" />
</xsl:if>
<xsl:if test="et:Information_Source">
<xsl:variable name="contents">
<xsl:apply-templates select="et:Information_Source" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Information Source', $contents)" />
</xsl:if>
<xsl:if test="et:Handling">
<xsl:variable name="contents">
<xsl:apply-templates select="et:Handling" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Handling', $contents)" />
</xsl:if>
<xsl:if test="et:Related_Exploit_Targets">
<xsl:variable name="contents">
<xsl:apply-templates select="et:Related_Exploit_Targets" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Related Expooit Targets', $contents)" />
</xsl:if>
</div>
</xsl:template>
<!--
The process*Contents templates are used to convert the top level catgory "items" into html.
This one processes indicator.
-->
<xsl:template name="processIndicatorContents">
<div>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<!-- set empty class for non-composition observables -->
<!-- <span style="color: red; background-color: yellow;">INDICATOR CONTENTS HERE</span> -->
<!--
<xsl:attribute name="class">
<xsl:if test="not(indicator:Composite_Indicator_Expression)">baseindicator </xsl:if>
<xsl:if test="@id">container baseobj</xsl:if>
</xsl:attribute>
-->
<xsl:if test="indicator:Description">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Description" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Description', $contents)" />
</xsl:if>
<xsl:if test="indicator:Valid_Time_Position">
<xsl:copy-of select="stix:printNameValueTable('Valid Time Position', fn:concat('(', indicator:Valid_Time_Position/indicator:Start_Time/text(), ' to ', indicator:Valid_Time_Position/indicator:End_Time/text(), ')'))" />
</xsl:if>
<xsl:if test="indicator:Alternative_ID">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Alternative_ID" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Alternative ID', $contents)" />
</xsl:if>
<xsl:if test="indicator:Observable">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Observable/@*" mode="cyboxProperties" />
<xsl:apply-templates select="indicator:Observable/*" mode="cyboxProperties" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Observable', $contents)" />
</xsl:if>
<xsl:if test="indicator:Composite_Indicator_Expression">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Composite_Indicator_Expression" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Indicator Composition', $contents)" />
</xsl:if>
<xsl:if test="indicator:Indicated_TTP">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Indicated_TTP" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Indicated TTP', $contents)" />
</xsl:if>
<xsl:if test="indicator:Kill_Chain_Phases">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Kill_Chain_Phases" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Kill Chain Phases', $contents)" />
</xsl:if>
<xsl:if test="indicator:Confidence">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Confidence" mode="cyboxProperties" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Confidence', $contents)" />
</xsl:if>
<xsl:if test="indicator:Sightings/indicator:Sighting">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Sightings" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Sightings', $contents)" />
</xsl:if>
<xsl:if test="indicator:Test_Mechanisms">
<xsl:variable name="contents">
<xsl:apply-templates select="Test_Mechanisms" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Test Mechanisms', $contents)" />
</xsl:if>
<xsl:if test="indicator:Likely_Impact">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Likely_Impact" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Likely Impact', $contents)" />
</xsl:if>
<xsl:if test="indicator:Suggested_COAs">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Suggested_COAs" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Suggested COAs', $contents)" />
</xsl:if>
<xsl:if test="indicator:Handling">
<xsl:variable name="contents">
<div>name: <xsl:value-of select="local-name(.)"/></div>
<xsl:apply-templates select="indicator:Handling" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Handling', $contents)" />
</xsl:if>
<xsl:if test="indicator:Related_Indicators">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Related_Indicators" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Related Indicators', $contents)" />
</xsl:if>
<xsl:if test="indicator:Related_Campaigns">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Related_Campaigns" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Related Campaigns', $contents)" />
</xsl:if>
<xsl:if test="indicator:Producer">
<xsl:variable name="contents">
<xsl:apply-templates select="indicator:Producer" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Producer', $contents)" />
</xsl:if>
</div>
</xsl:template>
<!--
This template produces the table displaying composite indicator expressions.
This is similar to how the composite observables are produced.
-->
<xsl:template match="indicator:Composite_Indicator_Expression">
<table class="compositionTableOperator">
<colgroup>
<xsl:choose>
<xsl:when test="@operator='AND'">
<col class="oce-first-obscomp-and"/>
</xsl:when>
<xsl:when test="@operator='OR'">
<col class="oce-first-obscomp-or"/>
</xsl:when>
</xsl:choose>
</colgroup>
<tbody>
<tr>
<th>
<xsl:attribute name="rowspan"><xsl:value-of select="count(cybox:Observable)"/></xsl:attribute>
<span><xsl:value-of select="@operator"/></span>
</th>
<td>
<table class="compositionTableOperand">
<xsl:for-each select="indicator:Indicator">
<tr>
<td>
<xsl:apply-templates select="." mode="composition" />
</td>
</tr>
</xsl:for-each>
<tr>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</xsl:template>
<!--
This template display the simple indicator within a composite indicator
expression (one of the operands).
-->
<xsl:template match="indicator:Indicator" mode="composition">
<xsl:if test="@idref">
<div class="foreignObservablePointer">
<xsl:variable name="targetId" select="string(@idref)"/>
<xsl:variable name="relationshipOrAssociationType" select="''" />
<!-- (indicator within composition - - idref: <xsl:value-of select="fn:data(@idref)"/>) -->
<xsl:call-template name="headerAndExpandableContent">
<xsl:with-param name="targetId" select="$targetId"/>
<xsl:with-param name="isComposition" select="fn:true()"/>
<xsl:with-param name="relationshipOrAssociationType" select="''" />
</xsl:call-template>
</div>
</xsl:if>
<xsl:for-each select="cybox:Observable_Composition|indicator:Composite_Indicator_Expression">
<xsl:apply-templates select="." mode="#default" />
</xsl:for-each>
</xsl:template>
<!--
This template display an observable contained within an indicator.
-->
<xsl:template match="indicator:Observable">
<xsl:choose>
<xsl:when test="@id">
<xsl:call-template name="processObservableInline" />
</xsl:when>
<xsl:when test="@idref">
<xsl:call-template name="processObservableInObservableCompositionSimple" />
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="indicator:Indicated_TTP">
<div>
<!-- <div>(indicator Indicated TTP)</div> -->
<div>
<xsl:apply-templates/>
</div>
</div>
</xsl:template>
<xsl:template match="indicator:Kill_Chain_Phases">
<div>
<!-- <div>Kill Chain Phases</div> -->
<div>
<xsl:apply-templates />
</div>
</div>
</xsl:template>
<!--
This template makes sure that TTP elements that have neither an id nor
an idref are printed out inline.
-->
<xsl:template match="stixCommon:TTP[not(@id) and not(@idref)]|stix:TTP[not(@id) and not(@idref)]">
<xsl:call-template name="processTTPContents" />
</xsl:template>
<!--
The process*Contents templates are used to convert the top level catgory "items" into html.
This one processes TTPs.
-->
<xsl:template name="processTTPContents">
<div>
<div>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<!-- set empty class for non-composition observables -->
<!-- <span style="color: red; background-color: yellow;">INDICATOR CONTENTS HERE</span> -->
<!--
<xsl:attribute name="class">
<!- - <xsl:if test="not(indicator:Composite_Indicator_Expression)">baseindicator </xsl:if> - ->
<xsl:if test="@id">container baseobj</xsl:if>
</xsl:attribute>
-->
<xsl:if test="ttp:Description">
<xsl:variable name="contents">
<xsl:apply-templates select="ttp:Description" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Description', $contents)" />
</xsl:if>
<xsl:if test="ttp:Behavior">
<xsl:variable name="contents">
<xsl:apply-templates select="ttp:Behavior/*" mode="cyboxProperties" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Behavior', $contents)" />
</xsl:if>
<xsl:if test="ttp:Resources">
<xsl:variable name="contents">
<xsl:apply-templates select="ttp:Resources/*" mode="cyboxProperties" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Resources', $contents)" />
</xsl:if>
<xsl:if test="ttp:Victim_Targeting">
<xsl:variable name="contents">
<xsl:apply-templates select="ttp:Victim_Targeting/*" mode="cyboxProperties" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Victim Targeting', $contents)" />
</xsl:if>
<xsl:if test="ttp:Exploit_Targets">
<xsl:variable name="contents">
<xsl:apply-templates select="ttp:Exploit_Targets" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Exploit Targets', $contents)" />
</xsl:if>
<xsl:if test="ttp:Related_TTPs/ttp:Related_TTP">
<xsl:variable name="contents">
<xsl:apply-templates select="ttp:Related_TTPs/ttp:Related_TTP" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Related TTPs', $contents)" />
</xsl:if>
<xsl:if test="ttp:Kill_Chain_Phases/stixCommon:Kill_Chain_Phase">
<xsl:variable name="contents">
<xsl:apply-templates select="ttp:Kill_Chain_Phases" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Kill Chain Phases', $contents)" />
</xsl:if>
<xsl:if test="ttp:Information_Source">
<xsl:variable name="contents">
<xsl:apply-templates select="ttp:Information_Source/*" mode="cyboxProperties" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Information Source', $contents)" />
</xsl:if>
<xsl:if test="ttp:Handling">
<xsl:variable name="contents">
<xsl:apply-templates select="ttp:Handling/*" mode="cyboxProperties" />
</xsl:variable>
<xsl:copy-of select="stix:printNameValueTable('Handling', $contents)" />
</xsl:if>
</div>
</div>
</xsl:template>
<xsl:template match="ttp:Exploit_Target">
<div class="container containerTtpExploitTarget">
<div><xsl:apply-templates select="stixCommon:Relationship" /></div>