blob: b722a11d9e36b172828db39e3199e19bbb6effb6 [file] [log] [blame]
Guillaume Nodet09157a92010-03-10 17:40:45 +00001<?xml version="1.0" encoding="UTF-8"?>
2<!--
3
4 Licensed to the Apache Software Foundation (ASF) under one or more
5 contributor license agreements. See the NOTICE file distributed with
6 this work for additional information regarding copyright ownership.
7 The ASF licenses this file to You under the Apache License, Version 2.0
8 (the "License"); you may not use this file except in compliance with
9 the License. You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19-->
20<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0">
21 <xsl:param name="nsh_interface" select="''"/>
22 <xsl:param name="nsh_namespace" select="''"/>
23 <xsl:output method="text" />
24
25 <xsl:template match="/">
26
27
28 <xsl:text>Import-Package:org.osgi.service.blueprint;version="[1.0.0,2.0.0)"
29 </xsl:text>
30
31 <xsl:if test="not($nsh_interface = '' or $nsh_namespace = '')">
32 <xsl:for-each select="descendant-or-self::node() | descendant-or-self::node()/attribute::*">
Guillaume Nodet57a8d812010-03-11 08:25:49 +000033 <xsl:if test="not(namespace-uri() = 'http://www.osgi.org/xmlns/blueprint/v1.0.0'
34 or namespace-uri() = 'http://www.w3.org/2001/XMLSchema-instance'
35 or namespace-uri() = '')">
Guillaume Nodetc24508d2010-03-11 12:38:58 +000036 <xsl:value-of select="concat('Import-Service:', $nsh_interface, ';filter=&quot;(', $nsh_namespace, '=', namespace-uri(), ')&quot;')" />
Guillaume Nodet09157a92010-03-10 17:40:45 +000037 <xsl:text>
38 </xsl:text>
39 </xsl:if>
40 </xsl:for-each>
41 </xsl:if>
42
43 <xsl:for-each select="
44 //bp:bean/@class
45 | //bp:service/@interface
46 | //bp:service/bp:interfaces/bp:value/text()
47 | //bp:reference/@interface
48 | //bp:reference-list/@interface
49 ">
50 <xsl:value-of select="concat('Import-Class:', .)" />
51 <xsl:text>
52 </xsl:text>
53 </xsl:for-each>
54
55 <xsl:for-each select="
56 //bp:bean/bp:argument/@type
57 | //bp:list/@value-type
58 | //bp:set/@value-type
59 | //bp:array/@value-type
60 | //bp:map/@key-type
61 | //bp:map/@value-type
62 ">
63 <xsl:choose>
64 <xsl:when test="contains(., '[')"><xsl:value-of select="concat('Import-Class:', substring-before(., '['))"/></xsl:when>
65 <xsl:otherwise><xsl:value-of select="concat('Import-Class:', .)"/></xsl:otherwise>
66 </xsl:choose>
67 <xsl:text>
68 </xsl:text>
69 </xsl:for-each>
70
Guillaume Nodet7bf509f2014-05-19 07:12:48 +000071 <xsl:for-each select="//bp:service[@interface or bp:interfaces/bp:value]">
Guillaume Nodet09157a92010-03-10 17:40:45 +000072 <xsl:choose>
73 <xsl:when test="@interface">
74 <xsl:value-of select="concat('Export-Service:', @interface)" />
75 </xsl:when>
76 <xsl:otherwise>
77 <xsl:choose>
78 <xsl:when test="bp:interfaces/bp:value/text()">
Guillaume Nodet7bf509f2014-05-19 07:12:48 +000079 <xsl:value-of select="'Export-Service:'" />
80 <xsl:for-each select="bp:interfaces/bp:value/text()">
81 <xsl:value-of select="."/>
82 <xsl:if test="position() != last()">
83 <xsl:value-of select="';'" />
84 </xsl:if>
85 </xsl:for-each>
Guillaume Nodet09157a92010-03-10 17:40:45 +000086 </xsl:when>
87 </xsl:choose>
88 </xsl:otherwise>
89 </xsl:choose>
90 <xsl:for-each select="bp:service-properties/bp:entry">
Guillaume Nodetda4289b2014-06-17 07:55:31 +000091 <xsl:choose>
92 <xsl:when test="@value">
93 <xsl:value-of select="concat(';', @key, '=&quot;', @value, '&quot;')" />
94 </xsl:when>
95 <xsl:when test="(bp:list|bp:array|bp:set)/bp:value/text()">
96 <xsl:value-of select="concat(';', @key, ':List&lt;String>=&quot;')" />
97 <xsl:for-each select="(bp:list|bp:array|bp:set)/bp:value/text()">
98 <xsl:value-of select="."/>
99 <xsl:if test="position() != last()">
100 <xsl:value-of select="','" />
101 </xsl:if>
102 </xsl:for-each>
103 <xsl:value-of select="'&quot;'" />
104 </xsl:when>
105 </xsl:choose>
Guillaume Nodet09157a92010-03-10 17:40:45 +0000106 </xsl:for-each>
107 <xsl:text>
108 </xsl:text>
109 </xsl:for-each>
110
Guillaume Nodetaa1eb1f2011-03-18 13:13:28 +0000111 <xsl:for-each select="//bp:reference[@interface]">
112 <xsl:value-of select="concat('Import-Service:', @interface, ';multiple:=false')" />
Guillaume Nodet09157a92010-03-10 17:40:45 +0000113 <xsl:choose>
114 <xsl:when test="@availability">
Guillaume Nodetc24508d2010-03-11 12:38:58 +0000115 <xsl:value-of select="concat(';availability:=', @availability)"/>
Guillaume Nodet09157a92010-03-10 17:40:45 +0000116 </xsl:when>
117 <xsl:otherwise>
118 <xsl:choose>
119 <xsl:when test="/bp:blueprint/@default-availability">
Guillaume Nodetc24508d2010-03-11 12:38:58 +0000120 <xsl:value-of select="concat(';availability:=', /bp:blueprint/@default-availability)"/>
Guillaume Nodet09157a92010-03-10 17:40:45 +0000121 </xsl:when>
Guillaume Nodetc24508d2010-03-11 12:38:58 +0000122 </xsl:choose>
123 </xsl:otherwise>
124 </xsl:choose>
125 <xsl:choose>
126 <xsl:when test="@filter">
127 <xsl:choose>
128 <xsl:when test="@component-name">
129 <xsl:value-of select="concat(';filter=&quot;(&amp;', @filter, ')(osgi.service.blueprint.compname=', @component-name, ')&quot;')" />
130 </xsl:when>
Guillaume Nodet09157a92010-03-10 17:40:45 +0000131 <xsl:otherwise>
Guillaume Nodetc24508d2010-03-11 12:38:58 +0000132 <xsl:value-of select="concat(';filter=&quot;', @filter, '&quot;')" />
Guillaume Nodet09157a92010-03-10 17:40:45 +0000133 </xsl:otherwise>
134 </xsl:choose>
Guillaume Nodetc24508d2010-03-11 12:38:58 +0000135 </xsl:when>
136 <xsl:otherwise>
137 <xsl:choose>
138 <xsl:when test="@component-name">
139 <xsl:value-of select="concat(';filter=&quot;(osgi.service.blueprint.compname=', @component-name, ')&quot;')" />
140 </xsl:when>
141 </xsl:choose>
Guillaume Nodet09157a92010-03-10 17:40:45 +0000142 </xsl:otherwise>
143 </xsl:choose>
144 <xsl:text>
145 </xsl:text>
146 </xsl:for-each>
147
Guillaume Nodetaa1eb1f2011-03-18 13:13:28 +0000148 <xsl:for-each select="//bp:reference-list[@interface]">
149 <xsl:value-of select="concat('Import-Service:', @interface, ';multiple:=true')"/>
150 <xsl:choose>
151 <xsl:when test="@availability">
152 <xsl:value-of select="concat(';availability:=', @availability)"/>
153 </xsl:when>
154 <xsl:otherwise>
155 <xsl:choose>
156 <xsl:when test="/bp:blueprint/@default-availability">
157 <xsl:value-of select="concat(';availability:=', /bp:blueprint/@default-availability)"/>
158 </xsl:when>
159 </xsl:choose>
160 </xsl:otherwise>
161 </xsl:choose>
162 <xsl:choose>
163 <xsl:when test="@filter">
164 <xsl:choose>
165 <xsl:when test="@component-name">
166 <xsl:value-of select="concat(';filter=&quot;(&amp;', @filter, ')(osgi.service.blueprint.compname=', @component-name, ')&quot;')" />
167 </xsl:when>
168 <xsl:otherwise>
169 <xsl:value-of select="concat(';filter=&quot;', @filter, '&quot;')" />
170 </xsl:otherwise>
171 </xsl:choose>
172 </xsl:when>
173 <xsl:otherwise>
174 <xsl:choose>
175 <xsl:when test="@component-name">
176 <xsl:value-of select="concat(';filter=&quot;(osgi.service.blueprint.compname=', @component-name, ')&quot;')" />
177 </xsl:when>
178 </xsl:choose>
179 </xsl:otherwise>
180 </xsl:choose>
181 <xsl:text>
182 </xsl:text>
183 </xsl:for-each>
184
185 </xsl:template>
Guillaume Nodet09157a92010-03-10 17:40:45 +0000186
187</xsl:stylesheet>
188