Guillaume Nodet | 09157a9 | 2010-03-10 17:40:45 +0000 | [diff] [blame] | 1 | <?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 Nodet | 57a8d81 | 2010-03-11 08:25:49 +0000 | [diff] [blame] | 33 | <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 Nodet | c24508d | 2010-03-11 12:38:58 +0000 | [diff] [blame] | 36 | <xsl:value-of select="concat('Import-Service:', $nsh_interface, ';filter="(', $nsh_namespace, '=', namespace-uri(), ')"')" /> |
Guillaume Nodet | 09157a9 | 2010-03-10 17:40:45 +0000 | [diff] [blame] | 37 | <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 Nodet | 7bf509f | 2014-05-19 07:12:48 +0000 | [diff] [blame] | 71 | <xsl:for-each select="//bp:service[@interface or bp:interfaces/bp:value]"> |
Guillaume Nodet | 09157a9 | 2010-03-10 17:40:45 +0000 | [diff] [blame] | 72 | <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 Nodet | 7bf509f | 2014-05-19 07:12:48 +0000 | [diff] [blame] | 79 | <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 Nodet | 09157a9 | 2010-03-10 17:40:45 +0000 | [diff] [blame] | 86 | </xsl:when> |
| 87 | </xsl:choose> |
| 88 | </xsl:otherwise> |
| 89 | </xsl:choose> |
| 90 | <xsl:for-each select="bp:service-properties/bp:entry"> |
Guillaume Nodet | da4289b | 2014-06-17 07:55:31 +0000 | [diff] [blame] | 91 | <xsl:choose> |
| 92 | <xsl:when test="@value"> |
| 93 | <xsl:value-of select="concat(';', @key, '="', @value, '"')" /> |
| 94 | </xsl:when> |
| 95 | <xsl:when test="(bp:list|bp:array|bp:set)/bp:value/text()"> |
| 96 | <xsl:value-of select="concat(';', @key, ':List<String>="')" /> |
| 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="'"'" /> |
| 104 | </xsl:when> |
| 105 | </xsl:choose> |
Guillaume Nodet | 09157a9 | 2010-03-10 17:40:45 +0000 | [diff] [blame] | 106 | </xsl:for-each> |
| 107 | <xsl:text> |
| 108 | </xsl:text> |
| 109 | </xsl:for-each> |
| 110 | |
Guillaume Nodet | aa1eb1f | 2011-03-18 13:13:28 +0000 | [diff] [blame] | 111 | <xsl:for-each select="//bp:reference[@interface]"> |
| 112 | <xsl:value-of select="concat('Import-Service:', @interface, ';multiple:=false')" /> |
Guillaume Nodet | 09157a9 | 2010-03-10 17:40:45 +0000 | [diff] [blame] | 113 | <xsl:choose> |
| 114 | <xsl:when test="@availability"> |
Guillaume Nodet | c24508d | 2010-03-11 12:38:58 +0000 | [diff] [blame] | 115 | <xsl:value-of select="concat(';availability:=', @availability)"/> |
Guillaume Nodet | 09157a9 | 2010-03-10 17:40:45 +0000 | [diff] [blame] | 116 | </xsl:when> |
| 117 | <xsl:otherwise> |
| 118 | <xsl:choose> |
| 119 | <xsl:when test="/bp:blueprint/@default-availability"> |
Guillaume Nodet | c24508d | 2010-03-11 12:38:58 +0000 | [diff] [blame] | 120 | <xsl:value-of select="concat(';availability:=', /bp:blueprint/@default-availability)"/> |
Guillaume Nodet | 09157a9 | 2010-03-10 17:40:45 +0000 | [diff] [blame] | 121 | </xsl:when> |
Guillaume Nodet | c24508d | 2010-03-11 12:38:58 +0000 | [diff] [blame] | 122 | </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="(&', @filter, ')(osgi.service.blueprint.compname=', @component-name, ')"')" /> |
| 130 | </xsl:when> |
Guillaume Nodet | 09157a9 | 2010-03-10 17:40:45 +0000 | [diff] [blame] | 131 | <xsl:otherwise> |
Guillaume Nodet | c24508d | 2010-03-11 12:38:58 +0000 | [diff] [blame] | 132 | <xsl:value-of select="concat(';filter="', @filter, '"')" /> |
Guillaume Nodet | 09157a9 | 2010-03-10 17:40:45 +0000 | [diff] [blame] | 133 | </xsl:otherwise> |
| 134 | </xsl:choose> |
Guillaume Nodet | c24508d | 2010-03-11 12:38:58 +0000 | [diff] [blame] | 135 | </xsl:when> |
| 136 | <xsl:otherwise> |
| 137 | <xsl:choose> |
| 138 | <xsl:when test="@component-name"> |
| 139 | <xsl:value-of select="concat(';filter="(osgi.service.blueprint.compname=', @component-name, ')"')" /> |
| 140 | </xsl:when> |
| 141 | </xsl:choose> |
Guillaume Nodet | 09157a9 | 2010-03-10 17:40:45 +0000 | [diff] [blame] | 142 | </xsl:otherwise> |
| 143 | </xsl:choose> |
| 144 | <xsl:text> |
| 145 | </xsl:text> |
| 146 | </xsl:for-each> |
| 147 | |
Guillaume Nodet | aa1eb1f | 2011-03-18 13:13:28 +0000 | [diff] [blame] | 148 | <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="(&', @filter, ')(osgi.service.blueprint.compname=', @component-name, ')"')" /> |
| 167 | </xsl:when> |
| 168 | <xsl:otherwise> |
| 169 | <xsl:value-of select="concat(';filter="', @filter, '"')" /> |
| 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="(osgi.service.blueprint.compname=', @component-name, ')"')" /> |
| 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 Nodet | 09157a9 | 2010-03-10 17:40:45 +0000 | [diff] [blame] | 186 | |
| 187 | </xsl:stylesheet> |
| 188 | |