-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConfig2RDF.xsl
77 lines (77 loc) · 3.33 KB
/
Config2RDF.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:my="http://www.okada.jp.org/schema/config2rdf#"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:val="http://www.opencdisc.org/schema/validator"
xmlns:odm="http://www.cdisc.org/ns/odm/v1.3"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output method="xml" encoding="UTF-8" />
<xsl:template match="/">
<xsl:element name="rdf:RDF">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="odm:ODM/odm:Study/odm:MetaDataVersion">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="odm:ItemGroupDef">
<xsl:text>
</xsl:text>
<xsl:element name="my:Domain">
<xsl:attribute name="rdf:ID">domain_<xsl:value-of select="@Name"/></xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="val:ValidationRuleRef">
<xsl:if test="@Active='Yes'">
<xsl:text>
</xsl:text>
<xsl:element name="my:hasRule">
<xsl:attribute name="rdf:datatype">http://www.w3.org/2001/XMLSchema#string</xsl:attribute>
<xsl:value-of select="@RuleID"/>
</xsl:element>
</xsl:if>
</xsl:template>
<xsl:template match="val:ValidationRules/val:*">
<xsl:text>
</xsl:text>
<xsl:element name="my:Rule">
<xsl:attribute name="rdf:ID">rule_<xsl:value-of select="@ID"/></xsl:attribute>
<xsl:text>
</xsl:text>
<xsl:if test="contains(@Variable,'%Domain%')">
<xsl:variable name="vname" select="substring-after(@Variable, '%Domain%')"/>
<xsl:for-each select="//odm:ItemGroupDef/@Name">
<xsl:element name="my:target">
<xsl:attribute name="rdf:datatype">http://www.w3.org/2001/XMLSchema#string</xsl:attribute>
<xsl:value-of select="concat(.,$vname)"/>
</xsl:element>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:if>
<xsl:if test="not(contains(@Variable,'%Domain%'))">
<xsl:element name="my:target">
<xsl:attribute name="rdf:datatype">http://www.w3.org/2001/XMLSchema#string</xsl:attribute>
<xsl:value-of select="@Variable"/>
</xsl:element>
</xsl:if>
<xsl:text>
</xsl:text>
<xsl:element name="my:description">
<xsl:attribute name="rdf:datatype">http://www.w3.org/2001/XMLSchema#string</xsl:attribute>
<xsl:value-of select="@Description"/>
</xsl:element>
<xsl:text>
</xsl:text>
<xsl:element name="my:message">
<xsl:attribute name="rdf:datatype">http://www.w3.org/2001/XMLSchema#string</xsl:attribute>
<xsl:value-of select="@Message"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>