Code Improvement
[clamp.git] / src / main / resources / xsl / clds-bpmn-transformer.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3   ============LICENSE_START=======================================================
4   ONAP CLAMP
5   ================================================================================
6   Copyright (C) 2017 AT&T Intellectual Property. All rights
7                               reserved.
8   ================================================================================
9   Licensed under the Apache License, Version 2.0 (the "License"); 
10   you may not use this file except in compliance with the License. 
11   You may obtain a copy of the License at
12   
13   http://www.apache.org/licenses/LICENSE-2.0
14   
15   Unless required by applicable law or agreed to in writing, software 
16   distributed under the License is distributed on an "AS IS" BASIS, 
17   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
18   See the License for the specific language governing permissions and 
19   limitations under the License.
20   ============LICENSE_END============================================
21   ===================================================================
22   ECOMP is a trademark and service mark of AT&T Intellectual Property.
23   -->
24
25 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
26         xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL">
27 <!--
28   ** clds-bpmn-transformer.xsl
29   -->
30
31     <xsl:output method="text" indent="no" omit-xml-declaration="yes" />
32     <xsl:strip-space elements="*"/>
33
34         <!-- by default copy all attributes and elements -->
35         <xsl:template match="/bpmn2:definitions/bpmn2:process">
36
37                 <xsl:text>{"policy":[</xsl:text>
38                 <xsl:for-each select="bpmn2:policy" >
39                         <xsl:call-template name="network-element" />
40                 </xsl:for-each>
41                 <xsl:text>],</xsl:text>
42                 
43                 <xsl:text>"tca":[</xsl:text>
44                 <xsl:for-each select="bpmn2:tCA" >
45                         <xsl:call-template name="network-element" />
46                 </xsl:for-each>
47                 <xsl:text>],</xsl:text>
48                 
49                 <xsl:text>"holmes":[</xsl:text>
50                 <xsl:for-each select="bpmn2:holmes" >
51                         <xsl:call-template name="network-element" />
52                 </xsl:for-each>
53                 <xsl:text>],</xsl:text>
54
55                 <xsl:text>"vesCollector":[</xsl:text>
56                 <xsl:for-each select="bpmn2:vesCollector" >
57                         <xsl:call-template name="network-element" />
58                 </xsl:for-each>
59                 <xsl:text>]</xsl:text>
60                 
61                 <xsl:text>}</xsl:text>
62         </xsl:template>
63
64         <xsl:template name="network-element">
65                 <xsl:variable name="incoming" select="./bpmn2:incoming"/>
66
67                 <xsl:text>{"id":"</xsl:text>
68                 <xsl:value-of select="./@id"/>
69                 <xsl:text>", "from":"</xsl:text>
70                 <xsl:value-of select="../bpmn2:sequenceFlow[@id=$incoming]/@sourceRef"/>
71                 <xsl:text>"}</xsl:text>
72                 <xsl:if test="not(position()=last())">, </xsl:if>
73         </xsl:template>
74
75 </xsl:stylesheet>