post-process.xslt 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2013
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" exclude-result-prefixes="xsd xsi bus cm SOAP-ENV SOAP-ENC">
  13. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  14. <!-- global variables -->
  15. <xsl:variable name="xtscm" select="'http://developer.cognos.com/schemas/xts-cm/1/'"/>
  16. <xsl:variable name="xsd-prefix" select="'xsd'"/>
  17. <!-- main entry point -->
  18. <xsl:template match="/">
  19. <xsl:apply-templates/>
  20. </xsl:template>
  21. <!-- eat the soap header, if present -->
  22. <xsl:template match="SOAP-ENV:Header"/>
  23. <!-- process query, add, delete, update, move and copy responses -->
  24. <xsl:template match="bus:queryResponse|bus:addResponse|bus:deleteResponse|bus:updateResponse|bus:moveResponse|bus:copyResponse|bus:exportResponse|bus:importResponse|*[local-name()='listArchivesResponse']" priority="1">
  25. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  26. <xsl:apply-templates/>
  27. </xsl:element>
  28. </xsl:template>
  29. <!-- process the cm cache query -->
  30. <xsl:template match="bus:queryCacheResult" priority="1">
  31. <xsl:element name="queryResponse" namespace="{$xtscm}">
  32. <xsl:apply-templates/>
  33. </xsl:element>
  34. </xsl:template>
  35. <xsl:template match="*[local-name()='getDeploymentOptionsResponse']|*[local-name()='getArchiveOptionsResponse']" priority="1">
  36. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  37. <xsl:element name="deploymentOptions" namespace="{$xtscm}">
  38. <xsl:apply-templates/>
  39. </xsl:element>
  40. </xsl:element>
  41. </xsl:template>
  42. <xsl:template match="deploymentReport" priority="1">
  43. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  44. <xsl:element name="deploymentOptions" namespace="{$xtscm}">
  45. <xsl:apply-templates/>
  46. </xsl:element>
  47. </xsl:element>
  48. </xsl:template>
  49. <!-- history details-->
  50. <xsl:template match="detail" priority="1">
  51. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  52. <xsl:value-of select="value" disable-output-escaping="no"/>
  53. </xsl:element>
  54. </xsl:template>
  55. <xsl:template match="copyFault[fault]" priority="1">
  56. <xsl:copy-of select="."/>
  57. </xsl:template>
  58. <!-- handle the count for delete, update, move and copy -->
  59. <xsl:template match="count[@xsi:type='xsd:integer']" priority="1">
  60. <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
  61. </xsl:template>
  62. <!-- handle array type -->
  63. <xsl:template match="*[substring-after(@xsi:type, ':')='Array']" priority="2">
  64. <xsl:apply-templates/>
  65. </xsl:template>
  66. <!-- handle queryCacheResult type -->
  67. <xsl:template match="*[local-name()='result' and substring-after(@xsi:type, ':')='queryCacheResult']" priority="2">
  68. <xsl:apply-templates/>
  69. </xsl:template>
  70. <!-- transform an item in an array to its equivalent element -->
  71. <!-- Note: array elements are normally contained in <item>. Axis1.4 can create array elements with name identical to their array name -->
  72. <!-- See the ps unittest "postprocess" for more details on the syntax -->
  73. <xsl:template match="*[local-name()='item' or (substring-after(../@xsi:type, ':')='Array' and substring-after(@xsi:type, ':')!='Array' and local-name(.)=local-name(..))]" priority="1">
  74. <xsl:variable name="element-name">
  75. <xsl:choose>
  76. <xsl:when test="@xsi:type">
  77. <xsl:value-of select="substring-after(@xsi:type, ':')"/>
  78. </xsl:when>
  79. <xsl:otherwise>
  80. <xsl:value-of select="substring-before(substring-after(../@SOAP-ENC:arrayType, ':'), '[')"/>
  81. </xsl:otherwise>
  82. </xsl:choose>
  83. </xsl:variable>
  84. <xsl:element name="{$element-name}" namespace="{$xtscm}">
  85. <xsl:variable name="type" select="substring-before(substring-after(../@SOAP-ENC:arrayType, ':'),'[')"/>
  86. <xsl:choose>
  87. <!-- special case: if type is 'baseClass', add an element 'objectClass' -->
  88. <xsl:when test="$type='baseClass'">
  89. <xsl:variable name="object-class" select="substring-after(@xsi:type, ':')"/>
  90. <xsl:if test="$object-class!='baseClass'">
  91. <xsl:element name="objectClass" namespace="{$xtscm}">
  92. <xsl:value-of select="$object-class"/>
  93. </xsl:element>
  94. </xsl:if>
  95. <xsl:apply-templates/>
  96. </xsl:when>
  97. <!-- special case: multilingual token array -->
  98. <xsl:when test="$type='multilingualToken'">
  99. <xsl:attribute name="xml:lang"><xsl:value-of select="locale"/></xsl:attribute>
  100. <xsl:attribute name="type"><xsl:value-of select="@xsi:type"/></xsl:attribute>
  101. <xsl:apply-templates select="*[not(self::locale)]"/>
  102. </xsl:when>
  103. <!-- special case: multilingual string array -->
  104. <xsl:when test="$type='multilingualString'">
  105. <xsl:attribute name="xml:lang"><xsl:value-of select="locale"/></xsl:attribute>
  106. <xsl:attribute name="type"><xsl:value-of select="@xsi:type"/></xsl:attribute>
  107. <xsl:apply-templates select="*[not(self::locale)]"/>
  108. </xsl:when>
  109. <!-- special case: localeMap entry array -->
  110. <xsl:when test="$type='localeMapEntry'">
  111. <xsl:attribute name="xml:key"><xsl:value-of select="key"/></xsl:attribute>
  112. <xsl:attribute name="type"><xsl:value-of select="@xsi:type"/></xsl:attribute>
  113. <xsl:apply-templates select="*[not(self::key)]"/>
  114. </xsl:when>
  115. <!-- special case: retentionRule -->
  116. <xsl:when test="$type='retentionRule'">
  117. <xsl:call-template name="elements2attributes"/>
  118. </xsl:when>
  119. <!-- special case: gatewayMapping -->
  120. <xsl:when test="$type='gatewayMapping'">
  121. <xsl:call-template name="elements2attributes"/>
  122. </xsl:when>
  123. <!-- special case: packageDeploymentInfo -->
  124. <xsl:when test="$type='packageDeploymentInfo'">
  125. <xsl:for-each select="child::*">
  126. <xsl:choose>
  127. <xsl:when test="local-name() = 'sourceName' or local-name() = 'targetName'">
  128. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  129. <xsl:apply-templates/>
  130. </xsl:element>
  131. </xsl:when>
  132. <xsl:otherwise>
  133. <xsl:apply-templates select="."/>
  134. </xsl:otherwise>
  135. </xsl:choose>
  136. </xsl:for-each>
  137. </xsl:when>
  138. <!-- special case: deploymentOption DEPRECATED. Will be removed in next major release.-->
  139. <!-- only options on a deployment object should be matched. Other options items should never make it to this point -->
  140. <xsl:when test="$type='deploymentOption' or $type='option'">
  141. <xsl:call-template name="elements2attributes-value2node"/>
  142. </xsl:when>
  143. <!--simpleParmValueItem contains simple properties such as "display" and "use" elements that have single value. Also, inherited properties such as "inclusive".
  144. The routingHintObject (hints) contains simple item properties such as objectClass and value.
  145. Here is an example of format that is expected from CM for routing:
  146. <routingTable xsi:type="cm:routingTableEntryArrayProp">
  147. <value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="cm:routingTableEntry[1]">
  148. <item xsi:type="tns:routingTableEntry">
  149. <rule xsi:type="tns:routingRuleObject">
  150. <hints xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="routingHintObject[1]">
  151. <item xsi:type="tns:routingHintObject">
  152. <objectClass xsi:type="tns:classEnum">package</objectClass>
  153. <value xsi:type="xsd:string">GO Sales</value>
  154. </item>
  155. </hints>
  156. </rule>
  157. <serverGroupName xsi:type="xsd:string">sg1</serverGroupName>
  158. </item>
  159. </value>
  160. </routingTable>
  161. This will be transformed to this:
  162. <routingTableEntry>
  163. <rule type="tns:routingRuleObject">
  164. <routingHintObject>
  165. <objectClass>package</objectClass>
  166. <value>GO Sales</value>
  167. </routingHintObject>
  168. <routingHintObject>
  169. <objectClass>role</objectClass>
  170. <value>role1</value>
  171. </routingHintObject>
  172. </rule>
  173. <serverGroupName>sg1</serverGroupName>
  174. </routingTableEntry>
  175. -->
  176. <xsl:when test="$element-name = 'simpleParmValueItem' or $element-name='routingHintObject'">
  177. <xsl:for-each select="*">
  178. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  179. <xsl:if test="@xsi:nil != ''">
  180. <xsl:attribute name="nil"><xsl:value-of select="@xsi:nil"/></xsl:attribute>
  181. </xsl:if>
  182. <xsl:value-of select="."/>
  183. </xsl:element>
  184. </xsl:for-each>
  185. </xsl:when>
  186. <xsl:when test="$element-name='parameterAssignmentDataItem'">
  187. <parameterName>
  188. <xsl:value-of select="./parameterName"/>
  189. </parameterName>
  190. <dataItemName>
  191. <xsl:value-of select="./dataItemName"/>
  192. </dataItemName>
  193. </xsl:when>
  194. <xsl:when test="$element-name='parameterAssignmentExpression'">
  195. <parameterName>
  196. <xsl:value-of select="./parameterName"/>
  197. </parameterName>
  198. <expression>
  199. <xsl:value-of select="./expression"/>
  200. </expression>
  201. </xsl:when>
  202. <!-- handle everything else -->
  203. <xsl:otherwise>
  204. <xsl:apply-templates/>
  205. </xsl:otherwise>
  206. </xsl:choose>
  207. </xsl:element>
  208. </xsl:template>
  209. <!-- translate the schemaInfo element into attributes -->
  210. <xsl:template match="*[substring-after(@xsi:type, ':')='schemaInfo']" priority="1">
  211. <xsl:call-template name="elements2attributes"/>
  212. </xsl:template>
  213. <!-- process all xsi:type -->
  214. <xsl:template match="*[@xsi:type!='']" priority="0">
  215. <xsl:choose>
  216. <xsl:when test="starts-with(@xsi:type,concat($xsd-prefix,':'))">
  217. <!-- handle xsd:xxxxxx types -->
  218. <xsl:choose>
  219. <xsl:when test="local-name()='value'">
  220. <xsl:choose>
  221. <!-- if we're dealing with runOptions or options then we need the value element -->
  222. <xsl:when test="ancestor::*[local-name() = 'runOptions']">
  223. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  224. <xsl:apply-templates/>
  225. </xsl:element>
  226. </xsl:when>
  227. <!-- special case: we want only the content of xsd value -->
  228. <xsl:otherwise>
  229. <xsl:attribute name="type"><xsl:value-of select="../@xsi:type"/></xsl:attribute>
  230. <xsl:apply-templates/>
  231. </xsl:otherwise>
  232. </xsl:choose>
  233. </xsl:when>
  234. <!-- special case: permission/name -->
  235. <xsl:when test="local-name()='name' and substring-after(../@xsi:type, ':')='permission'">
  236. <xsl:attribute name="name"><xsl:value-of select="."/></xsl:attribute>
  237. </xsl:when>
  238. <xsl:otherwise>
  239. <!-- include the element and continue processing -->
  240. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  241. <xsl:apply-templates/>
  242. </xsl:element>
  243. </xsl:otherwise>
  244. </xsl:choose>
  245. </xsl:when>
  246. <xsl:otherwise>
  247. <xsl:variable name="localName" select="local-name()"/>
  248. <!-- handle cm:xxxxxx types -->
  249. <xsl:choose>
  250. <!-- special case: multilingualString -->
  251. <xsl:when test="$localName='value' and substring-after(@xsi:type, ':')='multilingualString'">
  252. <xsl:attribute name="xml:lang"><xsl:value-of select="locale"/></xsl:attribute>
  253. <xsl:attribute name="type"><xsl:value-of select="@xsi:type"/></xsl:attribute>
  254. <xsl:apply-templates select="*[not(self::locale)]"/>
  255. </xsl:when>
  256. <!-- special case: multilingualToken -->
  257. <xsl:when test="$localName='value' and substring-after(@xsi:type, ':')='multilingualToken'">
  258. <xsl:attribute name="xml:lang"><xsl:value-of select="locale"/></xsl:attribute>
  259. <xsl:attribute name="type"><xsl:value-of select="@xsi:type"/></xsl:attribute>
  260. <xsl:apply-templates select="*[not(self::locale)]"/>
  261. </xsl:when>
  262. <xsl:when test="$localName='value' and (substring-after(@xsi:type, ':')='baseReportActionEnum' or substring-after(@xsi:type, ':')='severityEnum' or substring-after(@xsi:type, ':')='powerPlayReportActionEnum')">
  263. <xsl:attribute name="type"><xsl:value-of select="../@xsi:type"/></xsl:attribute>
  264. <xsl:apply-templates/>
  265. </xsl:when>
  266. <!-- special case: userCapabilityPermission/userCapability -->
  267. <xsl:when test="local-name()='userCapability' and substring-after(../@xsi:type, ':')='userCapabilityPermission'">
  268. <xsl:attribute name="userCapability"><xsl:value-of select="."/></xsl:attribute>
  269. </xsl:when>
  270. <!-- special case: permission/access -->
  271. <xsl:when test="$localName='access' and (substring-after(../@xsi:type, ':')='permission' or substring-after(../@xsi:type, ':')='userCapabilityPermission')">
  272. <xsl:attribute name="access"><xsl:value-of select="."/></xsl:attribute>
  273. </xsl:when>
  274. <!-- special case: We need to disable output escaping for properties that contain XML data.
  275. Property Object
  276. =====================================================
  277. portalPage account
  278. state runTimeState
  279. executionDetails runHistory
  280. specification report/query
  281. advancedSettings config stuff
  282. -->
  283. <xsl:when test="$localName='portalPage' or $localName='state' or $localName='executionDetails' or ($localName='specification' and @type!='powerPlayServiceSpecificationProp') or $localName='advancedSettings'">
  284. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  285. <xsl:attribute name="type"><xsl:value-of select="@xsi:type"/></xsl:attribute>
  286. <xsl:apply-templates select="*[substring-after(@xsi:type, ':')='schemaInfo']"/>
  287. <xsl:value-of select="value" disable-output-escaping="yes"/>
  288. </xsl:element>
  289. </xsl:when>
  290. <xsl:when test="$localName='report' or $localName='dispatcherID'">
  291. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  292. <xsl:attribute name="type"><xsl:value-of select="@xsi:type"/></xsl:attribute>
  293. <xsl:apply-templates select="*[substring-after(@xsi:type, ':')='schemaInfo']"/>
  294. <!-- don't want the XML to be expanded - it'll pick up a namespace attribute otherwise -->
  295. <xsl:value-of select="value"/>
  296. </xsl:element>
  297. </xsl:when>
  298. <!-- special case for deploymentOptions. deploymentOptions are still needed to be processed in the post-process.xslt. Do not do a simple copy of options if they are on a deployment object.-->
  299. <xsl:when test="$localName='options' and substring-after(../@xsi:type, ':')!='exportDeployment' and substring-after(../@xsi:type, ':')!='importDeployment' and substring-after(../@xsi:type,':')!='powerPlayReport'">
  300. <!-- Make sure all the attribute values that start with 'cm:' get replaced with 'bus:' -->
  301. <xsl:apply-templates select="." mode="options"/>
  302. </xsl:when>
  303. <xsl:when test="$localName='options' and ( substring-after(../@xsi:type,':')='powerPlayReport')">
  304. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  305. <xsl:for-each select="value/item">
  306. <xsl:variable name="class" select="substring-after(@xsi:type, ':')"/>
  307. <xsl:element name="{$class}" namespace="{$xtscm}">
  308. <cm:name>
  309. <xsl:value-of select="name"/>
  310. </cm:name>
  311. <cm:value>
  312. <xsl:value-of select="value"/>
  313. </cm:value>
  314. </xsl:element>
  315. </xsl:for-each>
  316. </xsl:element>
  317. </xsl:when>
  318. <!-- For searchPathStoreID add another element <id> containing the GUID only -->
  319. <xsl:when test="$localName = 'storeID'">
  320. <xsl:variable name="value">
  321. <xsl:choose>
  322. <xsl:when test="value and string(./value) != ''"><xsl:value-of select="value"/></xsl:when>
  323. <xsl:when test="string(child::node()) != ''"><xsl:value-of select="normalize-space(string(child::node()))"/></xsl:when>
  324. <xsl:otherwise></xsl:otherwise>
  325. </xsl:choose>
  326. </xsl:variable>
  327. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  328. <xsl:attribute name="type"><xsl:value-of select="@xsi:type"/></xsl:attribute>
  329. <xsl:if test="substring(@xsi:type, string-length(@xsi:type)-3) = 'Prop' and not(value)">
  330. <xsl:attribute name="nil">true</xsl:attribute>
  331. </xsl:if>
  332. <xsl:value-of select="$value"/>
  333. </xsl:element>
  334. </xsl:when>
  335. <xsl:otherwise>
  336. <!-- include the element and continue processing -->
  337. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  338. <xsl:attribute name="type"><xsl:value-of select="@xsi:type"/></xsl:attribute>
  339. <xsl:if test="substring(@xsi:type, string-length(@xsi:type)-3) = 'Prop' and not(value)">
  340. <xsl:attribute name="nil">true</xsl:attribute>
  341. </xsl:if>
  342. <xsl:apply-templates/>
  343. </xsl:element>
  344. </xsl:otherwise>
  345. </xsl:choose>
  346. </xsl:otherwise>
  347. </xsl:choose>
  348. </xsl:template>
  349. <!--
  350. When dealing with options we have to replace all the 'cm:' in attribute values with 'bus:'. Since we deal with options in
  351. their raw form and when we're updating CM we're the namespace prefix 'bus' as the http://developer.cognos.com/schemas/bibus/3/. We
  352. don't specify the namespace prefix 'cm' in our update requests, so if we leave 'cm:' in the attribute values CM doesn't think that
  353. the attribute value has a namespace and they'll add it. This causes us to get 'cm:cm:<attribute value>' when we query CM after an
  354. update. Trakker bug 472828
  355. -->
  356. <xsl:template match="*" mode="options">
  357. <xsl:element name="{local-name()}">
  358. <xsl:for-each select="@*">
  359. <xsl:attribute name="{name()}">
  360. <xsl:choose>
  361. <xsl:when test="starts-with(.,'cm:')"><xsl:value-of select="concat('bus:',substring-after(.,'cm:'))"/></xsl:when>
  362. <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
  363. </xsl:choose>
  364. </xsl:attribute>
  365. </xsl:for-each>
  366. <xsl:apply-templates mode="options"/>
  367. </xsl:element>
  368. </xsl:template>
  369. <!-- REVISE: quick hack for IB#22 only -->
  370. <xsl:template match="permissions[./value/@xsi:nil='true']" priority="1">
  371. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  372. <xsl:apply-templates/>
  373. <xsl:text>read write execute setPolicy traverse</xsl:text>
  374. </xsl:element>
  375. </xsl:template>
  376. <!-- convert the permissions array of NMTOKEN into a string of tokens -->
  377. <xsl:template match="permissions[@xsi:type='cm:nmtokenArrayProp']" priority="1">
  378. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  379. <xsl:attribute name="type">xsd:string</xsl:attribute>
  380. <xsl:apply-templates select="*[substring-after(@xsi:type, ':')='schemaInfo']"/>
  381. <xsl:value-of select="normalize-space(value)"/>
  382. </xsl:element>
  383. </xsl:template>
  384. <!-- convert a data source's capabilities properties into an array of values -->
  385. <xsl:template match="capabilities[@xsi:type='cm:anyURIArrayProp']" priority="1">
  386. <xsl:element name="dataSourceCapabilities" namespace="{$xtscm}">
  387. <xsl:attribute name="type">xsd:string</xsl:attribute>
  388. <xsl:apply-templates select="*[substring-after(@xsi:type, ':')='schemaInfo']"/>
  389. <xsl:for-each select="./value/item">
  390. <xsl:element name="capability" namespace="{$xtscm}"><xsl:value-of select="."/></xsl:element>
  391. </xsl:for-each>
  392. </xsl:element>
  393. </xsl:template>
  394. <!-- convert the effectiveUserCapabilities -->
  395. <xsl:template match="effectiveUserCapabilities" priority="1">
  396. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  397. <xsl:for-each select="./value/item">
  398. <xsl:variable name="capability" select="string(.)"/>
  399. <xsl:if test="$capability != ''">
  400. <xsl:element name="{$capability}" namespace="{$xtscm}"/>
  401. </xsl:if>
  402. </xsl:for-each>
  403. </xsl:element>
  404. </xsl:template>
  405. <xsl:template match="mostRecentEventList[@xsi:type='cm:baseClassArrayProp']" priority="1">
  406. <xsl:element name="{local-name()}" namespace="{$xtscm}">
  407. <xsl:if test="not(value/item)">
  408. <xsl:attribute name="nil">true</xsl:attribute>
  409. </xsl:if>
  410. <xsl:if test="value/item">
  411. <xsl:value-of select="value/item/searchPath/value/."/>
  412. </xsl:if>
  413. </xsl:element>
  414. </xsl:template>
  415. <!-- grab the text -->
  416. <xsl:template match="text()" priority="0">
  417. <!-- XLTC hack, check for empty text node -->
  418. <xsl:if test="normalize-space(.)!=''">
  419. <xsl:value-of select="."/>
  420. </xsl:if>
  421. </xsl:template>
  422. <xsl:template name="elements2attributes">
  423. <xsl:for-each select="child::*">
  424. <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
  425. </xsl:for-each>
  426. </xsl:template>
  427. <xsl:template name="elements2attributes-value2node">
  428. <xsl:for-each select="child::*[local-name() != 'value']">
  429. <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
  430. </xsl:for-each>
  431. <xsl:apply-templates select="child::*[local-name() = 'value']"/>
  432. </xsl:template>
  433. </xsl:stylesheet>