-
Notifications
You must be signed in to change notification settings - Fork 0
/
reqif_redact.xslt
141 lines (125 loc) · 5.32 KB
/
reqif_redact.xslt
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
<!-- -*- mode: xml; -*- -->
<!-- img/edinburgh lab -->
<!-- redact reqif1.2 package -->
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:reqif-common="http://www.prostep.org/reqif"
xmlns:rm-reqif="http://www.ibm.com/rm/reqif"
xsi:schemaLocation="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd reqif.xsd"
xmlns:reqif="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:rm="http://www.ibm.com/rm"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<!-- set to true to obfuscate same-as URIs -->
<xsl:param name="process-sameas" select="true()" as="xs:boolean"/>
<xsl:output omit-xml-declaration="no" method="xml"/>
<xsl:key name="obfuscation" match="@LONG-NAME" use="."/>
<xsl:key name="other-content-obfuscation" match="//reqif:EMBEDDED-VALUE/@OTHER-CONTENT" use="."/>
<xsl:key name="value-obfuscation" match="@THE-VALUE|//rm:SAME-AS/text()" use="."/>
<xsl:template match="//reqif:REQ-IF-HEADER/reqif:TITLE">
<xsl:variable name="title" select="text()"/>
<xsl:copy>
<xsl:value-of select="concat($title, ' (redacted v0.1)')">
</xsl:value-of>
</xsl:copy>
</xsl:template>
<xsl:template match="@LONG-NAME[not(
. = ''
or . = 'String'
or . = 'Boolean'
or . = 'ReqIF.ForeignDeleted'
or . = 'ReqIF.ChapterName'
or . = 'ReqIF.Text'
or . = 'ReqIF.ForeignDeleted'
or . = 'Object Type'
)]">
<xsl:attribute name="LONG-NAME">
<xsl:value-of select="concat('redacted-', generate-id(key('obfuscation',.)[1]))"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="//reqif:EMBEDDED-VALUE/@OTHER-CONTENT[not(
. = ''
or . = 'Document'
or . = 'Glossary'
or . = 'Collection'
or . = 'Term'
or . = 'Text'
or . = 'Part'
or . = 'Sketch'
or . = 'ScreenFlow'
or . = 'Storyboard'
or . = 'BusinessProcessDiagram'
or . = 'SimpleFlowDiagram'
or . = 'UseCaseDiagram'
or . = 'WrapperResource'
or . = 'Module'
or . = 'Composite'
or . = 'Diagram'
)]">
<xsl:attribute name="OTHER-CONTENT">
<xsl:value-of select="concat('redacted-', generate-id(key('other-content-obfuscation',.)[1]))"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="*[not(self::reqif:ATTRIBUTE-VALUE-DATE)]/@THE-VALUE[not(. = '')]">
<xsl:attribute name="THE-VALUE">
<xsl:value-of select="concat('redacted-', generate-id(key('value-obfuscation',.)[1]))"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="//rm:SAME-AS">
<xsl:variable name="sameas" select="text()"/>
<xsl:copy>
<xsl:choose>
<xsl:when test="$process-sameas">
<xsl:value-of select="concat('http://redacted.example.con/', generate-id(key('value-obfuscation',.)[1]))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$sameas"/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
<xsl:template match="xhtml:div//text()">
<xsl:variable name="red" select="concat('redacted-text-', generate-id(.))"/>
<xsl:value-of select="$red"></xsl:value-of>
</xsl:template>
<xsl:template match="rm:ATTRIBUTE-VALUE-XHTML//text()">
<xsl:variable name="red" select="concat('redacted-text-', generate-id(.))"/>
<xsl:value-of select="$red"></xsl:value-of>
</xsl:template>
<!--
<xsl:template match="//reqif:ENUM-VALUE/@reqif:LONG-NAME">
<xsl:variable name="elementname" select="concat('REDACTED-',generate-id(.))"/>
<xsl:copy>
<xsl:value-of select="$elementname">
</xsl:value-of>
</xsl:copy>
</xsl:template>
-->
<xsl:template match="node()|@*" name="identity">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<!-- <xsl:template match="//rif:OTHER-CONTENT|//*[not(self::rif:DATATYPE-DEFINITION-INTEGER
or self::rif:DATATYPE-DEFINITION-DOCUMENT
or self::rif:DATATYPE-DEFINITION-DATE
or self::rif:ATTRIBUTE-DEFINITION-SIMPLE
)]
/rif:LONG-NAME[text() != 'Created Thru'
and text() != 'Last Modified On'
and text() != 'String'
and text() != 'Object Heading'
and text() != 'Object Short Text'
and text() != 'Absoulte Number'
and text() != 'Object Text']
|//rif-xhtml:div|//rif:THE-VALUE|//rif:DESC|//doors:VIEW-NAME|//doors:VIEW-DATA">
<xsl:variable name="elementname" select="concat('REDACTED-',generate-id(.))"/>
<xsl:copy>
<xsl:value-of select="$elementname">
</xsl:value-of>
</xsl:copy>
</xsl:template>
-->
</xsl:stylesheet>