logic.xslt 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cpscrn
  5. (C) Copyright IBM Corp. 2005, 2011
  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"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:val="http://developer.cognos.com/schemas/validator/1/">
  15. <!--
  16. the following imports requires these variables to be defined:
  17. $metaData, $interactions, $logic, $userPreferences, $navRequest, $navResponse
  18. -->
  19. <xsl:import href="/common/propeditor/types/xsdtypes.xslt"/>
  20. <xsl:import href="/common/propeditor/types/fragextTypes.xslt"/>
  21. <xsl:import href="/common/propeditor/types/cmtypes.xslt"/>
  22. <xsl:import href="/common/propeditor/types/cmmtypes.xslt"/>
  23. <xsl:import href="/common/propeditor/types/generictypes.xslt"/>
  24. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  25. <!--
  26. Variable declarations. The xpath "/*[false()]" provides an empty node set result.
  27. -->
  28. <xsl:variable name="metaData" select="/root/fragment/meta"/>
  29. <xsl:variable name="interactions" select="/root/interactions"/>
  30. <xsl:variable name="state" select="/root/state"/>
  31. <xsl:variable name="userPreferences" select="/root/preferences"/>
  32. <xsl:variable name="logic" select="/*[false()]"/>
  33. <xsl:variable name="navRequest" select="/*[false()]"/>
  34. <xsl:variable name="navResponse" select="/*[false()]"/>
  35. <xsl:key name="env-param" match="/root/interactions/param" use="@name"/>
  36. <xsl:template match="/">
  37. <response>
  38. <fragment>
  39. <meta>
  40. <xsl:choose>
  41. <xsl:when test="$metaData/*[local-name() = 'globalValidator']">
  42. <globalValidator>
  43. <!-- first copy in the validator for the target fragment -->
  44. <xsl:copy-of select="$metaData/*[local-name() = 'globalValidator']/*"/>
  45. <!-- next copy in the validator of the generic editor -->
  46. <xsl:copy-of select="/root/input[@name='geMeta']/globalValidator/*"/>
  47. </globalValidator>
  48. </xsl:when>
  49. <xsl:otherwise>
  50. <xsl:copy-of select="/root/input[@name='geMeta']/globalValidator"/>
  51. </xsl:otherwise>
  52. </xsl:choose>
  53. <xsl:copy-of select="$metaData/*[local-name() != 'globalValidator']"/>
  54. </meta>
  55. <xsl:if test="not ($interactions/param[@name='privateAction' and (.='save' or .='cancel')])">
  56. <markup>
  57. <validator>
  58. <xsl:apply-templates select="$metaData/customProperties" mode="logic-markup-validator"/>
  59. </validator>
  60. </markup>
  61. </xsl:if>
  62. </fragment>
  63. <logic>
  64. <targetMeta>
  65. <meta>
  66. <xsl:for-each select="/root/fragment/*[local-name() = 'meta']/customProperties[string(control/@appearance) != 'hidden']">
  67. <xsl:choose>
  68. <xsl:when test="(count(default/value) > 0) and (string(default/value/@xml:lang) = '')">
  69. <customProperties name="{@name}">
  70. <xsl:for-each select="./*">
  71. <xsl:if test="local-name() = 'control'">
  72. <xsl:call-template name="copyControlElement">
  73. <xsl:with-param name="controlElement" select="."/>
  74. </xsl:call-template>
  75. </xsl:if>
  76. <xsl:if test="local-name() != 'default' and local-name() != 'control'">
  77. <xsl:copy-of select="."/>
  78. </xsl:if>
  79. </xsl:for-each>
  80. <default>
  81. <value xml:lang="{$userPreferences/param[@name='contentLocale']}">
  82. <xsl:value-of select="default/value"/>
  83. </value>
  84. </default>
  85. </customProperties>
  86. </xsl:when>
  87. <xsl:otherwise>
  88. <xsl:copy>
  89. <xsl:copy-of select="@*"/>
  90. <xsl:copy-of select="./*[local-name() != 'control']"/>
  91. <xsl:for-each select="./*[local-name() = 'control']">
  92. <xsl:call-template name="copyControlElement">
  93. <xsl:with-param name="controlElement" select="."/>
  94. </xsl:call-template>
  95. </xsl:for-each>
  96. </xsl:copy>
  97. </xsl:otherwise>
  98. </xsl:choose>
  99. </xsl:for-each>
  100. </meta>
  101. </targetMeta>
  102. </logic>
  103. </response>
  104. </xsl:template>
  105. <xsl:template name="copyControlElement">
  106. <xsl:param name="controlElement"/>
  107. <xsl:copy>
  108. <xsl:copy-of select="$controlElement/@*"/>
  109. <xsl:variable name="currentGroupID" select="$controlElement/@group"/>
  110. <xsl:if test="$metaData/controlGroups[@id = $currentGroupID]">
  111. <xsl:element name="group">
  112. <xsl:if test="string($metaData/controlGroups[@id = $currentGroupID]/@order) != ''">
  113. <xsl:attribute name="order"><xsl:value-of select="$metaData/controlGroups[@id = $currentGroupID]/@order"/></xsl:attribute>
  114. </xsl:if>
  115. <xsl:value-of select="$metaData/controlGroups[@id = $currentGroupID]/label"/>
  116. </xsl:element>
  117. </xsl:if>
  118. <xsl:copy-of select="$controlElement/*"/>
  119. </xsl:copy>
  120. </xsl:template>
  121. <!-- these are templates required by the markup stage -->
  122. <xsl:template name="getPropertyValue"/>
  123. <xsl:template name="relatedControl"/>
  124. <xsl:template name="keyScript"/>
  125. <xsl:template name="createLanguageSelector"/>
  126. <xsl:template match="customProperties" mode="logic-markup-validator">
  127. <xsl:variable name="prefix" select="substring-before(datatype, ':')"/>
  128. <xsl:variable name="type" select="substring-after(datatype, ':')"/>
  129. <xsl:variable name="namespaceSpecificCustomProps">
  130. <xsl:element name="{$prefix}:{$type}" namespace="{datatype/namespace::*[name() = $prefix]}">
  131. <xsl:copy-of select="self::node()"/>
  132. </xsl:element>
  133. </xsl:variable>
  134. <xsl:apply-templates select="$namespaceSpecificCustomProps/*" mode="metaValidators"/>
  135. </xsl:template>
  136. </xsl:stylesheet>
  137. <!-- $Header: //cpscrn/main/src/java/etc/webapps/cps/WEB-INF/fragments/producers/common/propeditor/logic.xslt#1 $ -->
  138. <!-- $DateTime: 2008/10/22 11:12:04 $ -->
  139. <!-- $Change: 25109 $ -->