fixing a problem with empty/duplicated roles upon account creation
[cxgn-corelibs.git] / lib / MOBY / xsl / parseMobyMessage.xsl
blobde7f66763df25f602680d62e66d65e1578728eee
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:moby="http://www.biomoby.org/moby" version="1.0">
3 <xsl:output method="xml" encoding="iso-8859-1" indent="no" disable-output-escaping="no"/>
5 <xsl:template match="/">
6 <xsl:text>#XSL_LIPM_MOBYPARSER_MESSAGE#</xsl:text>
7 <xsl:text>
8 </xsl:text>
9 <xsl:apply-templates select="/moby:MOBY/moby:mobyContent/moby:serviceNotes"/>
10 <xsl:apply-templates select="/moby:MOBY/moby:mobyContent/moby:mobyData"/>
11 </xsl:template>
13 <xsl:template match="moby:serviceNotes">
14 <xsl:text>#XSL_LIPM_MOBYPARSER_SERVICENOTES#</xsl:text>
15 <xsl:value-of select="normalize-space(.)"/>
16 <xsl:text>#XSL_LIPM_MOBYPARSER_SERVICENOTES#</xsl:text>
17 <xsl:text>
18 </xsl:text>
19 </xsl:template>
21 <xsl:template match="moby:mobyData">
23 <xsl:text>#XSL_LIPM_MOBYPARSER_DATA_START#</xsl:text>
24 <xsl:text>
25 </xsl:text>
27 <!-- Retrieve QueryId -->
29 <xsl:value-of select="normalize-space(./@moby:queryID)"/>
30 <xsl:variable name="queryID1" select="normalize-space(./@moby:queryID)"/>
31 <xsl:variable name="queryID2" select="normalize-space(./@queryID)"/>
32 <xsl:text>#XSL_LIPM_MOBYPARSER_QUERYID#</xsl:text>
33 <xsl:if test="$queryID1 != ''">
34 <xsl:value-of select="$queryID1"/>
35 </xsl:if>
36 <xsl:if test="$queryID2 != ''">
37 <xsl:value-of select="$queryID2"/>
38 </xsl:if>
39 <xsl:text>#XSL_LIPM_MOBYPARSER_QUERYID#</xsl:text>
40 <xsl:text>
41 </xsl:text>
45 <xsl:for-each select="child::*">
46 <xsl:text>#XSL_LIPM_MOBYPARSER_ARTICLE_START#</xsl:text>
47 <xsl:text>
48 </xsl:text>
49 <xsl:variable name="articleName" select="normalize-space(./@moby:articleName)"/>
50 <xsl:choose>
51 <xsl:when test="$articleName = ''">
52 <xsl:text>#XSL_LIPM_MOBYPARSER_ARTICLENAME#</xsl:text>
53 <xsl:value-of select="normalize-space(./@articleName)"/>
54 <xsl:text>#XSL_LIPM_MOBYPARSER_ARTICLENAME#</xsl:text>
55 </xsl:when>
56 <xsl:otherwise>
57 <xsl:text>#XSL_LIPM_MOBYPARSER_ARTICLENAME#</xsl:text>
58 <xsl:value-of select="$articleName"/>
59 <xsl:text>#XSL_LIPM_MOBYPARSER_ARTICLENAME#</xsl:text>
60 </xsl:otherwise>
61 </xsl:choose>
63 <xsl:text>
64 </xsl:text>
65 <xsl:variable name="articleType" select="normalize-space(name(.))"/>
66 <xsl:text>#XSL_LIPM_MOBYPARSER_ARTICLETYPE#</xsl:text>
67 <xsl:value-of select="$articleType"/>
68 <xsl:text>#XSL_LIPM_MOBYPARSER_ARTICLETYPE#</xsl:text>
70 <xsl:text>
71 </xsl:text>
73 <xsl:choose>
74 <xsl:when test="$articleType = 'moby:Collection'">
75 <xsl:apply-templates select="."/>
76 </xsl:when>
77 <xsl:when test="$articleType = 'moby:Simple'">
78 <xsl:apply-templates select="."/>
79 </xsl:when>
80 <xsl:otherwise>
81 <xsl:apply-templates select="."/>
82 </xsl:otherwise>
83 </xsl:choose>
84 </xsl:for-each>
85 </xsl:template>
87 <!--
89 TEMPLATE COLLECTION
91 -->
94 <xsl:template match="moby:Collection">
95 <xsl:text>#XSL_LIPM_MOBYPARSER_COLLECTION_START#</xsl:text>
98 <xsl:for-each select="child::*">
100 <xsl:variable name="articleType" select="normalize-space(name(.))"/>
101 <xsl:if test="$articleType = 'moby:Simple'">
102 <xsl:apply-templates select="."/>
103 </xsl:if>
105 </xsl:for-each>
106 <xsl:text>#XSL_LIPM_MOBYPARSER_COLLECTION_END#</xsl:text>
107 </xsl:template>
110 <!--
112 TEMPLATE PARAMETER
116 <xsl:template match="moby:Parameter">
118 <xsl:variable name="paramname1" select="normalize-space(./@moby:articleName)"/>
119 <xsl:variable name="paramname2" select="normalize-space(./@articleName)"/>
121 <xsl:text>#XSL_LIPM_MOBYPARSER_SECONDARY_START#</xsl:text>
122 <xsl:if test="$paramname1 != ''">
123 <xsl:value-of select="$paramname1"/>
124 </xsl:if>
125 <xsl:if test="$paramname2 != ''">
126 <xsl:value-of select="$paramname2"/>
127 </xsl:if>
128 <!--<xsl:value-of select="normalize-space(./@moby:articleName)"/>-->
129 <xsl:text>#XSL_LIPM_MOBYPARSER_SECONDARY_SEP#</xsl:text>
130 <xsl:value-of select="normalize-space(./child::*)"/>
131 <xsl:text>#XSL_LIPM_MOBYPARSER_SECONDARY_END#</xsl:text>
132 </xsl:template>
134 <!--
136 TEMPLATE SIMPLE
140 <xsl:template match="moby:Simple">
141 <xsl:text>#XSL_LIPM_MOBYPARSER_SIMPLE_START#</xsl:text>
142 <xsl:text>
143 </xsl:text>
145 <xsl:for-each select="child::*">
146 <xsl:call-template name="objectClass"/>
147 </xsl:for-each>
149 <xsl:text>
150 </xsl:text>
152 </xsl:template>
155 <!--
157 TEMPLATE OBJECT
162 <xsl:template name="objectClass">
164 <!-- Retrieve Object Type -->
166 <xsl:variable name="objectType" select="normalize-space(name(.))"/>
167 <xsl:text>#XSL_LIPM_MOBYPARSER_OBJECTTYPE#</xsl:text>
168 <xsl:value-of select="$objectType"/>
169 <xsl:text>#XSL_LIPM_MOBYPARSER_OBJECTTYPE#</xsl:text>
171 <xsl:text>
172 </xsl:text>
175 <!-- Retrieve Object Namespace-->
177 <xsl:variable name="objectNamespace1" select="normalize-space(./@moby:namespace)"/>
178 <xsl:variable name="objectNamespace2" select="normalize-space(./@namespace)"/>
179 <xsl:text>#XSL_LIPM_MOBYPARSER_OBJECTNAMESPACE#</xsl:text>
180 <xsl:if test="$objectNamespace1 != ''">
181 <xsl:value-of select="$objectNamespace1"/>
182 </xsl:if>
183 <xsl:if test="$objectNamespace2 != ''">
184 <xsl:value-of select="$objectNamespace2"/>
185 </xsl:if>
186 <xsl:text>#XSL_LIPM_MOBYPARSER_OBJECTNAMESPACE#</xsl:text>
187 <xsl:text>
188 </xsl:text>
190 <!-- Retrieve Object Id -->
192 <xsl:variable name="objectId1" select="normalize-space(./@moby:id)"/>
193 <xsl:variable name="objectId2" select="normalize-space(./@id)"/>
194 <xsl:text>#XSL_LIPM_MOBYPARSER_OBJECTID#</xsl:text>
195 <xsl:if test="$objectId1 != ''">
196 <xsl:value-of select="$objectId1"/>
197 </xsl:if>
198 <xsl:if test="$objectId2 != ''">
199 <xsl:value-of select="$objectId2"/>
200 </xsl:if>
201 <xsl:text>#XSL_LIPM_MOBYPARSER_OBJECTID#</xsl:text>
202 <xsl:text>
203 </xsl:text>
205 <!-- Retrieve Object articleName -->
207 <xsl:variable name="objectName1" select="normalize-space(./@moby:articleName)"/>
208 <xsl:variable name="objectName2" select="normalize-space(./@articleName)"/>
209 <xsl:text>#XSL_LIPM_MOBYPARSER_OBJECTNAME#</xsl:text>
210 <xsl:if test="$objectName1 != ''">
211 <xsl:value-of select="$objectName1"/>
212 </xsl:if>
213 <xsl:if test="$objectName2 != ''">
214 <xsl:value-of select="$objectName2"/>
215 </xsl:if>
216 <xsl:text>#XSL_LIPM_MOBYPARSER_OBJECTNAME#</xsl:text>
217 <xsl:text>
218 </xsl:text>
221 <!-- Retrieve Object Content -->
223 <xsl:text>#XSL_LIPM_MOBYPARSER_OBJECTCONTENT#</xsl:text>
224 <xsl:value-of select="."/>
225 <xsl:text>#XSL_LIPM_MOBYPARSER_OBJECTCONTENT#</xsl:text>
226 <xsl:text>
227 </xsl:text>
229 <xsl:for-each select="./child::*">
230 <xsl:choose>
231 <xsl:when test="contains(name(.),'CrossReference')">
232 <xsl:call-template name="crossReference"/>
233 </xsl:when>
234 <xsl:when test="contains(name(.),'Xref')">
235 <xsl:call-template name="crossReference"/>
236 </xsl:when>
237 <xsl:otherwise>
238 <xsl:text>#XSL_LIPM_MOBYPARSER_OBJECTHASA_START#</xsl:text>
239 <xsl:text>
240 </xsl:text>
241 <xsl:call-template name="objectClass"/>
242 <xsl:text>#XSL_LIPM_MOBYPARSER_OBJECTHASA_END#</xsl:text>
243 </xsl:otherwise>
244 </xsl:choose>
245 </xsl:for-each>
247 </xsl:template>
251 <!--
253 TEMPLATE CROSS/X/REF
259 <xsl:template name="crossReference">
260 <xsl:for-each select="./child::*">
261 <xsl:variable name="crossrefObjectType" select="normalize-space(name(.))"/>
262 <xsl:variable name="crossrefObjectId1" select="normalize-space(./@moby:id)"/>
263 <xsl:variable name="crossrefObjectId2" select="normalize-space(./@id)"/>
264 <xsl:variable name="crossrefObjectNamespace1" select="normalize-space(./@moby:namespace)"/>
265 <xsl:variable name="crossrefObjectNamespace2" select="normalize-space(./@namespace)"/>
267 <xsl:text>#XSL_LIPM_MOBYPARSER_CROSSREF_START#</xsl:text>
268 <xsl:value-of select="$crossrefObjectType"/>
269 <xsl:text>#XSL_LIPM_MOBYPARSER_CROSSREF_SEP#</xsl:text>
270 <xsl:if test="$crossrefObjectId1 != ''"><xsl:value-of select="$crossrefObjectId1"/></xsl:if>
271 <xsl:if test="$crossrefObjectId2 != ''"><xsl:value-of select="$crossrefObjectId2"/></xsl:if>
272 <xsl:text>#XSL_LIPM_MOBYPARSER_CROSSREF_SEP#</xsl:text>
273 <xsl:if test="$crossrefObjectNamespace1 != ''"><xsl:value-of select="$crossrefObjectNamespace1"/></xsl:if>
274 <xsl:if test="$crossrefObjectNamespace2 != ''"><xsl:value-of select="$crossrefObjectNamespace2"/></xsl:if>
275 <xsl:text>#XSL_LIPM_MOBYPARSER_CROSSREF_END#</xsl:text>
276 <xsl:text>
277 </xsl:text>
278 </xsl:for-each>
280 </xsl:template>
282 </xsl:stylesheet>