formlogic.xslt 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045
  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, 2022
  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:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:out="dummy-uri" xmlns:utml="http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/">
  13. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  14. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  15. <xsl:variable name="utml-namespace-uri" select="'http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/'"/>
  16. <xsl:template match="/">
  17. <xsl:apply-templates/>
  18. </xsl:template>
  19. <!--
  20. eXtensible Form Markup Logicsheet 1.0
  21. Upfront Template Markup Language 3.0
  22. Copyright (c) 1998 - 2008 Cognos Inc.
  23. utml:form
  24. utml:input
  25. utml:textbox
  26. utml:checkbox
  27. utml:radio
  28. utml:password
  29. utml:hidden
  30. utml:textarea
  31. utml:select
  32. utml:option
  33. attributes
  34. utml:name
  35. utml:value
  36. utml:default-value
  37. utml:update
  38. utml:prefix
  39. utml:generate-cancel-form
  40. helper functions
  41. utml:subst
  42. utml:comment
  43. utml:dump-state
  44. -->
  45. <!--
  46. utml:form
  47. name
  48. method
  49. target
  50. action
  51. -->
  52. <xsl:template match="utml:form[namespace-uri() = $utml-namespace-uri]" priority="1">
  53. <!-- get the form name... -->
  54. <out:variable name="utml-form-name">
  55. <xsl:call-template name="get-utml-name">
  56. <xsl:with-param name="node" select="."/>
  57. </xsl:call-template>
  58. </out:variable>
  59. <form>
  60. <!-- copy non-utml attributes... -->
  61. <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
  62. <!-- set the name... -->
  63. <out:attribute name="name">
  64. <out:value-of select="$utml-form-name"/>
  65. </out:attribute>
  66. <!-- determine if this ontrol needs to be rendered in read-only mode -->
  67. <out:variable name="form-read-only">
  68. <xsl:call-template name="get-utml-read-only">
  69. <xsl:with-param name="node" select="."/>
  70. </xsl:call-template>
  71. </out:variable>
  72. <!-- handle children... -->
  73. <xsl:apply-templates/>
  74. <!--
  75. the only constraint with prefixes is that if a relative path is given in any XPath expression the value will
  76. not be substituted. we have to define variables here so that they will be generated, and referencable below
  77. in the generated XSLT...this is necessary b/c the prefix could contain an XPath expression inside an xslt
  78. element, such as:
  79. <utml:input type="input" value="xxx">
  80. <utml:prefix>
  81. <xsl:text/>prefix1<xsl:text/>
  82. <xsl:value-of select="/root/env/param[@name = 'zzz']"/>
  83. </utml:prefix>
  84. </utml:input>
  85. if we don't define a variable and make its contents a copy of the original contents of the utml:prefix information
  86. will be lost.
  87. -->
  88. <xsl:for-each select="//utml:input[@utml:prefix or utml:prefix] | //utml:textarea[@utml:prefix or utml:prefix] | //utml:select[@utml:prefix or utml:prefix] | //utml:radio-group[@utml:prefix or utml:prefix]">
  89. <out:variable name="{concat( 'generated-id-', generate-id(.) )}">
  90. <xsl:call-template name="get-utml-prefix">
  91. <xsl:with-param name="node" select="."/>
  92. </xsl:call-template>
  93. </out:variable>
  94. </xsl:for-each>
  95. <!--
  96. build up the existence test string, this will be used to determine what query-values to create hidden inputs for,
  97. utml:prefix's take precedence over name, when doing the comparison. name can only be used when
  98. it is given as an attribute.
  99. -->
  100. <xsl:variable name="is-utml-exclusion-list" select="utml:exclusion-list"/>
  101. <xsl:variable name="existence-test-string">
  102. <xsl:variable name="test-string">
  103. <xsl:for-each select="//utml:input[not(@type = 'button' or type = 'button') and not( (@type = 'radio' or type = 'radio') and ancestor::*[name() = 'utml:radio-group'] )] | //utml:textarea | //utml:select | //utml:radio-group | //utml:change">
  104. <xsl:if test="position() = 1">
  105. <xsl:text>not(</xsl:text>
  106. </xsl:if>
  107. <xsl:choose>
  108. <xsl:when test="./@utml:prefix or ./utml:prefix">
  109. <xsl:text/>starts-with(@name, <xsl:value-of select="concat( '$generated-id-', generate-id(.) )"/>) or <xsl:text/>
  110. </xsl:when>
  111. <xsl:when test="./@name">
  112. <xsl:text/>( @name = '<xsl:value-of select="./@name"/>' or @name = '<xsl:value-of select="concat( 'tmp_chkbox_', ./@name )"/>' or @name = '<xsl:value-of select="concat( 'changed_', ./@name )"/>' ) or <xsl:text/>
  113. </xsl:when>
  114. </xsl:choose>
  115. <xsl:if test="position() = last()">
  116. <xsl:if test="$is-utml-exclusion-list">
  117. <xsl:text/>contains($utml-exclusion-list, concat(' ', @name, ' ')) or <xsl:text/>
  118. </xsl:if>
  119. <xsl:text/>starts-with(@name, 'h_CAM'))<xsl:text/>
  120. </xsl:if>
  121. </xsl:for-each>
  122. </xsl:variable>
  123. <xsl:choose>
  124. <xsl:when test="$test-string = ''">
  125. <xsl:text/>true()<xsl:text/>
  126. </xsl:when>
  127. <xsl:otherwise>
  128. <xsl:value-of select="$test-string"/>
  129. </xsl:otherwise>
  130. </xsl:choose>
  131. </xsl:variable>
  132. <!-- copy all unused query-values into the form as hidden inputs... -->
  133. <xsl:if test="utml:exclusion-list">
  134. <out:variable name="utml-exclusion-list">
  135. <out:value-of select="' '"/>
  136. <xsl:copy-of select="utml:exclusion-list/child::node()"/>
  137. <out:value-of select="' '"/>
  138. </out:variable>
  139. </xsl:if>
  140. <!-- this will allow you to specify other fields to exclude in the automatic building of the hidden inputs -->
  141. <out:variable name="other-excludes">
  142. <xsl:for-each select="//utml:form/utml:excludes">
  143. <xsl:value-of select="concat(' ', normalize-space(.), ' ')"/>
  144. </xsl:for-each>
  145. </out:variable>
  146. <!-- this will allow you to specigy a prefix to exclude hidden inputs for -->
  147. <out:variable name="exclude-prefix">
  148. <xsl:choose>
  149. <xsl:when test="//utml:form/utml:exclude-prefix">
  150. <xsl:copy-of select="//utml:form/utml:exclude-prefix"/>
  151. </xsl:when>
  152. <xsl:otherwise>
  153. <xsl:value-of select="'do_not_include_this_entry_'"/>
  154. </xsl:otherwise>
  155. </xsl:choose>
  156. </out:variable>
  157. <out:for-each select="/root/env/param[not(starts-with( @name, $exclude-prefix ))]">
  158. <out:if test="{$existence-test-string} and not(contains($other-excludes, concat(' ', @name, ' ')))">
  159. <!--
  160. TODO: if we don't add the space (&#160;) below, the carriage return and tab will be lost...I don't
  161. think Xalan is handling whitespace correctly when the xsl:output method is 'HTML'. however, adding
  162. the space (which will be rendered as &nbsp; by Xalan may cause some formatting head aches...
  163. No one is quite sure why this was put into the code. We'll comment it out for now, and remove it later.
  164. <xsl:text/>&#10;&#09;&#160;<xsl:text/>
  165. -->
  166. <!-- the default operation (if the control was not explicitly given on the page) is "maintain" -->
  167. <out:choose>
  168. <out:when test="@name = 'ps_nav_op'">
  169. <input type="hidden" name="{'{@name}'}" value="'maintain'"/>
  170. </out:when>
  171. <out:otherwise>
  172. <input type="hidden" name="{'{@name}'}" value="{'{.}'}"/>
  173. </out:otherwise>
  174. </out:choose>
  175. </out:if>
  176. </out:for-each>
  177. <!-- UTML navigation control fields: Add those to the page if they do not exist already. -->
  178. <!-- Navigation instruction for stacked dialogs. -->
  179. <xsl:if test="not(//utml:input[@name = 'ps_nav_op' or name = 'ps_nav_op']) ">
  180. <out:if test="not( /root/env/param[@name = 'ps_nav_op'] )">
  181. <!--xsl:text/>&#10;&#09;&#160;<xsl:text/-->
  182. <input type="hidden" name="ps_nav_op" value=""/>
  183. </out:if>
  184. </xsl:if>
  185. <!-- Comma-delimited list of template names representing a set of stacked dialogs resulting from a "push" or a "stack-up" navigation operations. -->
  186. <xsl:if test="not(//utml:input[@name = 'ps_nav_stack' or name = 'ps_nav_stack']) ">
  187. <out:if test="not( /root/env/param[@name = 'ps_nav_stack'] )">
  188. <!--xsl:text/>&#10;&#09;&#160;<xsl:text/-->
  189. <input type="hidden" name="ps_nav_stack" value=""/>
  190. </out:if>
  191. </xsl:if>
  192. <!-- The name of the current template. This is used by formlogic-init to determine where we came from to update the navigation stack. -->
  193. <xsl:if test="not(//utml:input[@name = 'ps_nav_source' or name = 'ps_nav_source']) ">
  194. <out:if test="not( /root/env/param[@name = 'ps_nav_source'] )">
  195. <!--xsl:text/>&#10;&#09;&#160;<xsl:text/-->
  196. <input type="hidden" name="ps_nav_source">
  197. <xsl:attribute name="value">{/root/env/param[@name = 'm']}</xsl:attribute>
  198. </input>
  199. </out:if>
  200. </xsl:if>
  201. </form>
  202. </xsl:template>
  203. <xsl:template match="utml:a[namespace-uri() = $utml-namespace-uri]" priority="1">
  204. <!-- Temporary work-around for XSLTC bug #6819 - variable scoping problem with literal result elements -->
  205. <out:if test="true()">
  206. <!-- get the href value, it can only contain JS, but we won't check for it... ... -->
  207. <xsl:variable name="hide-when-read-only">
  208. <xsl:call-template name="get-utml-hide-when-read-only">
  209. <xsl:with-param name="node" select="."/>
  210. </xsl:call-template>
  211. </xsl:variable>
  212. <out:variable name="read-only">
  213. <xsl:call-template name="get-utml-read-only">
  214. <xsl:with-param name="node" select="."/>
  215. </xsl:call-template>
  216. </out:variable>
  217. <out:variable name="hide">
  218. <xsl:choose>
  219. <xsl:when test=" $hide-when-read-only = 'true' ">
  220. <out:value-of select="read-only"/>
  221. </xsl:when>
  222. <xsl:otherwise>
  223. <xsl:value-of select=" 'false' "/>
  224. </xsl:otherwise>
  225. </xsl:choose>
  226. </out:variable>
  227. <out:variable name="unique-id">
  228. <xsl:call-template name="get-utml-unique-id">
  229. <xsl:with-param name="node" select="."/>
  230. </xsl:call-template>
  231. </out:variable>
  232. <out:if test="($hide = 'false') or ($read-only = 'false' and $form-read-only = 'false')">
  233. <out:variable name="href">
  234. <xsl:call-template name="get-utml-href">
  235. <xsl:with-param name="node" select="."/>
  236. </xsl:call-template>
  237. </out:variable>
  238. <!-- get the utml:target... -->
  239. <out:variable name="target">
  240. <xsl:call-template name="get-utml-target">
  241. <xsl:with-param name="node" select="."/>
  242. </xsl:call-template>
  243. </out:variable>
  244. <out:variable name="defaultKey">
  245. <xsl:call-template name="get-utml-defaultKey">
  246. <xsl:with-param name="node" select="."/>
  247. </xsl:call-template>
  248. </out:variable>
  249. <out:variable name="defaultAct">
  250. <xsl:call-template name="get-utml-defaultAct">
  251. <xsl:with-param name="node" select="."/>
  252. </xsl:call-template>
  253. </out:variable>
  254. <!-- get the utml:op value, currently it can only be plain text... -->
  255. <xsl:variable name="op">
  256. <xsl:choose>
  257. <xsl:when test="./@utml:op = 'push' or ./@utml:op = 'stack-up'">
  258. <xsl:value-of select="'push'"/>
  259. </xsl:when>
  260. <xsl:when test="./@utml:op = 'pop' or ./@utml:op = 'stack-down'">
  261. <xsl:value-of select="'pop'"/>
  262. </xsl:when>
  263. <xsl:when test="./@utml:op = 'drop' or ./@utml:op = 'stack-down-save'">
  264. <xsl:value-of select="'drop'"/>
  265. </xsl:when>
  266. <xsl:when test="./@utml:op = 'submit'">
  267. <xsl:value-of select="'submit'"/>
  268. </xsl:when>
  269. <xsl:otherwise>
  270. <xsl:value-of select="'maintain'"/>
  271. </xsl:otherwise>
  272. </xsl:choose>
  273. </xsl:variable>
  274. <!-- get the name of the parent form, necessary for setting form variables via JS -->
  275. <out:variable name="parent-form-name">
  276. <xsl:choose>
  277. <xsl:when test="ancestor::*[name() = 'utml:form' and namespace-uri() = $utml-namespace-uri]">
  278. <xsl:call-template name="get-utml-name">
  279. <xsl:with-param name="node" select="ancestor::*[name() = 'utml:form' and namespace-uri() = $utml-namespace-uri]"/>
  280. </xsl:call-template>
  281. </xsl:when>
  282. <xsl:otherwise>
  283. <xsl:choose>
  284. <xsl:when test="@utml:formName">
  285. <xsl:value-of select="@utml:formName"/>
  286. </xsl:when>
  287. <xsl:when test="utml:formName">
  288. <xsl:copy-of select="utml:formName/child::node()"/>
  289. </xsl:when>
  290. <xsl:otherwise>
  291. <out:value-of select="$utml-form-name"/>
  292. </xsl:otherwise>
  293. </xsl:choose>
  294. </xsl:otherwise>
  295. </xsl:choose>
  296. </out:variable>
  297. <!-- determine whether we're to call a JS validate function or not. -->
  298. <out:variable name="validate">
  299. <xsl:call-template name="get-utml-validate">
  300. <xsl:with-param name="node" select="."/>
  301. </xsl:call-template>
  302. </out:variable>
  303. <!--
  304. Use this to delimit template names in the navigation stack. Use * since it is the least likely char to be used in a folder or file name.
  305. This is also defined in formlogic_init.xslt
  306. -->
  307. <out:variable name="nav-stack-delimiter" select="'*'"/>
  308. <out:variable name="js-logic">
  309. <!-- propogate the navigation operation...-->
  310. document.<out:value-of select="$parent-form-name"/>.ps_nav_op.value = '<xsl:value-of select="$op"/>';
  311. <!-- calculate the target morphlet... -->
  312. <out:choose>
  313. <out:when test="$target">
  314. document.<out:value-of select="$parent-form-name"/>.m.value = '<out:value-of select="$target"/>';
  315. </out:when>
  316. <!-- if the user gave one of the operations: stack-up, submit, or no operation, they would have been required to give a target, in which case we won't be here, however don't currently have
  317. the ability to validate(!), so we'll just use a conditional test... -->
  318. <out:otherwise>
  319. <xsl:if test="$op = 'pop' or $op = 'drop'">
  320. <!-- Determine the new target from the existing stack. If the current template is A then the current stack could be somthing like A,B,C. we want to extract B. -->
  321. <out:variable name="new-target">
  322. <out:choose>
  323. <out:when test="contains(/root/env/param[@name='ps_nav_stack'], $nav-stack-delimiter)">
  324. <out:value-of select="substring-before( /root/env/param[@name='ps_nav_stack'], $nav-stack-delimiter )"/>
  325. </out:when>
  326. <out:otherwise>
  327. <out:value-of select="/root/env/param[@name='ps_nav_stack']"/>
  328. </out:otherwise>
  329. </out:choose>
  330. </out:variable>
  331. document.<out:value-of select="$parent-form-name"/>.m.value = "<out:value-of select="xtsext:javascriptencode($new-target)"/>";
  332. </xsl:if>
  333. </out:otherwise>
  334. </out:choose>
  335. <!-- insert any user specified href info... -->
  336. <out:value-of select="$href"/>
  337. <!-- form submission... -->
  338. <out:variable name="submit">
  339. <xsl:call-template name="get-utml-submit">
  340. <xsl:with-param name="node" select="."/>
  341. </xsl:call-template>
  342. </out:variable>
  343. <out:if test="$submit != 'false'">
  344. <script language="JavaScript">
  345. <![CDATA[
  346. function needCustomHeader(formName)
  347. {
  348. var needed = false;
  349. var iFrmCmd = formName.ifrmcmd;
  350. var psNavOp = formName.ps_nav_op;
  351. var mClass = formName.m_class;
  352. var psNavSource = formName.ps_nav_source;
  353. var mNewClass = formName.m_new_class;
  354. if ( iFrmCmd != undefined && iFrmCmd.value === "create" &&
  355. psNavOp != undefined && psNavOp.value === "submit" )
  356. {
  357. if ( mClass != undefined && mClass.value === "subscriptionFolder" &&
  358. psNavSource != undefined && psNavSource.value.slice(-"new_general.xts".length) === "new_general.xts" ) {
  359. needed = true;
  360. }
  361. else if ( mNewClass != undefined && mNewClass.value === "subscriptionFolder" &&
  362. psNavSource != undefined && psNavSource.value.slice(-"new_actions.xts".length) === "new_actions.xts" ) {
  363. needed = true;
  364. }
  365. }
  366. return needed;
  367. }
  368. function getFormDataQueryString(form)
  369. {
  370. var keyValuePairs = [];
  371. for (var i = 0; i < form.elements.length; i++)
  372. {
  373. var element = form.elements[i];
  374. keyValuePairs.push(encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value));
  375. }
  376. return queryString = keyValuePairs.join("&");
  377. }
  378. ]]>
  379. </script>
  380. <!-- XSRF-TOKEN cookie is null when disableXSRFCheck=true in bootstrap.properties. -->
  381. var xsrfTokenCookie = getCookie("XSRF-TOKEN");
  382. var formName= document.<out:value-of select="$parent-form-name"/>;
  383. if (xsrfTokenCookie &amp;&amp; needCustomHeader(formName))
  384. {
  385. <!--
  386. CAPSIRTS-412 / MANAGECA-9957
  387. Case A:
  388. 1. Go to "Personal menu" > "My Watch Items" and "Rules".
  389. 2. Click "New Folder", enter a name, etc., and click "Finish".
  390. ifrmcmd=create
  391. ps_nav_op=submit
  392. m_class=subscriptionFolder
  393. ps_nav_source=portal/new_general.xts
  394. Case B
  395. 1. Go to "Personal menu" > "My Watch Items" and "Rules".
  396. 2. Click "New Folder" and click "Select another location...".
  397. 3. Click "New Folder...", enter a name, etc., and click "Finish".
  398. ...
  399. ifrmcmd=create
  400. ps_nav_op=submit
  401. m_new_class=subscriptionFolder
  402. ps_nav_source=portal/select/new_actions.xts
  403. -->
  404. var xhr = new XMLHttpRequest();
  405. xhr.onreadystatechange = function()
  406. {
  407. if (xhr.readyState === 4)
  408. {
  409. document.write(xhr.responseText);
  410. document.close();
  411. }
  412. }
  413. xhr.open(formName.method, formName.action, false);
  414. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  415. xhr.setRequestHeader("X-XSRF-TOKEN", xsrfTokenCookie);
  416. xhr.send(getFormDataQueryString(formName));
  417. }
  418. else
  419. {
  420. formName.submit();
  421. }
  422. </out:if>
  423. </out:variable>
  424. <!-- Generate a unique id to use for calling a function. Use the unique-id the caller passed it in if it exists. We need this so that we do not have name collisions when more than one <utml:a> exist on a page. -->
  425. <out:variable name="node_id">
  426. <out:choose>
  427. <out:when test="$unique-id!=''"><out:value-of select="$unique-id"/></out:when>
  428. <out:otherwise><xsl:value-of select="generate-id(.)"/></out:otherwise>
  429. </out:choose>
  430. </out:variable>
  431. <!-- Output the JS snippet for the anchor -->
  432. <script language="JavaScript">
  433. <out:if test="$defaultKey = 'active'">
  434. function enterdfaultact()
  435. {
  436. var currentFocusEl = document.activeElement;
  437. if (currentFocusEl.tagName.toLowerCase() =='a' || currentFocusEl.getAttribute("role") == 'button' || currentFocusEl.getAttribute("role") == 'link'){
  438. return true;
  439. }
  440. <out:if test="$defaultAct!=''">
  441. <out:value-of select="$defaultAct"/>
  442. </out:if>
  443. utmlA_<out:value-of select="$node_id"/>();
  444. return false;
  445. }
  446. </out:if>
  447. function utmlA_<out:value-of select="$node_id"/>()
  448. {
  449. <out:choose>
  450. <!--out:when test="$validate = 'true'" -->
  451. <!-- If the morphlet writer provided a validate() function on the page then make sure to call it before execution. -->
  452. <!-- if (window.validate)
  453. {
  454. if (validate())
  455. {
  456. <out:value-of select="$js-logic"/>
  457. }
  458. } -->
  459. <!-- If the morphlet writer did NOT provide a validate() function then politely execute the command (may be this is bad!!) -->
  460. <!-- else
  461. {
  462. <out:value-of select="$js-logic"/>
  463. }
  464. </out:when -->
  465. <out:when test="$validate != '' and $validate != 'false' ">
  466. <out:variable name="validateName">
  467. <out:choose>
  468. <out:when test="$validate='true'"><out:value-of select="'validate'"/></out:when>
  469. <out:otherwise><out:value-of select="$validate"/></out:otherwise>
  470. </out:choose>
  471. </out:variable>
  472. <!-- If the morphlet writer provided a validate() function on the page then make sure to call it before execution. -->
  473. if (window.<out:value-of select="$validateName"/>)
  474. {
  475. if (<out:value-of select="$validateName"/>())
  476. {
  477. <out:value-of select="$js-logic"/>
  478. }
  479. }
  480. <!-- If the morphlet writer did NOT provide a validate() function then politely execute the command (may be this is bad!!) -->
  481. else
  482. {
  483. <out:value-of select="$js-logic"/>
  484. }
  485. </out:when>
  486. <out:otherwise>
  487. <out:value-of select="$js-logic"/>
  488. </out:otherwise>
  489. </out:choose>
  490. }
  491. </script>
  492. <!-- Output the HTML anchor -->
  493. <a>
  494. <xsl:if test="count(ancestor::*[@role='tablist'])">
  495. <xsl:attribute name="role">tab</xsl:attribute>
  496. <xsl:attribute name="aria-selected"><out:value-of select="$isTabSelected"/></xsl:attribute>
  497. </xsl:if>
  498. <!-- copy all non-utml attributes... -->
  499. <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
  500. <out:attribute name="href">javascript:utmlA_<out:value-of select="$node_id"/>()</out:attribute>
  501. <!-- copy all non-utml child elements... -->
  502. <xsl:apply-templates/>
  503. </a>
  504. </out:if>
  505. </out:if>
  506. </xsl:template>
  507. <xsl:template match="utml:static[namespace-uri() = $utml-namespace-uri]" priority="1">
  508. <!-- calculate the control name, this includes all dynamically generated name information... -->
  509. <out:variable name="control-name">
  510. <xsl:call-template name="get-utml-prefix">
  511. <xsl:with-param name="node" select="."/>
  512. </xsl:call-template>
  513. <xsl:call-template name="get-utml-name">
  514. <xsl:with-param name="node" select="."/>
  515. </xsl:call-template>
  516. </out:variable>
  517. <!-- get the value ... -->
  518. <out:variable name="value">
  519. <xsl:call-template name="get-utml-value">
  520. <xsl:with-param name="node" select="."/>
  521. </xsl:call-template>
  522. </out:variable>
  523. <!-- get the update flag, this can only be text... -->
  524. <xsl:variable name="update">
  525. <xsl:call-template name="get-utml-update">
  526. <xsl:with-param name="node" select="."/>
  527. </xsl:call-template>
  528. </xsl:variable>
  529. <!-- update the control value, either from the query value, or the default... -->
  530. <xsl:choose>
  531. <xsl:when test="$update = 'false'">
  532. <out:value-of select="$value"/>
  533. </xsl:when>
  534. <xsl:otherwise>
  535. <out:choose>
  536. <out:when test="/root/env/param[@name = $control-name]">
  537. <!-- TEMPORARY HACK TO DEAL WITH CM ENCODING ISSUES FOR 0.1 RELEASE. -->
  538. <xsl:choose>
  539. <xsl:when test="@cmdecode = 'true'">
  540. <out:value-of select="/root/env/param[@name = $control-name]"/>
  541. </xsl:when>
  542. <xsl:otherwise>
  543. <out:value-of select="/root/env/param[@name = $control-name]"/>
  544. </xsl:otherwise>
  545. </xsl:choose>
  546. </out:when>
  547. <out:otherwise>
  548. <out:value-of select="$value"/>
  549. </out:otherwise>
  550. </out:choose>
  551. </xsl:otherwise>
  552. </xsl:choose>
  553. </xsl:template>
  554. <!-- ============================================================ -->
  555. <!-- == Text Lite - only keeps track of the variable no extras == -->
  556. <!-- ============================================================ -->
  557. <xsl:template match="utml:input[(@type = 'text-lite')]" priority="1">
  558. <input type="text">
  559. <xsl:copy-of select="@*[(local-name() != 'type') and (local-name() != 'value')]"/>
  560. <out:attribute name="value">
  561. <out:choose>
  562. <out:when test="/root/env/param[@name = '{@name}']">
  563. <out:value-of select="/root/env/param[@name = '{@name}']"/>
  564. </out:when>
  565. <out:otherwise>
  566. <xsl:copy-of select="utml:value/child::node()"/>
  567. </out:otherwise>
  568. </out:choose>
  569. </out:attribute>
  570. </input>
  571. </xsl:template>
  572. <!-- ===================================================================== -->
  573. <!-- ============== Text - Password - Hidden =================== -->
  574. <xsl:template match="utml:input[((@type = 'text' or type = 'text') or (@type = 'password' or type = 'password') or (@type = 'hidden' or type = 'hidden')) and (namespace-uri() = $utml-namespace-uri)]" priority="1">
  575. <out:if test="true()">
  576. <!-- add this here to define unique context for the variables below -->
  577. <!-- determine if this ontrol needs to be rendered in read-only mode -->
  578. <out:variable name="read-only">
  579. <xsl:call-template name="get-utml-read-only">
  580. <xsl:with-param name="node" select="."/>
  581. </xsl:call-template>
  582. </out:variable>
  583. <!-- calculate the control name, this includes all dynamically generated name information... -->
  584. <out:variable name="control-name">
  585. <xsl:call-template name="get-utml-prefix">
  586. <xsl:with-param name="node" select="."/>
  587. </xsl:call-template>
  588. <xsl:call-template name="get-utml-name">
  589. <xsl:with-param name="node" select="."/>
  590. </xsl:call-template>
  591. </out:variable>
  592. <!-- get the value ... -->
  593. <out:variable name="value">
  594. <xsl:call-template name="get-utml-value">
  595. <xsl:with-param name="node" select="."/>
  596. </xsl:call-template>
  597. </out:variable>
  598. <!-- get the update flag, this can only be text... -->
  599. <xsl:variable name="update">
  600. <xsl:call-template name="get-utml-update">
  601. <xsl:with-param name="node" select="."/>
  602. </xsl:call-template>
  603. </xsl:variable>
  604. <!-- get the type... -->
  605. <out:variable name="type">
  606. <xsl:call-template name="get-utml-type">
  607. <xsl:with-param name="node" select="."/>
  608. </xsl:call-template>
  609. </out:variable>
  610. <!-- get the state of the tracking feature... -->
  611. <xsl:variable name="track-changes">
  612. <xsl:call-template name="get-utml-track">
  613. <xsl:with-param name="node" select="."/>
  614. </xsl:call-template>
  615. </xsl:variable>
  616. <out:choose>
  617. <out:when test="($read-only = 'true' or $form-read-only = 'true') and (not($type = 'hidden'))">
  618. <out:value-of select = "xtsext:enforceBTD($value, $baseTextDirection, $productLocale, boolean($isBidiEnabled='true'))"/>
  619. </out:when>
  620. <out:otherwise>
  621. <xsl:if test="$track-changes = 'true'">
  622. <script language="JavaScript">
  623. function on_<out:value-of select="$control-name"/>_changed() {
  624. document.<out:value-of select="$utml-form-name"/>.changed_<out:value-of select="$control-name"/>.value=&quot;1&quot;;
  625. }
  626. </script>
  627. <out:variable name="hidden-control-name">
  628. <out:value-of select="concat( 'changed_', $control-name )"/>
  629. </out:variable>
  630. <input type="hidden">
  631. <out:attribute name="name">
  632. <out:value-of select="$hidden-control-name"/>
  633. </out:attribute>
  634. <out:choose>
  635. <out:when test="/root/env/param[@name = $hidden-control-name]">
  636. <out:attribute name="value">
  637. <out:value-of select="/root/env/param[@name = $hidden-control-name]"/>
  638. </out:attribute>
  639. </out:when>
  640. <out:otherwise>
  641. <out:attribute name="value">0</out:attribute>
  642. </out:otherwise>
  643. </out:choose>
  644. </input>
  645. </xsl:if>
  646. <input>
  647. <!-- copy all non-utml attributes... -->
  648. <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
  649. <!-- add the name attribute... -->
  650. <out:attribute name="name">
  651. <out:value-of select="$control-name"/>
  652. </out:attribute>
  653. <!-- add the type... -->
  654. <out:attribute name="type">
  655. <xsl:call-template name="get-utml-type">
  656. <xsl:with-param name="node" select="."/>
  657. </xsl:call-template>
  658. </out:attribute>
  659. <!-- add the onchange attribute... -->
  660. <xsl:if test="$track-changes = 'true'">
  661. <out:attribute name="onchange">
  662. <out:text/>if(window.on_<out:value-of select="$control-name"/>_changed)window.on_<out:value-of select="$control-name"/>_changed();<out:text/>
  663. <xsl:if test="@onchange">
  664. <out:text/>
  665. <xsl:value-of select="@onchange"/>
  666. <out:text/>
  667. </xsl:if>
  668. </out:attribute>
  669. </xsl:if>
  670. <!-- update the control value, either from the query value, or the default... -->
  671. <!-- bidi -->
  672. <out:variable name="updatedValue">
  673. <xsl:choose>
  674. <xsl:when test="$update = 'false'"><out:value-of select="$value"/></xsl:when>
  675. <xsl:otherwise>
  676. <out:choose>
  677. <out:when test="/root/env/param[@name = $control-name]">
  678. <out:value-of select="/root/env/param[@name = $control-name]"/>
  679. </out:when>
  680. <out:otherwise><out:value-of select="$value"/></out:otherwise>
  681. </out:choose>
  682. </xsl:otherwise>
  683. </xsl:choose>
  684. </out:variable>
  685. <out:attribute name="value">
  686. <out:value-of select="$updatedValue"/>
  687. </out:attribute>
  688. <out:variable name="textDirection">
  689. <out:choose>
  690. <out:when test="$isBidiEnabled != 'true'"></out:when>
  691. <out:otherwise>
  692. <xsl:choose>
  693. <xsl:when test="@dir"></xsl:when>
  694. <xsl:when test="@stttype">stt</xsl:when>
  695. <xsl:otherwise>
  696. <out:value-of select="xtsext:getBTD(string($updatedValue), $baseTextDirection, $productLocale)"/>
  697. </xsl:otherwise>
  698. </xsl:choose>
  699. </out:otherwise>
  700. </out:choose>
  701. </out:variable>
  702. <out:if test="$type = 'text' and $textDirection != ''">
  703. <out:choose>
  704. <out:when test="$textDirection = 'stt'">
  705. <out:attribute name="dir">ltr</out:attribute>
  706. </out:when>
  707. <out:otherwise>
  708. <out:attribute name="dir">
  709. <out:value-of select="$textDirection"/>
  710. </out:attribute>
  711. </out:otherwise>
  712. </out:choose>
  713. <out:if test="$textDirection = 'stt' or $baseTextDirection = 'auto'">
  714. <xsl:choose>
  715. <xsl:when test="@onfocus">
  716. <out:attribute name="onfocus">
  717. <xsl:value-of select="concat('bidi.onfocus(this);',@onfocus)"/>
  718. </out:attribute>
  719. </xsl:when>
  720. <xsl:otherwise>
  721. <out:attribute name="onfocus">
  722. <out:text>bidi.onfocus(this)</out:text>
  723. </out:attribute>
  724. </xsl:otherwise>
  725. </xsl:choose>
  726. </out:if>
  727. </out:if>
  728. <!-- handle children... -->
  729. <xsl:apply-templates/>
  730. </input>
  731. </out:otherwise>
  732. </out:choose>
  733. </out:if>
  734. </xsl:template>
  735. <!-- ==================================================================== -->
  736. <!-- ============== Checkbox =================== -->
  737. <xsl:template match="utml:input[(@type = 'checkbox' or type = 'checkbox') and (namespace-uri() = $utml-namespace-uri)]" priority="1">
  738. <out:if test="true()">
  739. <!-- add this here to define unique context for the variables below -->
  740. <!-- calculate the control name, this includes all dynamically generated name information... -->
  741. <out:variable name="control-name">
  742. <xsl:call-template name="get-utml-prefix">
  743. <xsl:with-param name="node" select="."/>
  744. </xsl:call-template>
  745. <xsl:call-template name="get-utml-name">
  746. <xsl:with-param name="node" select="."/>
  747. </xsl:call-template>
  748. </out:variable>
  749. <!-- determine if this ontrol needs to be rendered in read-only mode -->
  750. <out:variable name="read-only">
  751. <xsl:call-template name="get-utml-read-only">
  752. <xsl:with-param name="node" select="."/>
  753. </xsl:call-template>
  754. </out:variable>
  755. <!-- get the value ... -->
  756. <out:variable name="value">
  757. <xsl:call-template name="get-utml-value">
  758. <xsl:with-param name="node" select="."/>
  759. </xsl:call-template>
  760. </out:variable>
  761. <!-- get the update flag, this can only be text... -->
  762. <xsl:variable name="update">
  763. <xsl:call-template name="get-utml-update">
  764. <xsl:with-param name="node" select="."/>
  765. </xsl:call-template>
  766. </xsl:variable>
  767. <!-- get the default condition that will be evaluated when the queryvalue isn't present... -->
  768. <xsl:variable name="default-condition">
  769. <xsl:call-template name="get-utml-default-condition">
  770. <xsl:with-param name="node" select="."/>
  771. </xsl:call-template>
  772. </xsl:variable>
  773. <!-- get the state of the tracking feature... -->
  774. <xsl:variable name="track-changes">
  775. <xsl:call-template name="get-utml-track">
  776. <xsl:with-param name="node" select="."/>
  777. </xsl:call-template>
  778. </xsl:variable>
  779. <!-- get the state of the unchecked value feature -->
  780. <xsl:variable name="unchecked-value">
  781. <xsl:call-template name="get-utml-unchecked-value">
  782. <xsl:with-param name="node" select="."/>
  783. </xsl:call-template>
  784. </xsl:variable>
  785. <!-- get the default condition that will be evaluated when the queryvalue isn't present... -->
  786. <out:variable name="checked">
  787. <xsl:call-template name="get-checked-state">
  788. <xsl:with-param name="node" select="."/>
  789. </xsl:call-template>
  790. </out:variable>
  791. <out:choose>
  792. <out:when test="$read-only = 'true' or $form-read-only = 'true'">
  793. <img role="checkbox" aria-disabled="true">
  794. <xsl:copy-of select="@id"/>
  795. <out:choose>
  796. <out:when test="/root/env/param[@name = $control-name] = $value or $checked = 'true'">
  797. <out:attribute name="src"><out:value-of select="$image_root"/>icon_disabled_checkbox_checked.gif</out:attribute>
  798. <out:attribute name="aria-checked">true</out:attribute>
  799. </out:when>
  800. <xsl:if test="$default-condition != ''">
  801. <out:when>
  802. <xsl:attribute name="test"><xsl:value-of select="$default-condition"/></xsl:attribute>
  803. <out:attribute name="src"><out:value-of select="$image_root"/>icon_disabled_checkbox_checked.gif</out:attribute>
  804. <out:attribute name="aria-checked">true</out:attribute>
  805. </out:when>
  806. </xsl:if>
  807. <out:otherwise>
  808. <out:attribute name="src"><out:value-of select="$image_root"/>icon_disabled_checkbox_unchecked.gif</out:attribute>
  809. <out:attribute name="aria-checked">false</out:attribute>
  810. </out:otherwise>
  811. </out:choose>
  812. </img>
  813. </out:when>
  814. <out:otherwise>
  815. <xsl:if test="$track-changes = 'true'">
  816. <script language="JavaScript">
  817. function on_<out:value-of select="$control-name"/>_changed() {
  818. document.<out:value-of select="$utml-form-name"/>.changed_<out:value-of select="$control-name"/>.value=&quot;1&quot;;
  819. }
  820. </script>
  821. <out:variable name="hidden-control-name">
  822. <out:value-of select="concat( 'changed_', $control-name )"/>
  823. </out:variable>
  824. <input type="hidden">
  825. <out:attribute name="name">
  826. <out:value-of select="$hidden-control-name"/>
  827. </out:attribute>
  828. <out:choose>
  829. <out:when test="/root/env/param[@name = $hidden-control-name]">
  830. <out:attribute name="value">
  831. <out:value-of select="/root/env/param[@name = $hidden-control-name]"/>
  832. </out:attribute>
  833. </out:when>
  834. <out:otherwise>
  835. <out:attribute name="value">0</out:attribute>
  836. </out:otherwise>
  837. </out:choose>
  838. </input>
  839. </xsl:if>
  840. <xsl:if test="$unchecked-value != ''">
  841. <input type="hidden">
  842. <!-- add the name attribute... -->
  843. <out:attribute name="name">
  844. <out:value-of select="$control-name"/>
  845. </out:attribute>
  846. <!-- update the control value, either from the query value, or the default... -->
  847. <xsl:choose>
  848. <xsl:when test="$update != 'false'">
  849. <out:choose>
  850. <!-- take the value from the env -->
  851. <out:when test="/root/env/param[@name = $control-name]">
  852. <out:attribute name="value"><out:value-of select="/root/env/param[@name = $control-name]"/></out:attribute>
  853. </out:when>
  854. <xsl:if test="$default-condition != ''">
  855. <!-- if the default condition is met, then the checkbox is checked -->
  856. <out:when>
  857. <xsl:attribute name="test"><xsl:value-of select="$default-condition"/></xsl:attribute>
  858. <out:attribute name="value"><out:value-of select="$value"/></out:attribute>
  859. </out:when>
  860. </xsl:if>
  861. <out:otherwise>
  862. <out:attribute name="value"><xsl:value-of select="$unchecked-value"/></out:attribute>
  863. </out:otherwise>
  864. </out:choose>
  865. </xsl:when>
  866. <xsl:otherwise>
  867. <out:attribute name="value"><out:value-of select="$value"/></out:attribute>
  868. </xsl:otherwise>
  869. </xsl:choose>
  870. </input>
  871. </xsl:if>
  872. <input>
  873. <!-- copy all non-utml attributes... -->
  874. <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
  875. <!-- add the type... -->
  876. <out:attribute name="type">
  877. <xsl:call-template name="get-utml-type">
  878. <xsl:with-param name="node" select="."/>
  879. </xsl:call-template>
  880. </out:attribute>
  881. <!-- add the name attribute... -->
  882. <out:attribute name="name">
  883. <xsl:if test="$unchecked-value != ''">tmp_chkbox_</xsl:if>
  884. <out:value-of select="$control-name"/>
  885. </out:attribute>
  886. <!-- add the value attribute... -->
  887. <out:attribute name="value">
  888. <out:value-of select="$value"/>
  889. </out:attribute>
  890. <!-- update the control value, either from the query value, or the default... -->
  891. <xsl:if test="$update != 'false'">
  892. <out:choose>
  893. <out:when test="/root/env/param[@name = $control-name] = $value">
  894. <out:attribute name="checked">checked</out:attribute>
  895. </out:when>
  896. <xsl:if test="$default-condition != ''">
  897. <out:when>
  898. <xsl:attribute name="test"><xsl:value-of select="$default-condition"/></xsl:attribute>
  899. <out:attribute name="checked">checked</out:attribute>
  900. </out:when>
  901. </xsl:if>
  902. </out:choose>
  903. </xsl:if>
  904. <!-- add the onchange attribute... -->
  905. <xsl:if test="$track-changes = 'true' or $unchecked-value != ''">
  906. <out:attribute name="onclick">
  907. <xsl:if test="$track-changes = 'true'">
  908. <out:text/>if(window.on_<out:value-of select="$control-name"/>_changed)window.on_<out:value-of select="$control-name"/>_changed();<out:text/>
  909. </xsl:if>
  910. <xsl:if test="$unchecked-value != ''">
  911. <out:text/>if (this.checked) { document.<out:value-of select="$utml-form-name"/>.<out:value-of select="$control-name"/>.value = '<out:value-of select="xtsext:javascriptencode(string($value))"/>'; } <out:text/>
  912. <out:text/>else { document.<out:value-of select="$utml-form-name"/>.<out:value-of select="$control-name"/>.value = '<xsl:value-of select="xtsext:javascriptencode(string($unchecked-value))"/>'; } <out:text/>
  913. </xsl:if>
  914. <xsl:if test="@onclick">
  915. <out:text/>
  916. <xsl:value-of select="@onclick"/>
  917. <out:text/>
  918. </xsl:if>
  919. </out:attribute>
  920. </xsl:if>
  921. <!-- handle children... -->
  922. <xsl:apply-templates/>
  923. </input>
  924. </out:otherwise>
  925. </out:choose>
  926. </out:if>
  927. </xsl:template>
  928. <!-- ===================================================================== -->
  929. <!-- ============== Textarea =================== -->
  930. <xsl:template match="utml:textarea[namespace-uri() = $utml-namespace-uri]" priority="1">
  931. <out:if test="true()">
  932. <!-- add this here to define unique context for the variables below -->
  933. <!-- determine if this ontrol needs to be rendered in read-only mode -->
  934. <out:variable name="read-only">
  935. <xsl:call-template name="get-utml-read-only">
  936. <xsl:with-param name="node" select="."/>
  937. </xsl:call-template>
  938. </out:variable>
  939. <!-- calculate the control name, this includes all dynamically generated name information... -->
  940. <out:variable name="control-name">
  941. <xsl:call-template name="get-utml-prefix">
  942. <xsl:with-param name="node" select="."/>
  943. </xsl:call-template>
  944. <xsl:call-template name="get-utml-name">
  945. <xsl:with-param name="node" select="."/>
  946. </xsl:call-template>
  947. </out:variable>
  948. <!-- get the value ... -->
  949. <out:variable name="value">
  950. <xsl:call-template name="get-utml-value">
  951. <xsl:with-param name="node" select="."/>
  952. </xsl:call-template>
  953. </out:variable>
  954. <!-- get the update flag, this can only be text... -->
  955. <xsl:variable name="update">
  956. <xsl:call-template name="get-utml-update">
  957. <xsl:with-param name="node" select="."/>
  958. </xsl:call-template>
  959. </xsl:variable>
  960. <!-- get the state of the tracking feature... -->
  961. <xsl:variable name="track-changes">
  962. <xsl:call-template name="get-utml-track">
  963. <xsl:with-param name="node" select="."/>
  964. </xsl:call-template>
  965. </xsl:variable>
  966. <out:choose>
  967. <out:when test="$read-only = 'true' or $form-read-only = 'true'">
  968. <out:value-of select = "xtsext:enforceBTD($value, $baseTextDirection, $productLocale, boolean($isBidiEnabled='true'))"/>
  969. </out:when>
  970. <out:otherwise>
  971. <xsl:if test="$track-changes = 'true'">
  972. <script language="JavaScript">
  973. function on_<out:value-of select="$control-name"/>_changed(){
  974. document.<out:value-of select="$utml-form-name"/>.changed_<out:value-of select="$control-name"/>.value=&quot;1&quot;;
  975. }
  976. </script>
  977. <out:variable name="hidden-control-name">
  978. <out:value-of select="concat( 'changed_', $control-name )"/>
  979. </out:variable>
  980. <input type="hidden">
  981. <out:attribute name="name">
  982. <out:value-of select="$hidden-control-name"/>
  983. </out:attribute>
  984. <out:choose>
  985. <out:when test="/root/env/param[@name = $hidden-control-name]">
  986. <out:attribute name="value">
  987. <out:value-of select="/root/env/param[@name = $hidden-control-name]"/>
  988. </out:attribute>
  989. </out:when>
  990. <out:otherwise>
  991. <out:attribute name="value">0</out:attribute>
  992. </out:otherwise>
  993. </out:choose>
  994. </input>
  995. </xsl:if>
  996. <textarea>
  997. <!-- copy all non-utml attributes... -->
  998. <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
  999. <!-- add the type... -->
  1000. <out:attribute name="type">
  1001. <xsl:call-template name="get-utml-type">
  1002. <xsl:with-param name="node" select="."/>
  1003. </xsl:call-template>
  1004. </out:attribute>
  1005. <!-- add the name attribute... -->
  1006. <out:attribute name="name">
  1007. <out:value-of select="$control-name"/>
  1008. </out:attribute>
  1009. <!-- add the onchange attribute... -->
  1010. <xsl:if test="$track-changes = 'true'">
  1011. <out:attribute name="onchange">
  1012. <out:text/>if(window.on_<out:value-of select="$control-name"/>_changed)window.on_<out:value-of select="$control-name"/>_changed();<out:text/>
  1013. <xsl:if test="@onchange">
  1014. <out:text/>
  1015. <xsl:value-of select="@onchange"/>
  1016. <out:text/>
  1017. </xsl:if>
  1018. </out:attribute>
  1019. </xsl:if>
  1020. <!-- bidi -->
  1021. <out:variable name="updatedValue">
  1022. <xsl:choose>
  1023. <xsl:when test="$update = 'false'"><out:value-of select="$value"/></xsl:when>
  1024. <xsl:otherwise>
  1025. <out:choose>
  1026. <out:when test="/root/env/param[@name = $control-name]">
  1027. <out:value-of select="/root/env/param[@name = $control-name]"/>
  1028. </out:when>
  1029. <out:otherwise><out:value-of select="$value"/></out:otherwise>
  1030. </out:choose>
  1031. </xsl:otherwise>
  1032. </xsl:choose>
  1033. </out:variable>
  1034. <out:variable name="textDirection">
  1035. <out:choose>
  1036. <out:when test="$isBidiEnabled != 'true'"></out:when>
  1037. <out:otherwise>
  1038. <xsl:choose>
  1039. <xsl:when test="@dir"></xsl:when>
  1040. <xsl:when test="@stttype">stt</xsl:when>
  1041. <xsl:otherwise>
  1042. <out:value-of select="xtsext:getBTD(string($updatedValue), $baseTextDirection, $productLocale)"/>
  1043. </xsl:otherwise>
  1044. </xsl:choose>
  1045. </out:otherwise>
  1046. </out:choose>
  1047. </out:variable>
  1048. <out:if test="$textDirection != ''">
  1049. <out:choose>
  1050. <out:when test="$textDirection = 'stt'">
  1051. <out:attribute name="dir">ltr</out:attribute>
  1052. </out:when>
  1053. <out:otherwise>
  1054. <out:attribute name="dir">
  1055. <out:value-of select="$textDirection"/>
  1056. </out:attribute>
  1057. </out:otherwise>
  1058. </out:choose>
  1059. <out:if test="$textDirection = 'stt' or $baseTextDirection = 'auto'">
  1060. <xsl:choose>
  1061. <xsl:when test="@onfocus">
  1062. <out:attribute name="onfocus">
  1063. <xsl:value-of select="concat('bidi.onfocus(this);',@onfocus)"/>
  1064. </out:attribute>
  1065. </xsl:when>
  1066. <xsl:otherwise>
  1067. <out:attribute name="onfocus">
  1068. <out:text>bidi.onfocus(this)</out:text>
  1069. </out:attribute>
  1070. </xsl:otherwise>
  1071. </xsl:choose>
  1072. </out:if>
  1073. </out:if>
  1074. <!-- handle children... -->
  1075. <xsl:apply-templates/>
  1076. <!-- update the control value, either from the query value, or the default... -->
  1077. <out:value-of select="$updatedValue"/>
  1078. </textarea>
  1079. </out:otherwise>
  1080. </out:choose>
  1081. </out:if>
  1082. </xsl:template>
  1083. <!-- ===================================================================== -->
  1084. <!-- ============== Select =================== -->
  1085. <xsl:template match="utml:select[namespace-uri() = $utml-namespace-uri]" priority="1">
  1086. <out:if test="true()">
  1087. <!-- add this here to define unique context for the variables below -->
  1088. <!-- determine if this ontrol needs to be rendered in read-only mode -->
  1089. <out:variable name="read-only">
  1090. <xsl:call-template name="get-utml-read-only">
  1091. <xsl:with-param name="node" select="."/>
  1092. </xsl:call-template>
  1093. </out:variable>
  1094. <!-- create variables for each default value in the comma delimited list... -->
  1095. <!--
  1096. TODO: ADD SUPPORT FOR SUBSTITUTION VARIABLES THAT CONTAIN A COMMA
  1097. DELIMITED LIST, AND LISTS OF COMMA DELIMITED SUBSTITUTION VARIABLES/PLAIN
  1098. TEXT ???
  1099. -->
  1100. <out:variable name="default-value">
  1101. <xsl:call-template name="get-utml-default-value">
  1102. <xsl:with-param name="node" select="."/>
  1103. </xsl:call-template>
  1104. </out:variable>
  1105. <!-- calculate the control name, this includes all dynamically generated name information... -->
  1106. <out:variable name="control-name">
  1107. <xsl:call-template name="get-utml-prefix">
  1108. <xsl:with-param name="node" select="."/>
  1109. </xsl:call-template>
  1110. <xsl:call-template name="get-utml-name">
  1111. <xsl:with-param name="node" select="."/>
  1112. </xsl:call-template>
  1113. </out:variable>
  1114. <!-- get the state of the tracking feature... -->
  1115. <xsl:variable name="track-changes">
  1116. <xsl:call-template name="get-utml-track">
  1117. <xsl:with-param name="node" select="."/>
  1118. </xsl:call-template>
  1119. </xsl:variable>
  1120. <out:choose>
  1121. <out:when test="$read-only = 'true' or $form-read-only = 'true'">
  1122. <xsl:apply-templates/>
  1123. </out:when>
  1124. <out:otherwise>
  1125. <xsl:if test="$track-changes = 'true'">
  1126. <script language="JavaScript">
  1127. function on_<out:value-of select="$control-name"/>_changed(){
  1128. document.<out:value-of select="$utml-form-name"/>.changed_<out:value-of select="$control-name"/>.value=&quot;1&quot;;
  1129. }
  1130. </script>
  1131. <out:variable name="hidden-control-name">
  1132. <out:value-of select="concat( 'changed_', $control-name )"/>
  1133. </out:variable>
  1134. <input type="hidden">
  1135. <out:attribute name="name">
  1136. <out:value-of select="$hidden-control-name"/>
  1137. </out:attribute>
  1138. <out:choose>
  1139. <out:when test="/root/env/param[@name = $hidden-control-name]">
  1140. <out:attribute name="value">
  1141. <out:value-of select="/root/env/param[@name = $hidden-control-name]"/>
  1142. </out:attribute>
  1143. </out:when>
  1144. <out:otherwise>
  1145. <out:attribute name="value">0</out:attribute>
  1146. </out:otherwise>
  1147. </out:choose>
  1148. </input>
  1149. </xsl:if>
  1150. <select>
  1151. <!-- copy all non-utml attributes... -->
  1152. <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
  1153. <!-- add the name attribute... -->
  1154. <out:attribute name="name">
  1155. <out:value-of select="$control-name"/>
  1156. </out:attribute>
  1157. <xsl:if test="$track-changes = 'true'">
  1158. <out:attribute name="onchange">
  1159. <out:text/>if(window.on_<out:value-of select="$control-name"/>_changed)window.on_<out:value-of select="$control-name"/>_changed();<out:text/>
  1160. <xsl:if test="@onchange">
  1161. <out:text/>
  1162. <xsl:value-of select="@onchange"/>
  1163. <out:text/>
  1164. </xsl:if>
  1165. </out:attribute>
  1166. </xsl:if>
  1167. <xsl:apply-templates/>
  1168. </select>
  1169. </out:otherwise>
  1170. </out:choose>
  1171. </out:if>
  1172. </xsl:template>
  1173. <!-- ===================================================================== -->
  1174. <!-- ============== Option =================== -->
  1175. <xsl:template match="utml:option[namespace-uri() = $utml-namespace-uri]" priority="1">
  1176. <out:if test="true()">
  1177. <!-- get the value ... -->
  1178. <out:variable name="value">
  1179. <xsl:call-template name="get-utml-value">
  1180. <xsl:with-param name="node" select="."/>
  1181. </xsl:call-template>
  1182. </out:variable>
  1183. <!-- get the update flag, this can only be text... -->
  1184. <xsl:variable name="update">
  1185. <xsl:call-template name="get-utml-update">
  1186. <xsl:with-param name="node" select="ancestor::*[name() = 'utml:select' and namespace-uri() = $utml-namespace-uri]"/>
  1187. </xsl:call-template>
  1188. </xsl:variable>
  1189. <out:choose>
  1190. <out:when test="$read-only = 'true' or $form-read-only = 'true'">
  1191. <xsl:choose>
  1192. <xsl:when test="$update != 'false'">
  1193. <out:choose>
  1194. <out:when test="string(/root/env/param[@name = $control-name]) = $value">
  1195. <xsl:apply-templates/>
  1196. </out:when>
  1197. <out:when test="not(/root/env/param[@name = $control-name])">
  1198. <out:if test="$value = $default-value">
  1199. <xsl:apply-templates/>
  1200. </out:if>
  1201. </out:when>
  1202. </out:choose>
  1203. </xsl:when>
  1204. <xsl:otherwise>
  1205. <out:if test="$value = $default-value">
  1206. <xsl:apply-templates/>
  1207. </out:if>
  1208. </xsl:otherwise>
  1209. </xsl:choose>
  1210. </out:when>
  1211. <out:otherwise>
  1212. <option>
  1213. <out:attribute name="value">
  1214. <out:value-of select="$value"/>
  1215. </out:attribute>
  1216. <!-- update the control value from the query value... -->
  1217. <xsl:choose>
  1218. <xsl:when test="$update != 'false'">
  1219. <out:choose>
  1220. <out:when test="/root/env/param[@name = $control-name] = string($value)">
  1221. <out:attribute name="selected">selected</out:attribute>
  1222. </out:when>
  1223. <out:when test="not(/root/env/param[@name = $control-name])">
  1224. <out:if test="string($value) = string($default-value)">
  1225. <out:attribute name="selected">selected</out:attribute>
  1226. </out:if>
  1227. </out:when>
  1228. </out:choose>
  1229. </xsl:when>
  1230. <xsl:otherwise>
  1231. <out:if test="string($value) = string($default-value)">
  1232. <out:attribute name="selected">selected</out:attribute>
  1233. </out:if>
  1234. </xsl:otherwise>
  1235. </xsl:choose>
  1236. <!-- handle children... -->
  1237. <xsl:apply-templates/>
  1238. </option>
  1239. </out:otherwise>
  1240. </out:choose>
  1241. </out:if>
  1242. </xsl:template>
  1243. <!-- ===================================================================== -->
  1244. <!-- ============== Radio =================== -->
  1245. <xsl:template match="utml:input[(@type = 'radio' or type = 'radio') and (namespace-uri() = $utml-namespace-uri)]" priority="1">
  1246. <out:if test="true()">
  1247. <!-- add this here to define unique context for the variables below -->
  1248. <!-- the button names should match that of the group so all group variables will need this prefix -->
  1249. <xsl:variable name="radio-prefix">
  1250. <xsl:choose>
  1251. <xsl:when test="@name"><xsl:value-of select="concat(@name, '-')"/></xsl:when>
  1252. <xsl:otherwise><xsl:value-of select="concat(ancestor::*[name() = 'utml:radio-group' and namespace-uri() = $utml-namespace-uri]/@name, '-')"/></xsl:otherwise>
  1253. </xsl:choose>
  1254. </xsl:variable>
  1255. <!-- get the value ... -->
  1256. <out:variable name="value">
  1257. <xsl:call-template name="get-utml-value">
  1258. <xsl:with-param name="node" select="."/>
  1259. </xsl:call-template>
  1260. </out:variable>
  1261. <!-- get the default condition that will be evaluated when the queryvalue isn't present... -->
  1262. <out:variable name="checked">
  1263. <xsl:call-template name="get-checked-state">
  1264. <xsl:with-param name="node" select="."/>
  1265. </xsl:call-template>
  1266. </out:variable>
  1267. <xsl:variable name="track-changes">
  1268. <xsl:call-template name="get-utml-track">
  1269. <xsl:with-param name="node" select="ancestor::*[name() = 'utml:radio-group' and namespace-uri() = $utml-namespace-uri] | ."/>
  1270. </xsl:call-template>
  1271. </xsl:variable>
  1272. <out:choose>
  1273. <out:when test="${$radio-prefix}read-only = 'true' or $form-read-only = 'true'">
  1274. <img role="radio" aria-disabled="true">
  1275. <xsl:copy-of select="@id"/>
  1276. <out:choose>
  1277. <out:when test="string(/root/env/param[@name = ${$radio-prefix}control-name]) = $value or $checked = 'true'">
  1278. <out:attribute name="src"><out:value-of select="$image_root"/>icon_disabled_radio_checked.gif</out:attribute>
  1279. <out:attribute name="aria-checked">true</out:attribute>
  1280. </out:when>
  1281. <xsl:if test="ancestor::*[name() = 'utml:radio-group' and namespace-uri() = $utml-namespace-uri]">
  1282. <out:when test="($value = ${$radio-prefix}default-value) and not(/root/env/param[@name = ${$radio-prefix}control-name])">
  1283. <out:attribute name="src"><out:value-of select="$image_root"/>icon_disabled_radio_checked.gif</out:attribute>
  1284. <out:attribute name="aria-checked">true</out:attribute>
  1285. </out:when>
  1286. </xsl:if>
  1287. <out:otherwise>
  1288. <out:attribute name="src"><out:value-of select="$image_root"/>icon_disabled_radio_unchecked.gif</out:attribute>
  1289. <out:attribute name="aria-checked">false</out:attribute>
  1290. </out:otherwise>
  1291. </out:choose>
  1292. </img>
  1293. </out:when>
  1294. <out:otherwise>
  1295. <input>
  1296. <!-- copy all non-utml attributes... -->
  1297. <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
  1298. <!-- calculate the control name, if it this guy isn't contained inside a utml:radio-group... -->
  1299. <xsl:choose>
  1300. <xsl:when test="not( ancestor::*[name() = 'utml:radio-group' and namespace-uri() = $utml-namespace-uri] )">
  1301. <out:variable name="{$radio-prefix}control-name">
  1302. <xsl:call-template name="get-utml-prefix">
  1303. <xsl:with-param name="node" select="."/>
  1304. </xsl:call-template>
  1305. <xsl:call-template name="get-utml-name">
  1306. <xsl:with-param name="node" select="."/>
  1307. </xsl:call-template>
  1308. </out:variable>
  1309. </xsl:when>
  1310. <xsl:otherwise>
  1311. <xsl:if test="$track-changes = 'true'">
  1312. <out:attribute name="onclick">
  1313. <out:text/>if(window.on_<out:value-of select="${$radio-prefix}control-name"/>_changed)window.on_<out:value-of select="${$radio-prefix}control-name"/>_changed();<out:text/>
  1314. <xsl:if test="@onclick">
  1315. <out:text/>
  1316. <xsl:value-of select="@onclick"/>
  1317. <out:text/>
  1318. </xsl:if>
  1319. </out:attribute>
  1320. </xsl:if>
  1321. </xsl:otherwise>
  1322. </xsl:choose>
  1323. <!-- get the update flag, this can only be text... -->
  1324. <xsl:variable name="update">
  1325. <xsl:call-template name="get-utml-update">
  1326. <xsl:with-param name="node" select="ancestor::*[name() = 'utml:radio-group' and namespace-uri() = $utml-namespace-uri]"/>
  1327. </xsl:call-template>
  1328. </xsl:variable>
  1329. <!-- add the name attribute, $control-name would have been generated by the utml:radio-group... -->
  1330. <out:attribute name="name">
  1331. <out:value-of select="${$radio-prefix}control-name"/>
  1332. </out:attribute>
  1333. <!-- add the type... -->
  1334. <out:attribute name="type">
  1335. <xsl:call-template name="get-utml-type">
  1336. <xsl:with-param name="node" select="."/>
  1337. </xsl:call-template>
  1338. </out:attribute>
  1339. <!-- add the value attribute... -->
  1340. <out:attribute name="value">
  1341. <out:value-of select="$value"/>
  1342. </out:attribute>
  1343. <!-- update the control value, either from the query value, or the default... -->
  1344. <xsl:if test="$update != 'false'">
  1345. <out:choose>
  1346. <out:when test="string(/root/env/param[@name = ${$radio-prefix}control-name]) = string($value)">
  1347. <out:attribute name="checked">checked</out:attribute>
  1348. </out:when>
  1349. <xsl:if test="ancestor::*[name() = 'utml:radio-group' and namespace-uri() = $utml-namespace-uri]">
  1350. <out:when test="(string($value) = string(${$radio-prefix}default-value)) and (not(/root/env/param[@name = ${$radio-prefix}control-name]) or string(/root/env/param[@name = ${$radio-prefix}control-name])='')">
  1351. <out:attribute name="checked">checked</out:attribute>
  1352. </out:when>
  1353. </xsl:if>
  1354. </out:choose>
  1355. </xsl:if>
  1356. <!-- handle children... -->
  1357. <xsl:apply-templates/>
  1358. </input>
  1359. </out:otherwise>
  1360. </out:choose>
  1361. </out:if>
  1362. </xsl:template>
  1363. <!-- ===================================================================== -->
  1364. <!-- ============== Radio Group =================== -->
  1365. <xsl:template match="utml:radio-group[namespace-uri() = $utml-namespace-uri]" priority="1">
  1366. <!--
  1367. unlike utml:select utml:radio-group doesn't generate a top level element, so we'll wrap it in an
  1368. xsl:if to deal with any potential scoping issues.
  1369. -->
  1370. <!--
  1371. determine if this ontrol needs to be rendered in read-only mode
  1372. All radio button children of a radio button group will use this to be rendered in read-only mode (disabled).
  1373. -->
  1374. <out:if test="true()">
  1375. <!-- this will prefix all the radio group variable so they have unique names -->
  1376. <xsl:variable name="radio-prefix">
  1377. <xsl:choose>
  1378. <xsl:when test="@name"><xsl:value-of select="concat(@name, '-')"/></xsl:when>
  1379. <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
  1380. </xsl:choose>
  1381. </xsl:variable>
  1382. <out:variable name="{$radio-prefix}read-only">
  1383. <xsl:call-template name="get-utml-read-only">
  1384. <xsl:with-param name="node" select="."/>
  1385. </xsl:call-template>
  1386. </out:variable>
  1387. <!-- calculate the control name, this includes all dynamically generated name information... -->
  1388. <out:variable name="{$radio-prefix}control-name">
  1389. <xsl:call-template name="get-utml-prefix">
  1390. <xsl:with-param name="node" select="."/>
  1391. </xsl:call-template>
  1392. <xsl:call-template name="get-utml-name">
  1393. <xsl:with-param name="node" select="."/>
  1394. </xsl:call-template>
  1395. </out:variable>
  1396. <!-- create a variable for the default value... -->
  1397. <out:variable name="{$radio-prefix}default-value">
  1398. <xsl:call-template name="get-utml-default-value">
  1399. <xsl:with-param name="node" select="."/>
  1400. </xsl:call-template>
  1401. </out:variable>
  1402. <!-- get the state of the tracking feature... -->
  1403. <xsl:variable name="track-changes">
  1404. <xsl:call-template name="get-utml-track">
  1405. <xsl:with-param name="node" select="."/>
  1406. </xsl:call-template>
  1407. </xsl:variable>
  1408. <out:if test="${$radio-prefix}read-only != 'true' and $form-read-only != 'true'">
  1409. <xsl:if test="$track-changes = 'true'">
  1410. <script language="JavaScript">
  1411. function on_<out:value-of select="${$radio-prefix}control-name"/>_changed(){
  1412. document.<out:value-of select="$utml-form-name"/>.changed_<out:value-of select="${$radio-prefix}control-name"/>.value=&quot;1&quot;;
  1413. }
  1414. </script>
  1415. <out:variable name="{$radio-prefix}hidden-control-name">
  1416. <out:value-of select="concat( 'changed_', ${$radio-prefix}control-name )"/>
  1417. </out:variable>
  1418. <input type="hidden">
  1419. <out:attribute name="name">
  1420. <out:value-of select="${$radio-prefix}hidden-control-name"/>
  1421. </out:attribute>
  1422. <out:choose>
  1423. <out:when test="/root/env/param[@name = ${$radio-prefix}hidden-control-name]">
  1424. <out:attribute name="value">
  1425. <out:value-of select="/root/env/param[@name = ${$radio-prefix}hidden-control-name]"/>
  1426. </out:attribute>
  1427. </out:when>
  1428. <out:otherwise>
  1429. <out:attribute name="value">0</out:attribute>
  1430. </out:otherwise>
  1431. </out:choose>
  1432. </input>
  1433. </xsl:if>
  1434. </out:if>
  1435. <xsl:apply-templates/>
  1436. </out:if>
  1437. </xsl:template>
  1438. <!--
  1439. =============================================================================
  1440. Change - a control used to track changes to properties.
  1441. =============================================================================
  1442. -->
  1443. <xsl:template match="utml:change[namespace-uri() = $utml-namespace-uri]" priority="1">
  1444. <!-- Limit the scope of variables declared with <out:variable>. -->
  1445. <out:if test="true()">
  1446. <!-- Get the name of the hidden field. -->
  1447. <out:variable name="hidden-control-name">
  1448. <xsl:call-template name="get-utml-prefix">
  1449. <xsl:with-param name="node" select="."/>
  1450. </xsl:call-template>
  1451. <xsl:call-template name="get-utml-name">
  1452. <xsl:with-param name="node" select="."/>
  1453. </xsl:call-template>
  1454. </out:variable>
  1455. <!-- Get the default value for this flag. -->
  1456. <out:variable name="value">
  1457. <xsl:call-template name="get-utml-value">
  1458. <xsl:with-param name="node" select="."/>
  1459. </xsl:call-template>
  1460. </out:variable>
  1461. <!-- Get the value for the update flag. -->
  1462. <xsl:variable name="update">
  1463. <xsl:call-template name="get-utml-update">
  1464. <xsl:with-param name="node" select="."/>
  1465. </xsl:call-template>
  1466. </xsl:variable>
  1467. <!-- Get the default condition expression. -->
  1468. <xsl:variable name="default-condition">
  1469. <xsl:call-template name="get-utml-default-condition">
  1470. <xsl:with-param name="node" select="."/>
  1471. </xsl:call-template>
  1472. </xsl:variable>
  1473. <!-- Get the override condition. -->
  1474. <xsl:variable name="override-condition">
  1475. <xsl:call-template name="get-utml-condition">
  1476. <xsl:with-param name="node" select="."/>
  1477. </xsl:call-template>
  1478. </xsl:variable>
  1479. <script language="JavaScript">
  1480. function on_<out:value-of select="$hidden-control-name"/>_changed() {
  1481. document.<out:value-of select="$utml-form-name"/>.<out:value-of select="$hidden-control-name"/>.value = &apos;1&apos;;
  1482. }
  1483. </script>
  1484. <input type="hidden">
  1485. <out:attribute name="name"><out:value-of select="$hidden-control-name"/></out:attribute>
  1486. <!-- Update the value attribute, either from the query-values or using the default condition. -->
  1487. <xsl:choose>
  1488. <xsl:when test="$update = 'false'">
  1489. <xsl:choose>
  1490. <xsl:when test="$override-condition != ''">
  1491. <out:choose>
  1492. <out:when>
  1493. <xsl:attribute name="test"><xsl:value-of select="$override-condition"/></xsl:attribute>
  1494. <out:attribute name="value">1</out:attribute>
  1495. </out:when>
  1496. <out:otherwise>
  1497. <out:attribute name="value">0</out:attribute>
  1498. </out:otherwise>
  1499. </out:choose>
  1500. </xsl:when>
  1501. <xsl:otherwise>
  1502. <out:attribute name="value"><out:value-of select="$value"/></out:attribute>
  1503. </xsl:otherwise>
  1504. </xsl:choose>
  1505. </xsl:when>
  1506. <xsl:otherwise>
  1507. <out:choose>
  1508. <out:when test="/root/env/param[@name = $hidden-control-name]">
  1509. <out:attribute name="value"><out:value-of select="/root/env/param[@name = $hidden-control-name]"/></out:attribute>
  1510. </out:when>
  1511. <xsl:if test="$default-condition != ''">
  1512. <out:when>
  1513. <xsl:attribute name="test"><xsl:value-of select="$default-condition"/></xsl:attribute>
  1514. <out:attribute name="value">1</out:attribute>
  1515. </out:when>
  1516. </xsl:if>
  1517. <out:otherwise>
  1518. <out:attribute name="value"><out:value-of select="$value"/></out:attribute>
  1519. </out:otherwise>
  1520. </out:choose>
  1521. </xsl:otherwise>
  1522. </xsl:choose>
  1523. </input>
  1524. </out:if>
  1525. </xsl:template>
  1526. <xsl:template name="get-utml-condition">
  1527. <xsl:param name="node"/>
  1528. <xsl:choose>
  1529. <xsl:when test="$node/@utml:condition">
  1530. <xsl:value-of select="$node/@utml:condition"/>
  1531. </xsl:when>
  1532. <xsl:when test="$node/utml:condition">
  1533. <xsl:value-of select="$node/utml:condition/child::text()"/>
  1534. </xsl:when>
  1535. </xsl:choose>
  1536. </xsl:template>
  1537. <!--
  1538. Description: Retrieve the utml:prefix attribute or child element from the given node.
  1539. -->
  1540. <xsl:template name="get-utml-prefix">
  1541. <xsl:param name="node"/>
  1542. <xsl:choose>
  1543. <xsl:when test="$node/@utml:prefix">
  1544. <out:text/>
  1545. <xsl:value-of select="$node/@utml:prefix"/>
  1546. <out:text/>
  1547. </xsl:when>
  1548. <xsl:when test="$node/utml:prefix">
  1549. <out:text/>
  1550. <xsl:copy-of select="$node/utml:prefix/child::node()"/>
  1551. <out:text/>
  1552. </xsl:when>
  1553. </xsl:choose>
  1554. </xsl:template>
  1555. <!--
  1556. Description: Retrieve the type attribute or the utml:type child element from the given node. Currently type can only be plain
  1557. text (no substitutions!), any markup given in child utml:type element will be ignored.
  1558. -->
  1559. <xsl:template name="get-utml-type">
  1560. <xsl:param name="node"/>
  1561. <xsl:choose>
  1562. <xsl:when test="$node/@type">
  1563. <out:text/>
  1564. <xsl:value-of select="$node/@type"/>
  1565. <out:text/>
  1566. </xsl:when>
  1567. <xsl:when test="$node/utml:type">
  1568. <out:text/>
  1569. <xsl:copy-of select="$node/utml:type/child::text()"/>
  1570. <out:text/>
  1571. </xsl:when>
  1572. </xsl:choose>
  1573. </xsl:template>
  1574. <!--
  1575. Description: retrieve the name attribute or child utml:name element from the given node.
  1576. -->
  1577. <xsl:template name="get-utml-name">
  1578. <xsl:param name="node"/>
  1579. <xsl:choose>
  1580. <xsl:when test="$node/@name">
  1581. <out:text/>
  1582. <xsl:value-of select="$node/@name"/>
  1583. <out:text/>
  1584. </xsl:when>
  1585. <xsl:when test="$node/utml:name">
  1586. <out:text/>
  1587. <xsl:copy-of select="$node/utml:name/child::node()"/>
  1588. <out:text/>
  1589. </xsl:when>
  1590. </xsl:choose>
  1591. </xsl:template>
  1592. <!--
  1593. Description: retrieve the read-only attribute or child utml:read-only element from the given node.
  1594. -->
  1595. <xsl:template name="get-utml-read-only">
  1596. <xsl:param name="node"/>
  1597. <xsl:choose>
  1598. <xsl:when test="$node/@utml:read-only">
  1599. <xsl:value-of select="$node/@utml:read-only"/>
  1600. </xsl:when>
  1601. <xsl:when test="$node/utml:read-only">
  1602. <out:text/>
  1603. <xsl:copy-of select="$node/utml:read-only/child::node()"/>
  1604. <out:text/>
  1605. </xsl:when>
  1606. <xsl:otherwise>
  1607. <out:text/>
  1608. <xsl:value-of select="'false'"/>
  1609. <out:text/>
  1610. </xsl:otherwise>
  1611. </xsl:choose>
  1612. </xsl:template>
  1613. <!--
  1614. Description: retrieve the hide-when-read-only attribute or child utml:hide-when-read-only element from the given node.
  1615. -->
  1616. <xsl:template name="get-utml-hide-when-read-only">
  1617. <xsl:param name="node"/>
  1618. <xsl:choose>
  1619. <xsl:when test="$node/@utml:hide-when-read-only">
  1620. <xsl:value-of select="$node/@utml:hide-when-read-only"/>
  1621. </xsl:when>
  1622. <xsl:when test="$node/utml:hide-when-read-only">
  1623. <out:text/>
  1624. <xsl:copy-of select="$node/utml:hide-when-read-only/child::node()"/>
  1625. <out:text/>
  1626. </xsl:when>
  1627. <xsl:otherwise>
  1628. <out:text/>
  1629. <xsl:value-of select="'false'"/>
  1630. <out:text/>
  1631. </xsl:otherwise>
  1632. </xsl:choose>
  1633. </xsl:template>
  1634. <!--
  1635. Description: retrieve the utml:unique-id attribute or child element from the given node.
  1636. -->
  1637. <xsl:template name="get-utml-unique-id">
  1638. <xsl:param name="node"/>
  1639. <xsl:choose>
  1640. <xsl:when test="$node/@unique-id">
  1641. <out:text/>
  1642. <xsl:value-of select="$node/@unique-id"/>
  1643. <out:text/>
  1644. </xsl:when>
  1645. <xsl:when test="$node/utml:unique-id">
  1646. <out:text/>
  1647. <xsl:copy-of select="$node/utml:unique-id/child::node()"/>
  1648. <out:text/>
  1649. </xsl:when>
  1650. </xsl:choose>
  1651. </xsl:template>
  1652. <!--
  1653. Description: retrieve the value attribute or the utml:value child element from the given node.
  1654. -->
  1655. <xsl:template name="get-utml-value">
  1656. <xsl:param name="node"/>
  1657. <xsl:choose>
  1658. <xsl:when test="$node/@value">
  1659. <out:text/>
  1660. <xsl:value-of select="$node/@value"/>
  1661. <out:text/>
  1662. </xsl:when>
  1663. <xsl:when test="$node/utml:value">
  1664. <out:text/>
  1665. <xsl:copy-of select="$node/utml:value/child::node()"/>
  1666. <out:text/>
  1667. </xsl:when>
  1668. </xsl:choose>
  1669. </xsl:template>
  1670. <!--
  1671. Description: retrieve the utml:update attribute or child element from the given node. Currently update can only be plain
  1672. text (no substitutions!), any markup given in child utml:update element will be ignored.
  1673. -->
  1674. <xsl:template name="get-utml-update">
  1675. <xsl:param name="node"/>
  1676. <xsl:choose>
  1677. <xsl:when test="$node/@utml:update">
  1678. <out:text/>
  1679. <xsl:value-of select="$node/@utml:update"/>
  1680. <out:text/>
  1681. </xsl:when>
  1682. <xsl:when test="$node/utml:update">
  1683. <out:text/>
  1684. <xsl:copy-of select="$node/utml:update/child::text()"/>
  1685. <out:text/>
  1686. </xsl:when>
  1687. </xsl:choose>
  1688. </xsl:template>
  1689. <!--
  1690. Description: retrieve the utml:default-value attribute or child element from the given node.
  1691. -->
  1692. <xsl:template name="get-utml-default-value">
  1693. <xsl:param name="node"/>
  1694. <xsl:choose>
  1695. <xsl:when test="$node/@utml:default-value">
  1696. <out:text/>
  1697. <xsl:value-of select="$node/@utml:default-value"/>
  1698. <out:text/>
  1699. </xsl:when>
  1700. <xsl:when test="$node/@default-value">
  1701. <out:text/>
  1702. <xsl:value-of select="$node/@default-value"/>
  1703. <out:text/>
  1704. </xsl:when>
  1705. <xsl:when test="$node/utml:default-value">
  1706. <out:text/>
  1707. <xsl:copy-of select="$node/utml:default-value/child::node()"/>
  1708. <out:text/>
  1709. </xsl:when>
  1710. </xsl:choose>
  1711. </xsl:template>
  1712. <!--
  1713. Description: retrieve the utml:onclick attribute or child element from the given node.
  1714. -->
  1715. <xsl:template name="get-utml-onclick">
  1716. <xsl:param name="node"/>
  1717. <xsl:choose>
  1718. <xsl:when test="$node/@onclick">
  1719. <out:text/>
  1720. <xsl:value-of select="$node/@onclick"/>
  1721. <out:text/>
  1722. </xsl:when>
  1723. <xsl:when test="$node/utml:onclick">
  1724. <out:text/>
  1725. <xsl:copy-of select="$node/utml:onclick/child::node()"/>
  1726. <out:text/>
  1727. </xsl:when>
  1728. </xsl:choose>
  1729. </xsl:template>
  1730. <!--
  1731. Description: retrieve the target attribute or utml:target child element from the given node.
  1732. -->
  1733. <xsl:template name="get-utml-target">
  1734. <xsl:param name="node"/>
  1735. <xsl:choose>
  1736. <xsl:when test="$node/@utml:target">
  1737. <out:text/>
  1738. <xsl:value-of select="$node/@utml:target"/>
  1739. <out:text/>
  1740. </xsl:when>
  1741. <xsl:when test="$node/utml:target">
  1742. <out:text/>
  1743. <xsl:copy-of select="$node/utml:target/child::node()"/>
  1744. <out:text/>
  1745. </xsl:when>
  1746. </xsl:choose>
  1747. </xsl:template>
  1748. <!--
  1749. Description: retrieve the target attribute or utml:target child element from the given node.
  1750. -->
  1751. <xsl:template name="get-target">
  1752. <xsl:param name="node"/>
  1753. <xsl:choose>
  1754. <xsl:when test="$node/@target">
  1755. <out:text/>
  1756. <xsl:value-of select="$node/@target"/>
  1757. <out:text/>
  1758. </xsl:when>
  1759. <xsl:when test="$node/utml:target">
  1760. <out:text/>
  1761. <xsl:copy-of select="$node/utml:target/child::node()"/>
  1762. <out:text/>
  1763. </xsl:when>
  1764. </xsl:choose>
  1765. </xsl:template>
  1766. <!--
  1767. Description: retrieve the submit attribute or utml:submit child element from the given node.
  1768. -->
  1769. <xsl:template name="get-utml-submit">
  1770. <xsl:param name="node"/>
  1771. <xsl:choose>
  1772. <xsl:when test="$node/@utml:submit">
  1773. <out:text/>
  1774. <xsl:value-of select="$node/@utml:submit"/>
  1775. <out:text/>
  1776. </xsl:when>
  1777. <xsl:when test="$node/utml:submit">
  1778. <out:text/>
  1779. <xsl:copy-of select="$node/utml:submit/child::node()"/>
  1780. <out:text/>
  1781. </xsl:when>
  1782. </xsl:choose>
  1783. </xsl:template>
  1784. <!--
  1785. Description: retrieve the utml:validate attribute or utml:validate child element from the given node.
  1786. -->
  1787. <xsl:template name="get-utml-validate">
  1788. <xsl:param name="node"/>
  1789. <xsl:choose>
  1790. <xsl:when test="$node/@utml:validate">
  1791. <out:text/>
  1792. <xsl:value-of select="$node/@utml:validate"/>
  1793. <out:text/>
  1794. </xsl:when>
  1795. <xsl:when test="$node/utml:validate">
  1796. <out:text/>
  1797. <xsl:copy-of select="$node/utml:validate/child::node()"/>
  1798. <out:text/>
  1799. </xsl:when>
  1800. </xsl:choose>
  1801. </xsl:template>
  1802. <!--
  1803. Description: retrieve the checked state
  1804. -->
  1805. <xsl:template name="get-checked-state">
  1806. <xsl:param name="node"/>
  1807. <xsl:choose>
  1808. <xsl:when test="$node/@checked = 'checked' or $node/@checked = 'true'">
  1809. <xsl:text/>true<xsl:text/>
  1810. </xsl:when>
  1811. <xsl:otherwise>
  1812. <xsl:text/>false<xsl:text/>
  1813. </xsl:otherwise>
  1814. </xsl:choose>
  1815. </xsl:template>
  1816. <!--
  1817. Description: retrieve the default-condition attribute or child utml:default-condition element from the given node.
  1818. -->
  1819. <xsl:template name="get-utml-default-condition">
  1820. <xsl:param name="node"/>
  1821. <xsl:choose>
  1822. <xsl:when test="$node/@utml:default-condition">
  1823. <out:text/>
  1824. <xsl:value-of select="$node/@utml:default-condition"/>
  1825. <out:text/>
  1826. </xsl:when>
  1827. <xsl:when test="$node/utml:default-condition">
  1828. <out:text/>
  1829. <xsl:copy-of select="$node/utml:default-condition/child::node()"/>
  1830. <out:text/>
  1831. </xsl:when>
  1832. </xsl:choose>
  1833. </xsl:template>
  1834. <!--
  1835. Description: retrieves the value of the utml:track attribute or child utml:track element
  1836. from the given node.
  1837. -->
  1838. <xsl:template name="get-utml-track">
  1839. <xsl:param name="node"/>
  1840. <xsl:choose>
  1841. <xsl:when test="$node/@utml:track">
  1842. <xsl:text/>
  1843. <xsl:value-of select="$node/@utml:track"/>
  1844. <xsl:text/>
  1845. </xsl:when>
  1846. <xsl:when test="$node/utml:track">
  1847. <xsl:text/>
  1848. <xsl:copy-of select="$node/utml:track/child::node()"/>
  1849. <xsl:text/>
  1850. </xsl:when>
  1851. <xsl:otherwise>
  1852. <!-- By default, this feature is disabled. -->
  1853. <xsl:text>false</xsl:text>
  1854. </xsl:otherwise>
  1855. </xsl:choose>
  1856. </xsl:template>
  1857. <!--
  1858. Description: retrieves the value of the utml:uncheckedValue. This is used for checkboxes that need
  1859. to return a value even when the checkbox is unchecked
  1860. -->
  1861. <xsl:template name="get-utml-unchecked-value">
  1862. <xsl:param name="node"/>
  1863. <xsl:choose>
  1864. <xsl:when test="$node/@utml:uncheckedValue">
  1865. <xsl:value-of select="$node/@utml:uncheckedValue"/>
  1866. </xsl:when>
  1867. <xsl:when test="$node/utml:uncheckedValue">
  1868. <xsl:copy-of select="$node/utml:uncheckedValue/child::node()"/>
  1869. </xsl:when>
  1870. </xsl:choose>
  1871. </xsl:template>
  1872. <!--
  1873. Description: retrieve the href attribute or child utml:href element from the given node.
  1874. -->
  1875. <xsl:template name="get-utml-href">
  1876. <xsl:param name="node"/>
  1877. <xsl:choose>
  1878. <xsl:when test="$node/@href">
  1879. <out:text/>
  1880. <xsl:value-of select="$node/@href"/>
  1881. <out:text/>
  1882. </xsl:when>
  1883. <xsl:when test="$node/utml:href">
  1884. <out:text/>
  1885. <xsl:copy-of select="$node/utml:href/child::node()"/>
  1886. <out:text/>
  1887. </xsl:when>
  1888. </xsl:choose>
  1889. </xsl:template>
  1890. <!--
  1891. Description: retrieve the defaultKey attribute only.
  1892. -->
  1893. <xsl:template name="get-utml-defaultKey">
  1894. <xsl:param name="node"/>
  1895. <xsl:choose>
  1896. <xsl:when test="$node/@utml:defaultKey">
  1897. <out:text/>
  1898. <xsl:value-of select="$node/@utml:defaultKey"/>
  1899. <out:text/>
  1900. </xsl:when>
  1901. <xsl:when test="$node/utml:defaultKey">
  1902. <out:text/>
  1903. <xsl:copy-of select="$node/utml:defaultKey/child::node()"/>
  1904. <out:text/>
  1905. </xsl:when>
  1906. </xsl:choose>
  1907. </xsl:template>
  1908. <!--
  1909. Description: retrieve the defaultAct child utml:defaultAct element from the given node.
  1910. -->
  1911. <xsl:template name="get-utml-defaultAct">
  1912. <xsl:param name="node"/>
  1913. <xsl:choose>
  1914. <xsl:when test="$node/@utml:defaultAct">
  1915. <out:text/>
  1916. <xsl:value-of select="$node/@utml:defaultAct"/>
  1917. <out:text/>
  1918. </xsl:when>
  1919. <xsl:when test="$node/utml:defaultAct">
  1920. <out:text/>
  1921. <xsl:copy-of select="$node/utml:defaultAct/child::node()"/>
  1922. <out:text/>
  1923. </xsl:when>
  1924. </xsl:choose>
  1925. </xsl:template>
  1926. <!-- the main engine -->
  1927. <xsl:template match="*[namespace-uri() = $utml-namespace-uri]" priority="0"/>
  1928. <xsl:template match="*">
  1929. <xsl:copy>
  1930. <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
  1931. <xsl:apply-templates/>
  1932. </xsl:copy>
  1933. </xsl:template>
  1934. <!--
  1935. utml:textbox
  1936. type
  1937. name
  1938. value
  1939. utml:default-value
  1940. -->
  1941. <!-- theoretically the simplest template -->
  1942. <xsl:template match="utml:comment"/>
  1943. <!-- debug information -->
  1944. <xsl:template match="utml:dump-state">
  1945. <table cellpadding="2" cellspacing="3" border="0" width="100%" bgcolor="#FFFFFF">
  1946. <tr bgcolor="#3333FF">
  1947. <td colspan="2">
  1948. <font face="arial" size="4" color="#FFFFFF">
  1949. query-values
  1950. </font>
  1951. </td>
  1952. </tr>
  1953. <tr bgcolor="#CCCCFF">
  1954. <td>
  1955. <font face="arial" size="2">
  1956. <b>name</b>
  1957. </font>
  1958. </td>
  1959. <td>
  1960. <font face="arial" size="2">
  1961. <b>value</b>
  1962. </font>
  1963. </td>
  1964. </tr>
  1965. <out:for-each select="/root/env/param">
  1966. <out:sort select="@name"/>
  1967. <tr bgcolor="#CCCCCC">
  1968. <td>
  1969. <font face="arial" size="2">
  1970. <out:value-of select="@name"/>
  1971. </font>
  1972. </td>
  1973. <td>
  1974. <font face="arial" size="2">
  1975. <out:value-of select="."/>
  1976. </font>
  1977. </td>
  1978. </tr>
  1979. </out:for-each>
  1980. </table>
  1981. </xsl:template>
  1982. </xsl:stylesheet>