1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <xsl:stylesheet version="1.0" |
---|
3 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:plm="http://www.plmxml.org/Schemas/PLMXMLSchema" |
---|
4 | xmlns:cim="http://www.coolemall.eu/DEBBComponent" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
---|
5 | |
---|
6 | <!-- Importing xslt for translating debb components --> |
---|
7 | <xsl:import href="DEBBComponentTranslator.xsl" /> |
---|
8 | |
---|
9 | <!-- Information for mapping of DEBB classes into DCWoRMS computingResource classes --> |
---|
10 | <xsl:param name="computingResourceClasses" select="computingResourceClasses"/> |
---|
11 | |
---|
12 | <!-- Information for mapping of resource classes into DCWoRMS resourceUnits classes --> |
---|
13 | <!-- (Needed to pass to DEBB Components xslt) --> |
---|
14 | <xsl:param name="resourceUnitClasses" select="resourceUnitClasses"/> |
---|
15 | |
---|
16 | <!-- Specification of the output document --> |
---|
17 | <xsl:output method="xml" version="1.0" encoding="UTF-8" |
---|
18 | indent="yes" /> |
---|
19 | |
---|
20 | <!-- Root of the PLM XML document --> |
---|
21 | <xsl:variable name="rootDoc" select="/" /> |
---|
22 | |
---|
23 | <!-- Default DEBBComponents file name (used if it is not specified in PLM |
---|
24 | XML file) --> |
---|
25 | <xsl:variable name="defaultDEBBComponentsFileName" select="'DEBBComponents.xml'" /> |
---|
26 | |
---|
27 | |
---|
28 | <xsl:template match="/"> |
---|
29 | <xsl:element name="environment"> |
---|
30 | <xsl:attribute name="xsi:noNamespaceSchemaLocation">DCWormsResSchema.xsd</xsl:attribute> |
---|
31 | <xsl:element name="resources"> |
---|
32 | <xsl:apply-templates select="//plm:InstanceGraph" /> |
---|
33 | <xsl:element name="scheduler"></xsl:element> |
---|
34 | </xsl:element> |
---|
35 | </xsl:element> |
---|
36 | </xsl:template> |
---|
37 | |
---|
38 | <xsl:template match="plm:InstanceGraph"> |
---|
39 | <!-- Finding root DEBB --> |
---|
40 | <xsl:variable name="rootRef" select="@rootRefs" /> |
---|
41 | <xsl:apply-templates select="plm:ProductInstance[@id=$rootRef]" /> |
---|
42 | </xsl:template> |
---|
43 | |
---|
44 | <xsl:template match="plm:ProductInstance"> |
---|
45 | <xsl:variable name="partRef" select="@partRef" /> |
---|
46 | <!-- Get rid of # at the beginning --> |
---|
47 | <xsl:variable name="productInstanceId" select="translate($partRef, '#', '')" /> |
---|
48 | |
---|
49 | <xsl:if test="not (starts-with(@name, 'Sensor'))"> |
---|
50 | <!-- We have to get rid of sensors, which make only problems here --> |
---|
51 | <xsl:element name="computingResource"> |
---|
52 | <xsl:attribute name="name"><xsl:value-of select="@name" /></xsl:attribute> |
---|
53 | |
---|
54 | <!-- Find corresponding ProductRevisionView and let it translate itself --> |
---|
55 | <xsl:apply-templates select="//plm:ProductRevisionView[@id=$productInstanceId]" /> |
---|
56 | |
---|
57 | <!-- Add hostnames, labels, locations, sequences, etc. --> |
---|
58 | <xsl:variable name="debbHostname" |
---|
59 | select="plm:UserData/plm:UserValue[@title='hostname']/@value" /> |
---|
60 | <xsl:if test="$debbHostname != ''"> |
---|
61 | <xsl:element name="parameter"> |
---|
62 | <xsl:attribute name="name">hostname</xsl:attribute> |
---|
63 | <xsl:element name="value"> |
---|
64 | <xsl:value-of select="$debbHostname" /> |
---|
65 | </xsl:element> |
---|
66 | </xsl:element> |
---|
67 | </xsl:if> |
---|
68 | <xsl:variable name="debbLabel" |
---|
69 | select="plm:UserData/plm:UserValue[@title='label']/@value" /> |
---|
70 | <xsl:if test="$debbLabel != ''"> |
---|
71 | <xsl:element name="parameter"> |
---|
72 | <xsl:attribute name="name">label</xsl:attribute> |
---|
73 | <xsl:element name="value"> |
---|
74 | <xsl:value-of select="$debbLabel" /> |
---|
75 | </xsl:element> |
---|
76 | </xsl:element> |
---|
77 | </xsl:if> |
---|
78 | <xsl:variable name="debbLocation" |
---|
79 | select="plm:UserData/plm:UserValue[@title='location']/@value" /> |
---|
80 | <xsl:if test="debbLocation != ''"> |
---|
81 | <xsl:element name="parameter"> |
---|
82 | <xsl:attribute name="name">location</xsl:attribute> |
---|
83 | <xsl:element name="value"> |
---|
84 | <xsl:value-of select="$debbLocation" /> |
---|
85 | </xsl:element> |
---|
86 | </xsl:element> |
---|
87 | </xsl:if> |
---|
88 | <xsl:variable name="debbSequence" |
---|
89 | select="plm:UserData/plm:UserValue[@title='sequence']/@value" /> |
---|
90 | <xsl:if test="$debbSequence != ''"> |
---|
91 | <xsl:element name="parameter"> |
---|
92 | <xsl:attribute name="name">sequence</xsl:attribute> |
---|
93 | <xsl:element name="value"> |
---|
94 | <xsl:value-of select="$debbSequence" /> |
---|
95 | </xsl:element> |
---|
96 | </xsl:element> |
---|
97 | </xsl:if> |
---|
98 | </xsl:element> |
---|
99 | </xsl:if> |
---|
100 | </xsl:template> |
---|
101 | |
---|
102 | <xsl:template match="plm:ProductRevisionView"> |
---|
103 | <!-- instanceRefs contain space separated ids of nested DEBBs --> |
---|
104 | <xsl:variable name="tokenizedText" select="tokenize(@instanceRefs, ' ')" /> |
---|
105 | |
---|
106 | <!-- DEBBLevel --> |
---|
107 | <xsl:variable name="debbLevel" |
---|
108 | select="plm:UserData/plm:UserValue[@title='DEBBLevel']/@value" /> |
---|
109 | <!-- DEBBComponentId --> |
---|
110 | <xsl:variable name="debbComponentId" |
---|
111 | select="plm:UserData/plm:UserValue[@title='DEBBComponentId']/@value" /> |
---|
112 | <!-- DEBBComponentFile --> |
---|
113 | <xsl:variable name="debbComponentFile" |
---|
114 | select="plm:UserData/plm:UserValue[@title='DEBBComponentFile']/@value" /> |
---|
115 | |
---|
116 | <xsl:attribute name="class"> |
---|
117 | <xsl:value-of select="$debbLevel" /> |
---|
118 | </xsl:attribute> |
---|
119 | |
---|
120 | <xsl:attribute name="type"> |
---|
121 | <xsl:value-of select="$debbComponentId" /> |
---|
122 | </xsl:attribute> |
---|
123 | |
---|
124 | <!-- Add DEBB information from DEBB Components file --> |
---|
125 | <xsl:choose> |
---|
126 | <!-- DEBB Components file is defined --> |
---|
127 | <xsl:when test="$debbComponentFile != ''"> |
---|
128 | <xsl:comment>DEBB Component file is <xsl:value-of select="$debbComponentFile"/></xsl:comment> |
---|
129 | <xsl:variable name="nestedDoc" select="document($debbComponentFile)" /> |
---|
130 | <xsl:apply-templates select="$nestedDoc//*[ComponentId=$debbComponentId]" /> |
---|
131 | </xsl:when> |
---|
132 | <!-- DEBB Components file is not defined. Use default one. --> |
---|
133 | <xsl:otherwise> |
---|
134 | <xsl:comment>DEBB Component file is <xsl:value-of select="$defaultDEBBComponentsFileName"/></xsl:comment> |
---|
135 | <xsl:variable name="nestedDoc" |
---|
136 | select="document($defaultDEBBComponentsFileName)" /> |
---|
137 | <xsl:apply-templates select="$nestedDoc//*[ComponentId=$debbComponentId]" > |
---|
138 | <xsl:with-param name="computingResourceClasses"> |
---|
139 | <xsl:value-of select="$computingResourceClasses"/> |
---|
140 | </xsl:with-param> |
---|
141 | <xsl:with-param name="resourceUnitClasses"> |
---|
142 | <xsl:value-of select="$resourceUnitClasses"/> |
---|
143 | </xsl:with-param> |
---|
144 | </xsl:apply-templates> |
---|
145 | </xsl:otherwise> |
---|
146 | </xsl:choose> |
---|
147 | |
---|
148 | <!-- Iterate children and ask them to translate themselves --> |
---|
149 | <xsl:for-each select="1 to count($tokenizedText)"> |
---|
150 | <xsl:variable name="index" select="." /> |
---|
151 | <xsl:apply-templates |
---|
152 | select="$rootDoc//plm:ProductInstance[@id=$tokenizedText[$index]]" /> |
---|
153 | </xsl:for-each> |
---|
154 | </xsl:template> |
---|
155 | </xsl:stylesheet> |
---|
156 | |
---|