cps-formlogic.xslt 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  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. <!-- $Header: //cpscrn/main/templates/cps4/producer/logicsheets/cps-formlogic.xslt#1 $ -->
  13. <!-- $DateTime: 2008/10/22 11:12:04 $ -->
  14. <!-- $Change: 25109 $ -->
  15. <xsl:stylesheet version="1.0"
  16. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  17. xmlns:out="dummy-uri"
  18. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  19. xmlns:utml="http://developer.cognos.com/schemas/cps/logic/form/1/">
  20. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  21. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  22. <xsl:variable name="utml-namespace-uri" select="'http://developer.cognos.com/schemas/cps/logic/form/1/'"/>
  23. <xsl:variable name="utml-nav-stack-delimiter" select="'*'"/>
  24. <xsl:variable name="utml-nav-stack-mode-delimiter" select="'|'"/>
  25. <!--
  26. List of supported tags (see each template for details):
  27. utml:form
  28. utml:form-submit
  29. utml:rewrite-render
  30. utml:input
  31. utml:textarea
  32. utml:radio-group
  33. utml:select
  34. utml:option
  35. utml:a
  36. utml:group
  37. utml:variables
  38. -->
  39. <!-- =========================================================== -->
  40. <!-- ========================= form ============================ -->
  41. <!-- =========================================================== -->
  42. <!--
  43. Just like formlogic formlogic lite will add evironment variables as
  44. that aren't in the current page as utml fields as hidden inputs
  45. - you can have fields not add a hidden input by defining an exclude or exclude prefix
  46. <utml:form ...
  47. <utml:exclude>excludefieldname</utml:exclude>
  48. <utml:exclude-prefix>excludeprefix</utml:excludeprefix>
  49. -->
  50. <xsl:template match="utml:form" priority="1">
  51. <form>
  52. <!-- copy non-utml attributes... -->
  53. <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
  54. <!-- define the delimiter so we know how tot get the tarked from the stack string -->
  55. <out:variable name="stack-down-target">
  56. <out:choose>
  57. <out:when test="contains( key('utml-key-params', 'edit_stack'), '{$utml-nav-stack-delimiter}')">
  58. <out:value-of select="substring-before( key('utml-key-params', 'edit_stack'), '{$utml-nav-stack-delimiter}' )"/>
  59. </out:when>
  60. <out:otherwise>
  61. <out:value-of select="key('utml-key-params', 'edit_stack')"/>
  62. </out:otherwise>
  63. </out:choose>
  64. </out:variable>
  65. <xsl:variable name="formName"><xsl:value-of select="@name"/></xsl:variable>
  66. <out:variable name="{$formName}form">
  67. <xsl:copy-of select="utml:read-only/child::node()"/>
  68. </out:variable>
  69. <!-- handle children... -->
  70. <xsl:apply-templates/>
  71. <!-- this will get all the current utml inputs -->
  72. <xsl:variable name="existence-test-string">
  73. <xsl:for-each select="//utml:input[not(@type = 'button') and not( (@type = 'radio') and ancestor::*[name() = 'utml:radio-group'] )] | //utml:textarea | //utml:select | //utml:radio-group">
  74. <xsl:text/> and @name != '<xsl:value-of select="./@name"/>' <xsl:text/>
  75. </xsl:for-each>
  76. <xsl:for-each select="//utml:form/utml:exclude">
  77. <xsl:text/> and @name != '<xsl:value-of select="."/>' <xsl:text/>
  78. </xsl:for-each>
  79. </xsl:variable>
  80. <!-- this will allow you to specigy a prefix to exclude hidden inputs for -->
  81. <xsl:variable name="exclude-prefixes">
  82. <xsl:for-each select=".//utml:exclude-prefix">
  83. <xsl:text>starts-with(@name, '</xsl:text>
  84. <xsl:value-of select="."/>
  85. <xsl:text>') or </xsl:text>
  86. </xsl:for-each>
  87. <xsl:text>false()</xsl:text>
  88. </xsl:variable>
  89. <!-- loop through the environment and add hidden inputs for unused info to be passed along -->
  90. <out:for-each select="$utml-params[not({$exclude-prefixes})]">
  91. <out:if test="@name != '' {$existence-test-string}">
  92. <input type="hidden">
  93. <xsl:attribute name="name"><xsl:value-of select="'{@name}'"/></xsl:attribute>
  94. <xsl:attribute name="value"><xsl:value-of select="'{.}'"/></xsl:attribute>
  95. </input>
  96. </out:if>
  97. </out:for-each>
  98. <!-- Comma-delimited list of template names representing a set of stacked dialogs resulting from a "push" or a "stack-up" navigation operations. -->
  99. <xsl:if test="not(//utml:input[@name = 'edit_stack'])">
  100. <out:if test="not( key('utml-key-params', 'edit_stack') )">
  101. <input type="hidden" name="edit_stack" value=""/>
  102. </out:if>
  103. </xsl:if>
  104. <!-- The name of the current template. This is used by formlogic-init to determine where we came from to update the navigation stack. -->
  105. <xsl:if test="not(//utml:input[@name = 'edit_mode'])">
  106. <out:if test="not( key('utml-key-params', 'edit_mode') )">
  107. <input type="hidden" name="edit_mode" value=""/>
  108. </out:if>
  109. </xsl:if>
  110. <xsl:if test="not(//utml:input[@name = 'edit_name'])">
  111. <out:if test="not( key('utml-key-params', 'edit_name') )">
  112. <input type="hidden" name="edit_name">
  113. <out:attribute name="value">
  114. <out:value-of select="$utml-mode"/>
  115. <out:text>|edit</out:text>
  116. </out:attribute>
  117. </input>
  118. </out:if>
  119. </xsl:if>
  120. <xsl:if test="not(//utml:input[@name = 'edit_visited'])">
  121. <out:if test="not( key('utml-key-params', 'edit_visited') )">
  122. <input type="hidden" name="edit_visited" value="true"/>
  123. </out:if>
  124. </xsl:if>
  125. <xsl:if test="@utml:escape-prefix != ''">
  126. <out:if test="{ @utml:escape-prefix } != ''">
  127. <script language="javascript">
  128. function <xsl:value-of select="@name"/>_escape_fields() {
  129. var prefix = "<out:value-of select="{ @utml:escape-prefix }"/>";
  130. var c = document.<xsl:value-of select="@name"/>.elements.length;
  131. var i;
  132. for (i=0; i &lt; c; i++) {
  133. var e = document.<xsl:value-of select="@name"/>.elements[i];
  134. if (e.name.substring(0, prefix.length) == prefix) {
  135. var s = e.name.substring(prefix.length);
  136. var c2 = document.<xsl:value-of select="@name"/>.elements.length;
  137. var i2;
  138. for (i2=0; i2&lt;c2; i2++) {
  139. var e2 = document.<xsl:value-of select="@name"/>.elements[i2];
  140. if (e2.name == s) {
  141. e.value = <xsl:value-of select="@name"/>_urlUnicodeEncode( e2.value );
  142. }
  143. }
  144. }
  145. }
  146. }
  147. function <xsl:value-of select="@name"/>_urlUnicodeEncode( str ) {
  148. var len = str.length;
  149. var out = "";
  150. var i;
  151. for (i = 0; i &lt; len; i++) {
  152. var c = str.charCodeAt( i );
  153. if (c == 0x25) {
  154. out += "%%";
  155. } else if (c &lt;= 0x7f) {
  156. out += str.charAt( i );
  157. } else {
  158. var e = c.toString( 16 );
  159. out += "%u" + ("0000" + e).substring(e.length);
  160. }
  161. }
  162. return out;
  163. }
  164. </script>
  165. </out:if>
  166. </xsl:if>
  167. <xsl:if test="@utml:maintainPrevNavState = 'true'">
  168. <out:if test="not( key('utml-key-params', 'edit_navState') )">
  169. <out:variable name="utml-navState">
  170. <out:for-each select="$utml-params">
  171. <out:text>&lt;param name="</out:text>
  172. <out:value-of select="@name"/>
  173. <out:text>"></out:text>
  174. <out:value-of select="xtsext:xmlencode(string(.))"/>
  175. <out:text>&lt;/param></out:text>
  176. </out:for-each>
  177. </out:variable>
  178. <input type="hidden" name="edit_navState" value="{ '{ xtsext:validator(&quot;prepare&quot;,&quot;edit_navState&quot;,xtsext:base64encode( string( $utml-navState ), true() )) }' }"/>
  179. </out:if>
  180. </xsl:if>
  181. </form>
  182. </xsl:template>
  183. <!-- =========================================================== -->
  184. <!-- ====================== form-subit ========================= -->
  185. <!-- =========================================================== -->
  186. <!--
  187. <utml:form-submit
  188. utml:formName = "the-form-name" mandatory
  189. utml:targetPage = "the-sub-mode" default: <blank> values: ...
  190. utml:mode = "the-wsrp-mode" default: <blank> values: wsrp:view, wsrp:edit, wsrp:help, wsrp:preview, cps:config
  191. utml:operation = "the-wsrp-interactionState" default: <blank> values: pop, drop, maintain, ...
  192. utml:urlType = "the-wsrp-urlType" default: blockingAction values: render, blockingAction
  193. utml:validate = "true|false"/> default: false
  194. -->
  195. <xsl:template match="utml:form-submit" name="utml-gen-form-submit" priority="1">
  196. <xsl:param name="formName">
  197. <xsl:choose>
  198. <xsl:when test="@utml:formName">
  199. <xsl:value-of select="@utml:formName"/>
  200. </xsl:when>
  201. <xsl:when test="ancestor::utml:form">
  202. <xsl:value-of select="ancestor::utml:form/@name"/>
  203. </xsl:when>
  204. <xsl:otherwise>
  205. <xsl:message terminate="yes">UTML ERROR: can't find the embedded form name.</xsl:message>
  206. </xsl:otherwise>
  207. </xsl:choose>
  208. </xsl:param>
  209. <xsl:param name="targetPage" select="@utml:targetPage"/>
  210. <xsl:param name="operation" select="@utml:operation"/>
  211. <xsl:param name="validate" select="@utml:validate"/>
  212. <xsl:param name="mode" select="@utml:mode"/>
  213. <xsl:param name="urlType" select="@utml:urlType"/>
  214. <xsl:if test="$operation = 'pop' or $operation = 'drop'">
  215. <out:variable name="stack-down-target{generate-id()}">
  216. <out:choose>
  217. <out:when test="contains( key('utml-key-params', 'edit_stack'), '{$utml-nav-stack-delimiter}')">
  218. <out:value-of select="substring-before( key('utml-key-params', 'edit_stack'), '{$utml-nav-stack-delimiter}' )"/>
  219. </out:when>
  220. <out:otherwise>
  221. <out:value-of select="key('utml-key-params', 'edit_stack')"/>
  222. </out:otherwise>
  223. </out:choose>
  224. </out:variable>
  225. </xsl:if>
  226. <xsl:if test="$validate = 'true'">
  227. <xsl:text>
  228. if ( window.wsrp_rewrite_validate ) {
  229. if ( !wsrp_rewrite_validate() ) {
  230. return;
  231. }
  232. }
  233. </xsl:text>
  234. </xsl:if>
  235. <xsl:text>
  236. if ( window.wsrp_rewrite_presubmit ) {
  237. wsrp_rewrite_presubmit('</xsl:text>
  238. <xsl:value-of select="$operation"/>
  239. <xsl:text>');
  240. }
  241. </xsl:text>
  242. <xsl:if test="//utml:form[@name = $formName]/@utml:escape-prefix">
  243. <out:if test="{ //utml:form[@name = $formName]/@utml:escape-prefix }">
  244. <xsl:value-of select="$formName"/>
  245. <xsl:text>_escape_fields();</xsl:text>
  246. </out:if>
  247. </xsl:if>
  248. <xsl:text>document.</xsl:text>
  249. <xsl:value-of select="$formName"/>
  250. <xsl:text>.action="wsrp_rewrite?wsrp-urlType=</xsl:text>
  251. <xsl:choose>
  252. <xsl:when test="$urlType != ''">
  253. <xsl:value-of select="$urlType"/>
  254. </xsl:when>
  255. <xsl:otherwise>blockingAction</xsl:otherwise>
  256. </xsl:choose>
  257. <xsl:if test="$operation != ''">
  258. <xsl:text>&amp;wsrp-interactionState=</xsl:text>
  259. <xsl:value-of select="$operation"/>
  260. </xsl:if>
  261. <xsl:choose>
  262. <xsl:when test="$mode != ''">
  263. <xsl:text>&amp;wsrp-mode=</xsl:text>
  264. <xsl:value-of select="$mode"/>
  265. </xsl:when>
  266. <xsl:when test="$operation = 'pop' or $operation = 'drop'">
  267. <!-- PATCH ALERT #415036.0: we do this work here, because some consumers must decide the wsrp-mode @
  268. wsrp_rewrite generation time, not @ blockingAction time. -->
  269. <xsl:text>&amp;wsrp-mode=</xsl:text>
  270. <out:choose>
  271. <out:when test="contains( $stack-down-target{generate-id()}, '{$utml-nav-stack-mode-delimiter}' )">
  272. <out:value-of select="substring-before( $stack-down-target{generate-id()}, '{$utml-nav-stack-mode-delimiter}' )"/>
  273. </out:when>
  274. <out:otherwise>
  275. <out:value-of select="$utml-mode"/>
  276. </out:otherwise>
  277. </out:choose>
  278. </xsl:when>
  279. <xsl:when test="$operation = 'maintain' or $operation = 'push'">
  280. <xsl:text>&amp;wsrp-mode=</xsl:text>
  281. <out:value-of select="$utml-mode"/>
  282. </xsl:when>
  283. </xsl:choose>
  284. <xsl:text>/wsrp_rewrite";</xsl:text>
  285. <xsl:choose>
  286. <xsl:when test="$targetPage != ''">
  287. <xsl:text>document.</xsl:text>
  288. <xsl:value-of select="$formName"/>
  289. <xsl:text>.edit_mode.value="</xsl:text>
  290. <xsl:value-of select="xtsext:javascriptencode($targetPage)"/>
  291. <xsl:text>";</xsl:text>
  292. </xsl:when>
  293. <xsl:otherwise>
  294. <xsl:if test="$operation = 'pop' or $operation = 'drop'">
  295. <xsl:text>document.</xsl:text>
  296. <xsl:value-of select="$formName"/>
  297. <xsl:text>.edit_mode.value='</xsl:text>
  298. <out:value-of xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" select="xtsext:javascriptencode($stack-down-target{generate-id()})"/>
  299. <xsl:text>';</xsl:text>
  300. </xsl:if>
  301. </xsl:otherwise>
  302. </xsl:choose>
  303. <xsl:text>document.</xsl:text>
  304. <xsl:value-of select="$formName"/>
  305. <xsl:text>.submit();</xsl:text>
  306. </xsl:template>
  307. <!-- =========================================================== -->
  308. <!-- ===================== rewrite-render ====================== -->
  309. <!-- =========================================================== -->
  310. <!--
  311. <utml:rewrite-render
  312. utml:mode = "the-wsrp-mode" default: wsrp:view values: wsrp:view, wsrp:edit, wsrp:help, wsrp:preview, cps:config
  313. />
  314. -->
  315. <xsl:template match="utml:rewrite-render" priority="1">
  316. <xsl:variable name="mode" select="@utml:mode"/>
  317. <out:text>document.location.href = "wsrp_rewrite?wsrp-urlType=render&amp;wsrp-mode=</out:text>
  318. <xsl:choose>
  319. <xsl:when test="$mode != ''">
  320. <xsl:value-of select="$mode"/>
  321. </xsl:when>
  322. <xsl:otherwise>wsrp:view</xsl:otherwise>
  323. </xsl:choose>
  324. <out:text>&amp;wsrp-navigationalState=</out:text>
  325. <out:choose>
  326. <out:when test="key('utml-key-params', 'edit_navState')">
  327. <out:value-of select="xtsext:urlencode( string(key( 'utml-key-params', 'edit_navState' ) ) )"/>
  328. </out:when>
  329. <out:otherwise>
  330. <out:variable name="utml-navState">
  331. <out:for-each select="$utml-params">
  332. <out:text>&lt;param name="</out:text>
  333. <out:value-of select="@name"/>
  334. <out:text>"></out:text>
  335. <out:value-of select="xtsext:xmlencode(string(.))"/>
  336. <out:text>&lt;/param></out:text>
  337. </out:for-each>
  338. </out:variable>
  339. <out:value-of select="xtsext:urlencode( xtsext:validator('prepare','utml-navState',xtsext:base64encode( string( $utml-navState ), true() ) ))"/>
  340. </out:otherwise>
  341. </out:choose>
  342. <xsl:text>/wsrp_rewrite";</xsl:text>
  343. </xsl:template>
  344. <!-- ========================================================== -->
  345. <!-- ======================= Input ============================ -->
  346. <!-- ========================================================== -->
  347. <!--
  348. <utml:input type="text|password|hidden" name="fieldname" (value="fieldvalue") utml:update="false|true">
  349. <utml:read-only>....</utml:read-only>
  350. (<utml:value>....</utml:value>) - other place for value
  351. </utml:input>
  352. Notes:
  353. -not having a readonly node will cut a lot of code out during the compile
  354. -value can be listed as an attribute or a child node
  355. -update will make the code smaller when set to false, this will not grab
  356. the environment value for the variable if found
  357. -->
  358. <xsl:template match="utml:input[(@type = 'text') or (@type = 'password') or (@type = 'hidden')]" priority="1">
  359. <!-- if there isn't a readonly node don't include the extra logic into the stylesheet -->
  360. <xsl:choose>
  361. <xsl:when test="((utml:read-only) or (ancestor::*[name() = 'utml:form']/utml:read-only) or (ancestor::*[name() = 'utml:group']/utml:read-only)) and not (@type = 'hidden')">
  362. <out:variable name="{@name}read-only">
  363. <xsl:choose>
  364. <xsl:when test="(utml:read-only)">
  365. <xsl:copy-of select="utml:read-only/child::node()"/>
  366. </xsl:when>
  367. <xsl:when test="(ancestor::*[name() = 'utml:group']/utml:read-only/child::node())">
  368. <xsl:copy-of select="ancestor::*[name() = 'utml:group']/utml:read-only/child::node()"/>
  369. </xsl:when>
  370. <xsl:otherwise>
  371. <xsl:copy-of select="ancestor::*[name() = 'utml:form']/utml:read-only/child::node()"/>
  372. </xsl:otherwise>
  373. </xsl:choose>
  374. </out:variable>
  375. <out:choose>
  376. <out:when test="${@name}read-only = 'true'">
  377. <xsl:choose>
  378. <xsl:when test="@type = 'password'">***************</xsl:when>
  379. <xsl:otherwise>
  380. <xsl:call-template name="utml-input-value">
  381. <xsl:with-param name="node" select="."/>
  382. </xsl:call-template>
  383. </xsl:otherwise>
  384. </xsl:choose>
  385. </out:when>
  386. <out:otherwise>
  387. <xsl:call-template name="utml-render-input">
  388. <xsl:with-param name="node" select="."/>
  389. </xsl:call-template>
  390. </out:otherwise>
  391. </out:choose>
  392. </xsl:when>
  393. <xsl:otherwise>
  394. <xsl:call-template name="utml-render-input">
  395. <xsl:with-param name="node" select="."/>
  396. </xsl:call-template>
  397. </xsl:otherwise>
  398. </xsl:choose>
  399. </xsl:template>
  400. <!-- render the input field again using all the original attributes -->
  401. <xsl:template name="utml-render-input">
  402. <xsl:param name="node"/>
  403. <input>
  404. <xsl:copy-of select="@*[(local-name() != 'value') and namespace-uri() != $utml-namespace-uri]"/>
  405. <out:variable name="updatedValue">
  406. <xsl:choose>
  407. <xsl:when test="@utml:update='false'">
  408. <xsl:call-template name="utml-get-value">
  409. <xsl:with-param name="node" select="$node"/>
  410. </xsl:call-template>
  411. </xsl:when>
  412. <xsl:otherwise>
  413. <xsl:call-template name="utml-input-value">
  414. <xsl:with-param name="node" select="$node"/>
  415. </xsl:call-template>
  416. </xsl:otherwise>
  417. </xsl:choose>
  418. </out:variable>
  419. <out:attribute name="value">
  420. <out:value-of select="$updatedValue"/>
  421. </out:attribute>
  422. <out:variable name="textDirection">
  423. <out:choose>
  424. <out:when test="$ui-portlet-isBidiEnabled != 'true'"></out:when>
  425. <out:otherwise>
  426. <xsl:choose>
  427. <xsl:when test="$node[@dir]"></xsl:when>
  428. <xsl:when test="$node[@stttype]">stt</xsl:when>
  429. <xsl:otherwise>
  430. <out:value-of select="xtsext:getBTD(string($updatedValue), $ui-portlet-baseTextDirection, $ui-portlet-product-locale)"/>
  431. </xsl:otherwise>
  432. </xsl:choose>
  433. </out:otherwise>
  434. </out:choose>
  435. </out:variable>
  436. <xsl:if test="$node[@type = 'text']">
  437. <out:if test="$textDirection != ''">
  438. <out:choose>
  439. <out:when test="$textDirection = 'stt'">
  440. <out:attribute name="dir">ltr</out:attribute>
  441. </out:when>
  442. <out:otherwise>
  443. <out:attribute name="dir">
  444. <out:value-of select="$textDirection"/>
  445. </out:attribute>
  446. </out:otherwise>
  447. </out:choose>
  448. <out:if test="$textDirection = 'stt' or $ui-portlet-baseTextDirection = 'auto'">
  449. <xsl:choose>
  450. <xsl:when test="$node[@onfocus]">
  451. <out:attribute name="onfocus">
  452. <xsl:value-of select="concat('bidi.onfocus(this);',$node[@onfocus])"/>
  453. </out:attribute>
  454. </xsl:when>
  455. <xsl:otherwise>
  456. <out:attribute name="onfocus">
  457. <out:text>bidi.onfocus(this)</out:text>
  458. </out:attribute>
  459. </xsl:otherwise>
  460. </xsl:choose>
  461. </out:if>
  462. </out:if>
  463. </xsl:if>
  464. <xsl:apply-templates/>
  465. </input>
  466. <xsl:call-template name="utml-render-escaped-input">
  467. <xsl:with-param name="node" select="$node"/>
  468. </xsl:call-template>
  469. </xsl:template>
  470. <!-- render the input field again using all the original attributes -->
  471. <xsl:template name="utml-render-textarea">
  472. <xsl:param name="node"/>
  473. <textarea>
  474. <xsl:copy-of select="@*[(local-name() != 'value') and namespace-uri() != $utml-namespace-uri]"/>
  475. <xsl:choose>
  476. <xsl:when test="@utml:update='false'">
  477. <xsl:call-template name="utml-get-value">
  478. <xsl:with-param name="node" select="$node"/>
  479. </xsl:call-template>
  480. </xsl:when>
  481. <xsl:otherwise>
  482. <xsl:call-template name="utml-input-value">
  483. <xsl:with-param name="node" select="$node"/>
  484. </xsl:call-template>
  485. </xsl:otherwise>
  486. </xsl:choose>
  487. <xsl:apply-templates/>
  488. </textarea>
  489. <xsl:call-template name="utml-render-escaped-input">
  490. <xsl:with-param name="node" select="$node"/>
  491. </xsl:call-template>
  492. </xsl:template>
  493. <xsl:template name="utml-render-escaped-input">
  494. <xsl:param name="node"/>
  495. <xsl:if test="@utml:escape = 'true'">
  496. <xsl:variable name="utml-escape-prefix">
  497. <xsl:choose>
  498. <xsl:when test="ancestor::utml:form">
  499. <xsl:value-of select="ancestor::utml:form/@utml:escape-prefix"/>
  500. </xsl:when>
  501. <xsl:otherwise>
  502. <xsl:value-of select="@utml:escape-prefix"/>
  503. </xsl:otherwise>
  504. </xsl:choose>
  505. </xsl:variable>
  506. <out:if test="{ $utml-escape-prefix } != ''">
  507. <input name="{ '{ ' }{ $utml-escape-prefix }{ ' }' }{ @name }" type="hidden" value=""/>
  508. </out:if>
  509. </xsl:if>
  510. </xsl:template>
  511. <!-- find out where you should get the value from -->
  512. <xsl:template name="utml-input-value">
  513. <xsl:param name="node"/>
  514. <out:choose>
  515. <out:when test="key('utml-key-params', '{$node/@name}')">
  516. <out:value-of select="key('utml-key-params', '{$node/@name}')"/>
  517. </out:when>
  518. <out:otherwise>
  519. <xsl:call-template name="utml-get-value">
  520. <xsl:with-param name="node" select="$node"/>
  521. </xsl:call-template>
  522. </out:otherwise>
  523. </out:choose>
  524. </xsl:template>
  525. <!-- is compile time code to find out where you put the value -->
  526. <xsl:template name="utml-get-value">
  527. <xsl:param name="node"/>
  528. <xsl:choose>
  529. <xsl:when test="$node/@value">
  530. <xsl:value-of select="$node/@value"/>
  531. </xsl:when>
  532. <xsl:when test="$node/@utml:value">
  533. <out:value-of select="{$node/@utml:value}"/>
  534. </xsl:when>
  535. <xsl:when test="$node/utml:value">
  536. <xsl:copy-of select="$node/utml:value/child::node()"/>
  537. </xsl:when>
  538. <xsl:otherwise>
  539. <xsl:apply-templates/>
  540. </xsl:otherwise>
  541. </xsl:choose>
  542. </xsl:template>
  543. <!-- ============================================================== -->
  544. <!-- ========================= Textarea =========================== -->
  545. <!-- ============================================================== -->
  546. <!--
  547. <utml:textarea name="fieldname" (value="fieldvalue") utml:update="false|true">
  548. <utml:read-only>....</utml:read-only>
  549. (<utml:value>....</utml:value>) - other place for value
  550. </utml:input>
  551. Notes:
  552. -not having a readonly node will cut a lot of code out during the compile
  553. -value can be listed as an attribute or a child node
  554. -update will make the code smaller when set to false, this will not grab
  555. the environment value for the variable if found
  556. -->
  557. <xsl:template match="utml:textarea" priority="1">
  558. <!-- if there isn't a readonly node don't include the extra logic into the stylesheet -->
  559. <xsl:choose>
  560. <xsl:when test="(utml:read-only) or (ancestor::*[name() = 'utml:form']/utml:read-only) or (ancestor::*[name() = 'utml:group']/utml:read-only)">
  561. <out:variable name="{@name}read-only">
  562. <xsl:choose>
  563. <xsl:when test="(utml:read-only)">
  564. <xsl:copy-of select="utml:read-only/child::node()"/>
  565. </xsl:when>
  566. <xsl:when test="(ancestor::*[name() = 'utml:group']/utml:read-only/child::node())">
  567. <xsl:copy-of select="ancestor::*[name() = 'utml:group']/utml:read-only/child::node()"/>
  568. </xsl:when>
  569. <xsl:otherwise>
  570. <xsl:copy-of select="ancestor::*[name() = 'utml:form']/utml:read-only/child::node()"/>
  571. </xsl:otherwise>
  572. </xsl:choose>
  573. </out:variable>
  574. <out:choose>
  575. <out:when test="${@name}read-only = 'true'">
  576. <xsl:call-template name="utml-input-value">
  577. <xsl:with-param name="node" select="."/>
  578. </xsl:call-template>
  579. </out:when>
  580. <out:otherwise>
  581. <xsl:call-template name="utml-render-textarea">
  582. <xsl:with-param name="node" select="."/>
  583. </xsl:call-template>
  584. </out:otherwise>
  585. </out:choose>
  586. </xsl:when>
  587. <xsl:otherwise>
  588. <xsl:call-template name="utml-render-textarea">
  589. <xsl:with-param name="node" select="."/>
  590. </xsl:call-template>
  591. </xsl:otherwise>
  592. </xsl:choose>
  593. </xsl:template>
  594. <!-- =============================================== -->
  595. <!-- ================= Radio Group ================= -->
  596. <!-- =============================================== -->
  597. <!--
  598. <utml:radio-group name="radiobuttonsfieldname">
  599. <utml:read-only>....</utml:read-only>
  600. <utml:default-value>....</utml:default-value>
  601. ...
  602. </utml:radio-group>
  603. Notes:
  604. -the variables created for this will use the name of the group as a prefix
  605. -default-value allows you to specify the default selected value
  606. -readonly can be set for the entire group of individual buttons
  607. -update='false' will not grab the environment value for the variable if found
  608. -->
  609. <xsl:template match="utml:radio-group" priority="1">
  610. <!-- this will prefix all the radio group variable so they have unique names -->
  611. <xsl:variable name="group-prefix">
  612. <xsl:choose>
  613. <xsl:when test="@name"><xsl:value-of select="@name"/></xsl:when>
  614. <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
  615. </xsl:choose>
  616. </xsl:variable>
  617. <out:variable name="{$group-prefix}read-only">
  618. <xsl:choose>
  619. <xsl:when test="(utml:read-only)">
  620. <xsl:copy-of select="utml:read-only/child::node()"/>
  621. </xsl:when>
  622. <xsl:when test="(ancestor::*[name() = 'utml:group']/utml:read-only/child::node())">
  623. <xsl:copy-of select="ancestor::*[name() = 'utml:group']/utml:read-only/child::node()"/>
  624. </xsl:when>
  625. <xsl:otherwise>
  626. <xsl:copy-of select="ancestor::*[name() = 'utml:form']/utml:read-only/child::node()"/>
  627. </xsl:otherwise>
  628. </xsl:choose>
  629. </out:variable>
  630. <out:variable name="{$group-prefix}checked-value">
  631. <out:choose>
  632. <out:when test="key('utml-key-params', '{@name}')"><out:value-of select="key('utml-key-params', '{@name}')"/></out:when>
  633. <out:otherwise><xsl:copy-of select="utml:default-value/child::node()"/></out:otherwise>
  634. </out:choose>
  635. </out:variable>
  636. <xsl:apply-templates/>
  637. </xsl:template>
  638. <!-- =============================================== -->
  639. <!-- ===================== Radio =================== -->
  640. <!-- =============================================== -->
  641. <!--
  642. <utml:input type="radio" (value="fieldvalue") *name="radiobuttonsfieldname"> *- if named make if the same as the group
  643. <utml:read-only>....</utml:read-only>
  644. (<utml:value>....</utml:value>) - other place for the value
  645. ...
  646. </utml:radio-group>
  647. Notes:
  648. -if the value of the radio button isn't dynamic use the attribute and the code becomes smaller
  649. -->
  650. <xsl:template match="utml:input[(@type = 'radio')]" priority="1">
  651. <!-- the button names should match that of the group so all group variables will need this prefix -->
  652. <xsl:variable name="group-prefix">
  653. <xsl:choose>
  654. <xsl:when test="@name"><xsl:value-of select="@name"/></xsl:when>
  655. <xsl:otherwise><xsl:value-of select="ancestor::*[name() = 'utml:radio-group']/@name"/></xsl:otherwise>
  656. </xsl:choose>
  657. </xsl:variable>
  658. <xsl:variable name="no-update" select="ancestor::*[name() = 'utml:radio-group']/@utml:update='false'"/>
  659. <!-- if it isn't readonly and the value is hardcoded don't add extra logic -->
  660. <xsl:choose>
  661. <xsl:when test="@value and not((ancestor::*[name() = 'utml:radio-group']/utml:read-only) or (ancestor::*[name() = 'utml:form']/utml:read-only))">
  662. <input name="{$group-prefix}">
  663. <xsl:choose>
  664. <xsl:when test="$no-update">
  665. <xsl:copy-of select="@*[(local-name() != 'name') and namespace-uri() != $utml-namespace-uri]"/>
  666. </xsl:when>
  667. <xsl:otherwise>
  668. <xsl:copy-of select="@*[(local-name() != 'checked') and (local-name() != 'name') and namespace-uri() != $utml-namespace-uri]"/>
  669. <out:if test="'{@value}' = ${$group-prefix}checked-value"><out:attribute name="checked">checked</out:attribute></out:if>
  670. </xsl:otherwise>
  671. </xsl:choose>
  672. <xsl:apply-templates/>
  673. </input>
  674. </xsl:when>
  675. <xsl:otherwise>
  676. <xsl:variable name="radio-prefix">
  677. <xsl:value-of select="concat($group-prefix, position())"/>
  678. </xsl:variable>
  679. <out:variable name="{$radio-prefix}value">
  680. <xsl:call-template name="utml-get-value">
  681. <xsl:with-param name="node" select="."/>
  682. </xsl:call-template>
  683. </out:variable>
  684. <xsl:choose>
  685. <xsl:when test="(ancestor::*[name() = 'utml:radio-group']/utml:read-only) or (ancestor::*[name() = 'utml:form']/utml:read-only) or (ancestor::*[name() = 'utml:group']/utml:read-only)">
  686. <out:choose>
  687. <out:when test="${$group-prefix}read-only = 'true'">
  688. <img>
  689. <out:attribute name="src">
  690. <out:value-of select="$image_root"/>icon_disabled_radio_<out:if test="${$radio-prefix}value != ${$group-prefix}checked-value">un</out:if>checked.gif</out:attribute>
  691. </img>
  692. </out:when>
  693. <out:otherwise>
  694. <input name="{$group-prefix}">
  695. <xsl:choose>
  696. <xsl:when test="$no-update">
  697. <xsl:copy-of select="@*[(local-name() != 'name') and namespace-uri() != $utml-namespace-uri]"/>
  698. </xsl:when>
  699. <xsl:otherwise>
  700. <xsl:copy-of select="@*[(local-name() != 'value') and (local-name() != 'name') and (local-name() != 'checked') and namespace-uri() != $utml-namespace-uri]"/>
  701. <out:attribute name="value">
  702. <xsl:call-template name="utml-get-value">
  703. <xsl:with-param name="node" select="."/>
  704. </xsl:call-template>
  705. </out:attribute>
  706. <out:if test="${$radio-prefix}value = ${$group-prefix}checked-value"><out:attribute name="checked">checked</out:attribute></out:if>
  707. </xsl:otherwise>
  708. </xsl:choose>
  709. <xsl:apply-templates/>
  710. </input>
  711. </out:otherwise>
  712. </out:choose>
  713. </xsl:when>
  714. <xsl:otherwise>
  715. <input name="{$group-prefix}">
  716. <xsl:choose>
  717. <xsl:when test="$no-update">
  718. <xsl:copy-of select="@*[(local-name() != 'name') and namespace-uri() != $utml-namespace-uri]"/>
  719. </xsl:when>
  720. <xsl:otherwise>
  721. <xsl:copy-of select="@*[(local-name() != 'value') and (local-name() != 'name') and (local-name() != 'checked') and namespace-uri() != $utml-namespace-uri]"/>
  722. <out:attribute name="value">
  723. <xsl:call-template name="utml-get-value">
  724. <xsl:with-param name="node" select="."/>
  725. </xsl:call-template>
  726. </out:attribute>
  727. <out:if test="${$radio-prefix}value = ${$group-prefix}checked-value"><out:attribute name="checked">checked</out:attribute></out:if>
  728. </xsl:otherwise>
  729. </xsl:choose>
  730. <xsl:apply-templates/>
  731. </input>
  732. </xsl:otherwise>
  733. </xsl:choose>
  734. </xsl:otherwise>
  735. </xsl:choose>
  736. </xsl:template>
  737. <!-- =============================================== -->
  738. <!-- ================== Checkbox =================== -->
  739. <!-- =============================================== -->
  740. <!--
  741. <utml:input type="checkbox" name="fieldname" (value="fieldvalue") utml:update="true|false">
  742. <utml:read-only>....</utml:read-only>
  743. (<utml:value>....</utml:value>) - other place for value
  744. <utml:default-value>....</utml:default-value>
  745. </utml:input>
  746. Notes:
  747. -if the value of the checkbox isn't dynamic use the attribute and the code becomes smaller
  748. -->
  749. <xsl:template match="utml:input[(@type = 'checkbox')]" priority="1">
  750. <xsl:variable name="checkbox-prefix" select="'v-'"/>
  751. <out:variable name="{$checkbox-prefix}checked-value">
  752. <xsl:choose>
  753. <xsl:when test="@utml:update='false'">
  754. <xsl:copy-of select="utml:default-value/child::node()"/>
  755. </xsl:when>
  756. <xsl:otherwise>
  757. <out:choose>
  758. <out:when test="key('utml-key-params', '{@name}')"><out:value-of select="key('utml-key-params', '{@name}')"/></out:when>
  759. <out:otherwise><xsl:copy-of select="utml:default-value/child::node()"/></out:otherwise>
  760. </out:choose>
  761. </xsl:otherwise>
  762. </xsl:choose>
  763. </out:variable>
  764. <!-- if it isn't readonly and the value is hardcoded don't add extra logic -->
  765. <xsl:choose>
  766. <xsl:when test="@value and not((utml:read-only) or (ancestor::*[name() = 'utml:form']/utml:read-only) or (ancestor::*[name() = 'utml:group']/utml:read-only))">
  767. <input>
  768. <xsl:copy-of select="@*[(local-name() != 'checked') and namespace-uri() != $utml-namespace-uri]"/>
  769. <out:if test="'{@value}' = ${$checkbox-prefix}checked-value"><out:attribute name="checked">checked</out:attribute></out:if>
  770. <xsl:apply-templates/>
  771. </input>
  772. </xsl:when>
  773. <xsl:otherwise>
  774. <out:variable name="{$checkbox-prefix}value">
  775. <xsl:call-template name="utml-get-value">
  776. <xsl:with-param name="node" select="."/>
  777. </xsl:call-template>
  778. </out:variable>
  779. <xsl:choose>
  780. <xsl:when test="(utml:read-only) or (ancestor::*[name() = 'utml:form']/utml:read-only) or (ancestor::*[name() = 'utml:group']/utml:read-only)">
  781. <out:variable name="{$checkbox-prefix}read-only">
  782. <xsl:choose>
  783. <xsl:when test="(utml:read-only)">
  784. <xsl:copy-of select="utml:read-only/child::node()"/>
  785. </xsl:when>
  786. <xsl:when test="(ancestor::*[name() = 'utml:group']/utml:read-only/child::node())">
  787. <xsl:copy-of select="ancestor::*[name() = 'utml:group']/utml:read-only/child::node()"/>
  788. </xsl:when>
  789. <xsl:otherwise>
  790. <xsl:copy-of select="ancestor::*[name() = 'utml:form']/utml:read-only/child::node()"/>
  791. </xsl:otherwise>
  792. </xsl:choose>
  793. </out:variable>
  794. <out:choose>
  795. <out:when test="${$checkbox-prefix}read-only = 'true'">
  796. <img>
  797. <out:attribute name="src">
  798. <out:value-of select="$image_root"/>icon_disabled_checkbox_<out:if test="${$checkbox-prefix}checked-value != ${$checkbox-prefix}value">un</out:if>checked.gif</out:attribute>
  799. </img>
  800. </out:when>
  801. <out:otherwise>
  802. <input>
  803. <xsl:copy-of select="@*[(local-name() != 'value') and (local-name() != 'checked') and namespace-uri() != $utml-namespace-uri]"/>
  804. <out:attribute name="value">
  805. <xsl:choose>
  806. <xsl:when test="@utml:update='false'">
  807. <xsl:call-template name="utml-get-value">
  808. <xsl:with-param name="node" select="."/>
  809. </xsl:call-template>
  810. </xsl:when>
  811. <xsl:otherwise>
  812. <xsl:call-template name="utml-input-value">
  813. <xsl:with-param name="node" select="."/>
  814. </xsl:call-template>
  815. </xsl:otherwise>
  816. </xsl:choose>
  817. </out:attribute>
  818. <out:if test="${$checkbox-prefix}checked-value = ${$checkbox-prefix}value"><out:attribute name="checked">checked</out:attribute></out:if>
  819. <xsl:apply-templates/>
  820. </input>
  821. </out:otherwise>
  822. </out:choose>
  823. </xsl:when>
  824. <xsl:otherwise>
  825. <input>
  826. <xsl:copy-of select="@*[(local-name() != 'value') and (local-name() != 'checked') and namespace-uri() != $utml-namespace-uri]"/>
  827. <out:attribute name="value">
  828. <xsl:choose>
  829. <xsl:when test="@utml:update='false'">
  830. <xsl:call-template name="utml-get-value">
  831. <xsl:with-param name="node" select="."/>
  832. </xsl:call-template>
  833. </xsl:when>
  834. <xsl:otherwise>
  835. <xsl:call-template name="utml-input-value">
  836. <xsl:with-param name="node" select="."/>
  837. </xsl:call-template>
  838. </xsl:otherwise>
  839. </xsl:choose>
  840. </out:attribute>
  841. <out:if test="string(${$checkbox-prefix}value) = ${$checkbox-prefix}checked-value"><out:attribute name="checked">checked</out:attribute></out:if>
  842. <xsl:apply-templates/>
  843. </input>
  844. </xsl:otherwise>
  845. </xsl:choose>
  846. </xsl:otherwise>
  847. </xsl:choose>
  848. </xsl:template>
  849. <!-- ================================================ -->
  850. <!-- ===================== Select =================== -->
  851. <!-- ================================================ -->
  852. <!--
  853. <utml:select name="fieldname">
  854. <utml:read-only>....</utml:read-only>
  855. <utml:default-value>....</utml:default-value>
  856. ...
  857. </utml:select>
  858. Notes:
  859. -the variables created for this will use the name as a prefix
  860. -default-value allows you to specify the default selected value
  861. -->
  862. <xsl:template match="utml:select" priority="1">
  863. <xsl:variable name="group-prefix" select="'v'"/>
  864. <out:variable name="{$group-prefix}read-only">
  865. <xsl:choose>
  866. <xsl:when test="(utml:read-only)">
  867. <xsl:copy-of select="utml:read-only/child::node()"/>
  868. </xsl:when>
  869. <xsl:when test="(ancestor::*[name() = 'utml:group']/utml:read-only/child::node())">
  870. <xsl:copy-of select="ancestor::*[name() = 'utml:group']/utml:read-only/child::node()"/>
  871. </xsl:when>
  872. <xsl:otherwise>
  873. <xsl:copy-of select="ancestor::*[name() = 'utml:form']/utml:read-only/child::node()"/>
  874. </xsl:otherwise>
  875. </xsl:choose>
  876. </out:variable>
  877. <out:variable name="{$group-prefix}selected-value">
  878. <out:choose>
  879. <out:when test="key('utml-key-params', '{@name}')"><out:value-of select="key('utml-key-params', '{@name}')"/></out:when>
  880. <out:otherwise><xsl:copy-of select="utml:default-value/child::node()"/></out:otherwise>
  881. </out:choose>
  882. </out:variable>
  883. <xsl:choose>
  884. <xsl:when test="(utml:read-only) or (ancestor::*[name() = 'utml:form']/utml:read-only) or (ancestor::*[name() = 'utml:group']/utml:read-only)">
  885. <out:choose>
  886. <out:when test="${$group-prefix}read-only = 'true'">
  887. <xsl:apply-templates/>
  888. </out:when>
  889. <out:otherwise>
  890. <select>
  891. <xsl:copy-of select="@*[(local-name() != 'default-value') and (local-name() != 'readonly') and namespace-uri() != $utml-namespace-uri]"/>
  892. <xsl:apply-templates/>
  893. </select>
  894. </out:otherwise>
  895. </out:choose>
  896. </xsl:when>
  897. <xsl:otherwise>
  898. <select>
  899. <xsl:copy-of select="@*[(local-name() != 'default-value') and (local-name() != 'readonly') and namespace-uri() != $utml-namespace-uri]"/>
  900. <xsl:apply-templates/>
  901. </select>
  902. </xsl:otherwise>
  903. </xsl:choose>
  904. </xsl:template>
  905. <!-- ================================================ -->
  906. <!-- ===================== Option =================== -->
  907. <!-- ================================================ -->
  908. <!--
  909. <utml:option (value="fieldvalue")>
  910. (<utml:value>....</utml:value>) - other place for value
  911. </utml:input>
  912. Notes:
  913. -if the value of the option isn't dynamic use the attribute and the code becomes smaller
  914. -->
  915. <xsl:template match="utml:option" priority="1">
  916. <xsl:variable name="group-prefix" select="'v'"/>
  917. <!-- this will try and streamline the code for when the value is hardcoded and not generated -->
  918. <xsl:choose>
  919. <xsl:when test="(ancestor::*[name() = 'utml:select']/utml:read-only) or (ancestor::*[name() = 'utml:form']/utml:read-only) or (ancestor::*[name() = 'utml:group']/utml:read-only)">
  920. <out:choose>
  921. <out:when test="${$group-prefix}read-only = 'true'">
  922. <xsl:choose>
  923. <xsl:when test="@value">
  924. <out:if test="'{@value}' = ${$group-prefix}selected-value">
  925. <xsl:apply-templates/>
  926. </out:if>
  927. </xsl:when>
  928. <xsl:otherwise>
  929. <xsl:variable name="option-prefix">
  930. <xsl:value-of select="concat($group-prefix, position())"/>
  931. </xsl:variable>
  932. <out:variable name="{$option-prefix}value">
  933. <xsl:call-template name="utml-get-value">
  934. <xsl:with-param name="node" select="."/>
  935. </xsl:call-template>
  936. </out:variable>
  937. <out:if test="{$option-prefix}value = ${$group-prefix}selected-value">
  938. <xsl:apply-templates/>
  939. </out:if>
  940. </xsl:otherwise>
  941. </xsl:choose>
  942. </out:when>
  943. <out:otherwise>
  944. <xsl:choose>
  945. <xsl:when test="@value">
  946. <option>
  947. <xsl:copy-of select="@*[(local-name() != 'selected') and namespace-uri() != $utml-namespace-uri]"/>
  948. <out:if test="'{@value}' = ${$group-prefix}selected-value"><out:attribute name="selected">true</out:attribute></out:if>
  949. <xsl:apply-templates/>
  950. </option>
  951. </xsl:when>
  952. <xsl:otherwise>
  953. <xsl:variable name="option-prefix">
  954. <xsl:value-of select="concat($group-prefix, position())"/>
  955. </xsl:variable>
  956. <out:variable name="{$option-prefix}value">
  957. <xsl:call-template name="utml-get-value">
  958. <xsl:with-param name="node" select="."/>
  959. </xsl:call-template>
  960. </out:variable>
  961. <option>
  962. <xsl:copy-of select="@*[(local-name() != 'selected') and (local-name() != 'value') and namespace-uri() != $utml-namespace-uri]"/>
  963. <out:attribute name="value"><out:value-of select="{$option-prefix}value"/></out:attribute>
  964. <out:if test="${$option-prefix}value = ${$group-prefix}selected-value"><out:attribute name="selected">true</out:attribute></out:if>
  965. <xsl:apply-templates/>
  966. </option>
  967. </xsl:otherwise>
  968. </xsl:choose>
  969. </out:otherwise>
  970. </out:choose>
  971. </xsl:when>
  972. <xsl:otherwise>
  973. <xsl:choose>
  974. <xsl:when test="@value">
  975. <option>
  976. <xsl:copy-of select="@*[(local-name() != 'selected') and namespace-uri() != $utml-namespace-uri]"/>
  977. <out:if test="'{@value}' = ${$group-prefix}selected-value"><out:attribute name="selected">true</out:attribute></out:if>
  978. <xsl:apply-templates/>
  979. </option>
  980. </xsl:when>
  981. <xsl:otherwise>
  982. <xsl:variable name="option-prefix">
  983. <xsl:value-of select="concat($group-prefix, position())"/>
  984. </xsl:variable>
  985. <out:variable name="{$option-prefix}value">
  986. <xsl:call-template name="utml-get-value">
  987. <xsl:with-param name="node" select="."/>
  988. </xsl:call-template>
  989. </out:variable>
  990. <option>
  991. <xsl:copy-of select="@*[(local-name() != 'selected') and (local-name() != 'value') and namespace-uri() != $utml-namespace-uri]"/>
  992. <out:attribute name="value"><out:value-of select="${$option-prefix}value"/></out:attribute>
  993. <out:if test="${$option-prefix}value = ${$group-prefix}selected-value"><out:attribute name="selected">true</out:attribute></out:if>
  994. <xsl:apply-templates/>
  995. </option>
  996. </xsl:otherwise>
  997. </xsl:choose>
  998. </xsl:otherwise>
  999. </xsl:choose>
  1000. </xsl:template>
  1001. <!-- ================================================ -->
  1002. <!-- ===================== A:HREF =================== -->
  1003. <!-- ================================================ -->
  1004. <!--
  1005. <utml:a (href="javascriptfunction") (utml:op="operation") *utml:formName="pform"> * - not needed when in a utml:form
  1006. (<utml:href>....</utml:href>) - other place for href
  1007. (<utml:op>....</utml:op>) - other place for operation
  1008. </utml:input>
  1009. Notes:
  1010. -default operation is maintain
  1011. -if you aren't directly inside a form use utml:formName to define the name - if you are it isn't needed
  1012. -the href has to be a valid javascript call with ; at the end
  1013. -->
  1014. <xsl:template match="utml:a" priority="1">
  1015. <!-- get the target -->
  1016. <xsl:variable name="utml-target">
  1017. <xsl:choose>
  1018. <xsl:when test="@utml:target"><xsl:value-of select="@utml:target"/></xsl:when>
  1019. <xsl:when test="utml:target"><xsl:copy-of select="utml:target/child::node()"/></xsl:when>
  1020. </xsl:choose>
  1021. </xsl:variable>
  1022. <!-- get the validate -->
  1023. <xsl:variable name="utml-validate">
  1024. <xsl:choose>
  1025. <xsl:when test="@utml:validate"><xsl:value-of select="@utml:validate"/></xsl:when>
  1026. <xsl:when test="utml:validate"><xsl:copy-of select="utml:validate/child::node()"/></xsl:when>
  1027. </xsl:choose>
  1028. </xsl:variable>
  1029. <!-- get the href -->
  1030. <xsl:variable name="utml-href">
  1031. <xsl:choose>
  1032. <xsl:when test="@utml:href"><xsl:value-of select="@utml:href"/></xsl:when>
  1033. <xsl:when test="utml:href"><xsl:copy-of select="utml:href/child::node()"/></xsl:when>
  1034. </xsl:choose>
  1035. </xsl:variable>
  1036. <!-- get the name of the parent form, necessary for setting form variables via JS -->
  1037. <xsl:variable name="parent-form-name">
  1038. <xsl:choose>
  1039. <xsl:when test="@utml:formName">
  1040. <xsl:value-of select="@utml:formName"/>
  1041. </xsl:when>
  1042. <xsl:when test="ancestor::utml:form">
  1043. <xsl:value-of select="ancestor::utml:form/@name"/>
  1044. </xsl:when>
  1045. <xsl:otherwise>
  1046. <xsl:message terminate="yes">UTML ERROR: can't find the embedded form name.</xsl:message>
  1047. </xsl:otherwise>
  1048. </xsl:choose>
  1049. </xsl:variable>
  1050. <!-- Output the HTML anchor -->
  1051. <a>
  1052. <!-- copy all non-utml attributes... -->
  1053. <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
  1054. <out:attribute name="href">
  1055. <out:text>javascript:</out:text><xsl:copy-of select="$utml-href"/><xsl:call-template name="utml-gen-form-submit">
  1056. <xsl:with-param name="formName" select="$parent-form-name"/>
  1057. <xsl:with-param name="target" select="$utml-target"/>
  1058. <xsl:with-param name="operation" select="@utml:op"/>
  1059. <xsl:with-param name="validate" select="'false'"/>
  1060. <xsl:with-param name="mode" select="'wsrp:edit'"/>
  1061. </xsl:call-template>
  1062. </out:attribute>
  1063. <!--copy all non-utml child elements... -->
  1064. <xsl:apply-templates/>
  1065. </a>
  1066. </xsl:template>
  1067. <xsl:template match="utml:group" priority="1">
  1068. <xsl:apply-templates/>
  1069. </xsl:template>
  1070. <xsl:template match="utml:variables" priority="1">
  1071. <out:key name="utml-key-params" match="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Body/wsrp:getMarkup/wsrp:markupParams/wsrp:navigationalState/param" use="@name"/>
  1072. <out:variable name="utml-params" select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Body/wsrp:getMarkup/wsrp:markupParams/wsrp:navigationalState/param"/>
  1073. <out:variable name="utml-image-root" select="/root/bad_xpath_fix_me/resourceTemplate"/>
  1074. <out:variable name="utml-mode" select="/root/envelope/SOAP-ENV:Envelope/SOAP-ENV:Body/wsrp:getMarkup/wsrp:markupParams/wsrp:mode"/>
  1075. </xsl:template>
  1076. <!-- the main engine -->
  1077. <xsl:template match="*[namespace-uri() = $utml-namespace-uri]" priority="0"/>
  1078. <xsl:template match="*">
  1079. <xsl:copy>
  1080. <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
  1081. <xsl:apply-templates/>
  1082. </xsl:copy>
  1083. </xsl:template>
  1084. </xsl:stylesheet>