12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: ps
- (C) Copyright IBM Corp. 2005, 2022
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!--
- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- -->
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:out="dummy-uri"
- xmlns:utml="http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/">
-
- <xsl:output method="xml" encoding="UTF-8" indent="no"/>
- <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
- <xsl:variable name="utml-namespace-uri" select="'http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/'"/>
- <!--
- utml:form
- utml:input
- utml:checkbox
- utml:radio
- utml:password
- utml:hidden
- utml:textarea
- utml:select
- utml:option
- -->
-
- <!-- =========================================================== -->
- <!-- ========================= form ============================ -->
- <!-- =========================================================== -->
-
- <!--
-
- Just like formlogic formlogic lite will add evironment variables as
- that aren't in the current page as utml fields as hidden inputs
-
- - you can have fields not add a hidden input by defining an exclude or exclude prefix
- <utml:form ...
- <utml:exclude>excludefieldname</utml:exclude>
- <utml:exclude-prefix>excludeprefix</utml:excludeprefix>
-
- -->
-
- <xsl:template match="utml:form[namespace-uri() = $utml-namespace-uri]" priority="1">
- <form>
-
- <!-- copy non-utml attributes... -->
- <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
-
- <!-- define the delimiter so we know how tot get the tarked from the stack string -->
- <xsl:variable name="nav-stack-delimiter" select="'*'"/>
-
- <out:variable name="stack-down-target">
- <out:choose>
- <out:when test="contains(/root/env/param[@name='ps_nav_stack'], '{$nav-stack-delimiter}')">
- <out:value-of select="substring-before( /root/env/param[@name='ps_nav_stack'], '{$nav-stack-delimiter}' )"/>
- </out:when>
- <out:otherwise>
- <out:value-of select="/root/env/param[@name='ps_nav_stack']"/>
- </out:otherwise>
- </out:choose>
- </out:variable>
-
- <xsl:variable name="formName"><xsl:value-of select="@name"/></xsl:variable>
-
- <out:variable name="{$formName}form">
- <xsl:copy-of select="utml:read-only/child::node()"/>
- </out:variable>
-
- <!-- Output the JS snippet for the anchor -->
- <script language="JavaScript">
- <![CDATA[
- function needCustomHeader(formName)
- {
- var mPNotificationEMail = formName.m_p_notificationEMail;
- var m = formName.m;
- var psNavSource = formName.ps_nav_source;
- var prevPsNavSource = formName.prev_ps_nav_src;
- if ( mPNotificationEMail != undefined &&
- m != undefined && m.value.slice(-"submit.xts".length) === "submit.xts" &&
- psNavSource != undefined && psNavSource.value.slice(-"personal.xts".length) === "personal.xts" &&
- prevPsNavSource != undefined && prevPsNavSource.value.slice(-"general.xts".length) === "general.xts" ) {
- return true;
- }
- return false;
- }
- function getFormDataQueryString(form)
- {
- var keyValuePairs = [];
- for (var i = 0; i < form.elements.length; i++)
- {
- var element = form.elements[i];
- keyValuePairs.push(encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value));
- }
- return queryString = keyValuePairs.join("&");
- }
- ]]>
- function utmlSubmitForm(formName, targetPage, operation, dovalid)
- {
- if( dovalid != '' && window.validate )
- {
- if( !validate() )
- return;
- }
- formName.ps_nav_op.value = operation;
- if (targetPage != '')
- formName.m.value = targetPage;
- else if (operation == 'pop' || operation == 'drop')
- formName.m.value = '<out:value-of select="xtsext:javascriptencode(string($stack-down-target))"/>';
- var isBidiEnabled = <out:value-of select="boolean($isBidiEnabled='true')"/>;
- if (isBidiEnabled){
- bidi.onsubmit(formName);
- }
- <!-- XSRF-TOKEN cookie is null when disableXSRFCheck=true in bootstrap.properties. -->
- var xsrfTokenCookie = getCookie("XSRF-TOKEN");
- if (xsrfTokenCookie && operation == "submit" && needCustomHeader(formName))
- {
- <!--
- CAPSIRTS-412 / MANAGECA-9864
-
- 1. Go to "Personal menu" > "My Watch Items" > "My Preferences" and "Personal".
- 2. Enter or change email address and click "OK".
-
- m_p_notificationEMail=...
- m=portal/submit.xts
- ps_nav_source=portal/preferences/personal.xts
- prev_ps_nav_src=portal/preferences/general.xts
- -->
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function()
- {
- if (xhr.readyState === 4)
- {
- document.write(xhr.responseText);
- document.close();
- }
- }
- xhr.open(formName.method, formName.action, false);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.setRequestHeader("X-XSRF-TOKEN", xsrfTokenCookie);
- xhr.send(getFormDataQueryString(formName));
- }
- else
- {
- formName.submit();
- }
- }
- </script>
-
- <!-- handle children... -->
- <xsl:apply-templates/>
- <!-- this will get all the current utml inputs -->
- <xsl:variable name="existence-test-string">
- <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">
- <xsl:text/> and @name != '<xsl:value-of select="./@name"/>' <xsl:text/>
- </xsl:for-each>
- </xsl:variable>
-
- <out:variable name="other-excludes">
- <xsl:for-each select="//utml:form/utml:excludes">
- <xsl:value-of select="concat(' ', normalize-space(.), ' ')"/>
- </xsl:for-each>
- </out:variable>
- <!-- this will allow you to specigy a prefix to exclude hidden inputs for -->
- <xsl:variable name="exclude-prefix">
- <xsl:choose>
- <xsl:when test="utml:exclude-prefix">
- <xsl:copy-of select="utml:exclude-prefix"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="'do_not_include_this_entry_'"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- loop through the environment and add hidden inputs for unused info to be passed along -->
- <out:for-each select="/root/env/param[not(starts-with( @name, '{$exclude-prefix}' ))]">
- <out:if test="@name != '' {$existence-test-string} and not(contains($other-excludes, concat(' ', @name, ' ')))">
- <input type="hidden">
- <xsl:attribute name="name"><xsl:value-of select="'{@name}'"/></xsl:attribute>
- <xsl:attribute name="value"><xsl:value-of select="'{.}'"/></xsl:attribute>
- </input>
- </out:if>
- </out:for-each>
- <!-- UTML navigation control fields: Add those to the page if they do not exist already. -->
- <!-- Navigation instruction for stacked dialogs. -->
- <xsl:if test="not(//utml:input[@name = 'ps_nav_op' or name = 'ps_nav_op']) ">
- <out:if test="not( /root/env/param[@name = 'ps_nav_op'] )">
- <input type="hidden" name="ps_nav_op" value=""/>
- </out:if>
- </xsl:if>
- <!-- Comma-delimited list of template names representing a set of stacked dialogs resulting from a "push" or a "stack-up" navigation operations. -->
- <xsl:if test="not(//utml:input[@name = 'ps_nav_stack' or name = 'ps_nav_stack']) ">
- <out:if test="not( /root/env/param[@name = 'ps_nav_stack'] )">
- <input type="hidden" name="ps_nav_stack" value=""/>
- </out:if>
- </xsl:if>
- <!-- The name of the current template. This is used by formlogic-init to determine where we came from to update the navigation stack. -->
- <xsl:if test="not(//utml:input[@name = 'ps_nav_source' or name = 'ps_nav_source']) ">
- <out:if test="not( /root/env/param[@name = 'ps_nav_source'] )">
- <input type="hidden" name="ps_nav_source">
- <xsl:attribute name="value">{/root/env/param[@name = 'm']}</xsl:attribute>
- </input>
- </out:if>
- </xsl:if>
- <xsl:if test="not(//utml:input[@name = 'prev_ps_nav_src' or name = 'prev_ps_nav_src']) ">
- <out:if test="not( /root/env/param[@name = 'prev_ps_nav_src'] )">
- <input type="hidden" name="prev_ps_nav_src">
- <xsl:attribute name="value">{/root/env/param[@name = 'm']}</xsl:attribute>
- </input>
- </out:if>
- </xsl:if>
- </form>
- </xsl:template>
-
- <!-- ========================================================== -->
- <!-- ======================= Input ============================ -->
- <!-- ========================================================== -->
-
- <!--
-
- <utml:input type="text|password|hidden" name="fieldname" (value="fieldvalue") utml:update="false|true">
- <utml:read-only>....</utml:read-only>
- (<utml:value>....</utml:value>) - other place for value
- </utml:input>
-
- Notes:
- -not having a readonly node will cut a lot of code out during the compile
- -value can be listed as an attribute or a child node
- -update will make the code smaller when set to false, this will not grab
- the environment value for the variable if found
-
- -->
- <xsl:template match="utml:input[(@type = 'text') or (@type = 'password') or (@type = 'hidden')]" priority="1">
- <!-- if there isn't a readonly node don't include the extra logic into the stylesheet -->
- <xsl:choose>
- <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')">
-
- <out:variable name="{@name}read-only">
- <xsl:choose>
- <xsl:when test="(utml:read-only)">
- <xsl:copy-of select="utml:read-only/child::node()"/>
- </xsl:when>
- <xsl:when test="(ancestor::*[name() = 'utml:group']/utml:read-only/child::node())">
- <xsl:copy-of select="ancestor::*[name() = 'utml:group']/utml:read-only/child::node()"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="ancestor::*[name() = 'utml:form']/utml:read-only/child::node()"/>
- </xsl:otherwise>
- </xsl:choose>
- </out:variable>
- <out:choose>
- <out:when test="${@name}read-only = 'true'">
- <xsl:choose>
- <xsl:when test="@type = 'password'">********</xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="input-value">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </out:when>
- <out:otherwise>
- <xsl:call-template name="render-input">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </out:otherwise>
- </out:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="render-input">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- render the input field again using all the original attributes -->
- <xsl:template name="render-input">
- <xsl:param name="node"/>
- <input>
- <xsl:copy-of select="@*[(local-name() != 'value') and namespace-uri() != $utml-namespace-uri]"/>
- <!-- bidi -->
- <out:variable name="updatedValue">
- <xsl:choose>
- <xsl:when test="@utml:update='false'">
- <xsl:call-template name="get-value">
- <xsl:with-param name="node" select="$node"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="input-value">
- <xsl:with-param name="node" select="$node"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </out:variable>
- <out:attribute name="value">
- <out:value-of select="$updatedValue"/>
- </out:attribute>
- <out:variable name="textDirection">
- <out:choose>
- <out:when test="$isBidiEnabled != 'true'"></out:when>
- <out:otherwise>
- <xsl:choose>
- <xsl:when test="$node[@dir]"></xsl:when>
- <xsl:when test="$node[@stttype]">stt</xsl:when>
- <xsl:otherwise>
- <out:value-of select="xtsext:getBTD(string($updatedValue), $baseTextDirection, $productLocale)"/>
- </xsl:otherwise>
- </xsl:choose>
- </out:otherwise>
- </out:choose>
- </out:variable>
- <xsl:if test="$node[@type = 'text']">
- <out:if test="$textDirection != ''">
- <out:choose>
- <out:when test="$textDirection = 'stt'">
- <out:attribute name="dir">ltr</out:attribute>
- </out:when>
- <out:otherwise>
- <out:attribute name="dir">
- <out:value-of select="$textDirection"/>
- </out:attribute>
- </out:otherwise>
- </out:choose>
- <out:if test="$textDirection = 'stt' or $baseTextDirection = 'auto'">
- <xsl:choose>
- <xsl:when test="$node[@onfocus]">
- <out:attribute name="onfocus">
- <xsl:value-of select="concat('bidi.onfocus(this);',$node[@onfocus])"/>
- </out:attribute>
- </xsl:when>
- <xsl:otherwise>
- <out:attribute name="onfocus">
- <out:text>bidi.onfocus(this)</out:text>
- </out:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </out:if>
- </out:if>
- </xsl:if>
- <xsl:apply-templates/>
- </input>
- </xsl:template>
-
- <!-- render the input field again using all the original attributes -->
- <xsl:template name="render-textarea">
- <xsl:param name="node"/>
- <textarea>
- <xsl:copy-of select="@*[(local-name() != 'value') and namespace-uri() != $utml-namespace-uri]"/>
- <out:variable name="updatedValue">
- <xsl:choose>
- <xsl:when test="@utml:update='false'">
- <xsl:call-template name="get-value">
- <xsl:with-param name="node" select="$node"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="input-value">
- <xsl:with-param name="node" select="$node"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </out:variable>
- <out:variable name="textDirection">
- <out:choose>
- <out:when test="$isBidiEnabled != 'true'"></out:when>
- <out:otherwise>
- <xsl:choose>
- <xsl:when test="$node[@dir]"></xsl:when>
- <xsl:when test="$node[@stttype]">stt</xsl:when>
- <xsl:otherwise>
- <out:value-of select="xtsext:getBTD(string($updatedValue), $baseTextDirection, $productLocale)"/>
- </xsl:otherwise>
- </xsl:choose>
- </out:otherwise>
- </out:choose>
- </out:variable>
- <out:if test="$textDirection != ''">
- <out:choose>
- <out:when test="$textDirection = 'stt'">
- <out:attribute name="dir">ltr</out:attribute>
- </out:when>
- <out:otherwise>
- <out:attribute name="dir">
- <out:value-of select="$textDirection"/>
- </out:attribute>
- </out:otherwise>
- </out:choose>
- <out:if test="$textDirection = 'stt' or $baseTextDirection = 'auto'">
- <xsl:choose>
- <xsl:when test="$node[@onfocus]">
- <out:attribute name="onfocus">
- <xsl:value-of select="concat('bidi.onfocus(this);',$node[@onfocus])"/>
- </out:attribute>
- </xsl:when>
- <xsl:otherwise>
- <out:attribute name="onfocus">
- <out:text>bidi.onfocus(this)</out:text>
- </out:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </out:if>
- </out:if>
- <out:value-of select="$updatedValue"/>
- <xsl:apply-templates/>
- </textarea>
- </xsl:template>
-
- <!-- find out where you should get the value from -->
- <xsl:template name="input-value">
- <xsl:param name="node"/>
- <out:choose>
- <out:when test="/root/env/param[@name = '{$node/@name}']">
- <out:value-of select="/root/env/param[@name = '{$node/@name}']"/>
- </out:when>
- <out:otherwise>
- <xsl:call-template name="get-value">
- <xsl:with-param name="node" select="$node"/>
- </xsl:call-template>
- </out:otherwise>
- </out:choose>
- </xsl:template>
-
- <!-- is compile time code to find out where you put the value -->
- <xsl:template name="get-value">
- <xsl:param name="node"/>
- <xsl:choose>
- <xsl:when test="$node/@value">
- <xsl:value-of select="$node/@value"/>
- </xsl:when>
- <xsl:when test="$node/@utml:value">
- <out:value-of select="{$node/@utml:value}"/>
- </xsl:when>
- <xsl:when test="$node/utml:value">
- <xsl:copy-of select="$node/utml:value/child::node()"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!-- ============================================================== -->
- <!-- ========================= Textarea =========================== -->
- <!-- ============================================================== -->
-
- <!--
-
- <utml:textarea name="fieldname" (value="fieldvalue") utml:update="false|true">
- <utml:read-only>....</utml:read-only>
- (<utml:value>....</utml:value>) - other place for value
- </utml:input>
-
- Notes:
- -not having a readonly node will cut a lot of code out during the compile
- -value can be listed as an attribute or a child node
- -update will make the code smaller when set to false, this will not grab
- the environment value for the variable if found
-
- -->
- <xsl:template match="utml:textarea[namespace-uri() = $utml-namespace-uri]" priority="1">
- <!-- if there isn't a readonly node don't include the extra logic into the stylesheet -->
- <xsl:choose>
- <xsl:when test="(utml:read-only) or (ancestor::*[name() = 'utml:form']/utml:read-only) or (ancestor::*[name() = 'utml:group']/utml:read-only)">
- <out:variable name="{@name}read-only">
- <xsl:choose>
- <xsl:when test="(utml:read-only)">
- <xsl:copy-of select="utml:read-only/child::node()"/>
- </xsl:when>
- <xsl:when test="(ancestor::*[name() = 'utml:group']/utml:read-only/child::node())">
- <xsl:copy-of select="ancestor::*[name() = 'utml:group']/utml:read-only/child::node()"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="ancestor::*[name() = 'utml:form']/utml:read-only/child::node()"/>
- </xsl:otherwise>
- </xsl:choose>
- </out:variable>
- <out:choose>
- <out:when test="${@name}read-only = 'true'">
- <xsl:call-template name="input-value">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </out:when>
- <out:otherwise>
- <xsl:call-template name="render-textarea">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </out:otherwise>
- </out:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="render-textarea">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- =============================================== -->
- <!-- ================= Radio Group ================= -->
- <!-- =============================================== -->
-
- <!--
-
- <utml:radio-group name="radiobuttonsfieldname">
- <utml:read-only>....</utml:read-only>
- <utml:default-value>....</utml:default-value>
-
- ...
-
- </utml:radio-group>
-
- Notes:
- -the variables created for this will use the name of the group as a prefix
- -default-value allows you to specify the default selected value
- -readonly can be set for the entire group of individual buttons
-
- -->
-
- <xsl:template match="utml:radio-group" priority="1">
- <!-- this will prefix all the radio group variable so they have unique names -->
- <xsl:variable name="group-prefix">
- <xsl:choose>
- <xsl:when test="@name"><xsl:value-of select="@name"/></xsl:when>
- <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <out:variable name="{$group-prefix}read-only">
- <xsl:choose>
- <xsl:when test="(utml:read-only)">
- <xsl:copy-of select="utml:read-only/child::node()"/>
- </xsl:when>
- <xsl:when test="(ancestor::*[name() = 'utml:group']/utml:read-only/child::node())">
- <xsl:copy-of select="ancestor::*[name() = 'utml:group']/utml:read-only/child::node()"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="ancestor::*[name() = 'utml:form']/utml:read-only/child::node()"/>
- </xsl:otherwise>
- </xsl:choose>
- </out:variable>
- <out:variable name="{$group-prefix}checked-value">
- <out:choose>
- <out:when test="key('env-param', '{@name}')"><out:value-of select="key('env-param', '{@name}')"/></out:when>
- <out:otherwise><xsl:copy-of select="utml:default-value/child::node()"/></out:otherwise>
- </out:choose>
- </out:variable>
- <xsl:apply-templates/>
- </xsl:template>
-
- <!-- =============================================== -->
- <!-- ===================== Radio =================== -->
- <!-- =============================================== -->
-
- <!--
- <utml:input type="radio" (value="fieldvalue") *name="radiobuttonsfieldname"> *- if named make if the same as the group
- <utml:read-only>....</utml:read-only>
- (<utml:value>....</utml:value>) - other place for the value
-
- ...
-
- </utml:radio-group>
-
- Notes:
- -if the value of the radio button isn't dynamic use the attribute and the code becomes smaller
- -->
- <xsl:template match="utml:input[(@type = 'radio')]" priority="1">
- <!-- the button names should match that of the group so all group variables will need this prefix -->
- <xsl:variable name="group-prefix">
- <xsl:choose>
- <xsl:when test="@name"><xsl:value-of select="@name"/></xsl:when>
- <xsl:otherwise><xsl:value-of select="ancestor::*[name() = 'utml:radio-group']/@name"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <!-- if it isn't readonly and the value is hardcoded don't add extra logic -->
- <xsl:choose>
- <xsl:when test="@value and not((ancestor::*[name() = 'utml:radio-group']/utml:read-only) or (ancestor::*[name() = 'utml:form']/utml:read-only))">
- <input name="{$group-prefix}">
- <xsl:copy-of select="@*[(local-name() != 'checked') and (local-name() != 'name') and namespace-uri() != $utml-namespace-uri]"/>
- <out:if test="'{@value}' = ${$group-prefix}checked-value"><out:attribute name="checked">checked</out:attribute></out:if>
- <xsl:apply-templates/>
- </input>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="radio-prefix">
- <xsl:value-of select="concat($group-prefix, position())"/>
- </xsl:variable>
- <out:variable name="{$radio-prefix}value">
- <xsl:call-template name="get-value">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </out:variable>
- <xsl:choose>
- <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)">
- <out:choose>
- <out:when test="${$group-prefix}read-only = 'true'">
- <img>
- <out:attribute name="src">
- <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>
- </img>
- </out:when>
- <out:otherwise>
- <input name="{$group-prefix}">
- <xsl:copy-of select="@*[(local-name() != 'value') and (local-name() != 'name') and (local-name() != 'checked') and namespace-uri() != $utml-namespace-uri]"/>
- <out:attribute name="value">
- <xsl:call-template name="input-value">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </out:attribute>
- <out:if test="${$radio-prefix}value = ${$group-prefix}checked-value"><out:attribute name="checked">checked</out:attribute></out:if>
- <xsl:apply-templates/>
- </input>
- </out:otherwise>
- </out:choose>
- </xsl:when>
- <xsl:otherwise>
- <input name="{$group-prefix}">
- <xsl:copy-of select="@*[(local-name() != 'value') and (local-name() != 'name') and (local-name() != 'checked') and namespace-uri() != $utml-namespace-uri]"/>
- <out:attribute name="value">
- <xsl:call-template name="input-value">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </out:attribute>
- <out:if test="${$radio-prefix}value = ${$group-prefix}checked-value"><out:attribute name="checked">checked</out:attribute></out:if>
- <xsl:apply-templates/>
- </input>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- =============================================== -->
- <!-- ================== Checkbox =================== -->
- <!-- =============================================== -->
-
- <!--
-
- <utml:input type="checkbox" name="fieldname" (value="fieldvalue")>
- <utml:read-only>....</utml:read-only>
- (<utml:value>....</utml:value>) - other place for value
- </utml:input>
-
- Notes:
- -if the value of the checkbox isn't dynamic use the attribute and the code becomes smaller
-
- -->
- <xsl:template match="utml:input[(@type = 'checkbox')]" priority="1">
- <xsl:variable name="checkbox-prefix">
- <xsl:value-of select="concat(@name, '-')"/>
- </xsl:variable>
- <out:variable name="{$checkbox-prefix}checked-value">
- <out:choose>
- <out:when test="key('env-param', '{@name}')"><out:value-of select="key('env-param', '{@name}')"/></out:when>
- <out:otherwise><xsl:copy-of select="utml:default-value/child::node()"/></out:otherwise>
- </out:choose>
- </out:variable>
- <!-- if it isn't readonly and the value is hardcoded don't add extra logic -->
- <xsl:choose>
- <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))">
- <input>
- <xsl:copy-of select="@*[(local-name() != 'checked') and namespace-uri() != $utml-namespace-uri]"/>
- <out:if test="'{@value}' = ${$checkbox-prefix}checked-value"><out:attribute name="checked">checked</out:attribute></out:if>
- <xsl:apply-templates/>
- </input>
- </xsl:when>
- <xsl:otherwise>
- <out:variable name="{$checkbox-prefix}value">
- <xsl:call-template name="get-value">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </out:variable>
- <xsl:choose>
- <xsl:when test="(utml:read-only) or (ancestor::*[name() = 'utml:form']/utml:read-only) or (ancestor::*[name() = 'utml:group']/utml:read-only)">
- <out:variable name="{$checkbox-prefix}read-only">
- <xsl:choose>
- <xsl:when test="(utml:read-only)">
- <xsl:copy-of select="utml:read-only/child::node()"/>
- </xsl:when>
- <xsl:when test="(ancestor::*[name() = 'utml:group']/utml:read-only/child::node())">
- <xsl:copy-of select="ancestor::*[name() = 'utml:group']/utml:read-only/child::node()"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="ancestor::*[name() = 'utml:form']/utml:read-only/child::node()"/>
- </xsl:otherwise>
- </xsl:choose>
- </out:variable>
- <out:choose>
- <out:when test="${$checkbox-prefix}read-only = 'true'">
- <img>
- <out:attribute name="src">
- <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>
- </img>
- </out:when>
- <out:otherwise>
- <input>
- <xsl:copy-of select="@*[(local-name() != 'value') and (local-name() != 'checked') and namespace-uri() != $utml-namespace-uri]"/>
- <out:attribute name="value">
- <xsl:call-template name="input-value">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </out:attribute>
- <out:if test="${$checkbox-prefix}checked-value = ${$checkbox-prefix}value"><out:attribute name="checked">checked</out:attribute></out:if>
- <xsl:apply-templates/>
- </input>
- </out:otherwise>
- </out:choose>
- </xsl:when>
- <xsl:otherwise>
- <input>
- <xsl:copy-of select="@*[(local-name() != 'value') and (local-name() != 'checked') and namespace-uri() != $utml-namespace-uri]"/>
- <out:attribute name="value">
- <xsl:call-template name="input-value">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </out:attribute>
- <out:if test="string(${$checkbox-prefix}value) = ${$checkbox-prefix}checked-value"><out:attribute name="checked">checked</out:attribute></out:if>
- <xsl:apply-templates/>
- </input>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- ================================================ -->
- <!-- ===================== Select =================== -->
- <!-- ================================================ -->
- <!--
-
- <utml:select name="fieldname">
- <utml:read-only>....</utml:read-only>
- <utml:default-value>....</utml:default-value>
-
- ...
-
- </utml:select>
-
- Notes:
- -the variables created for this will use the name as a prefix
- -default-value allows you to specify the default selected value
-
- -->
- <xsl:template match="utml:select" priority="1">
- <xsl:variable name="group-prefix">
- <xsl:choose>
- <xsl:when test="@name"><xsl:value-of select="concat(@name, '-')"/></xsl:when>
- <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <out:variable name="{$group-prefix}read-only">
- <xsl:choose>
- <xsl:when test="(utml:read-only)">
- <xsl:copy-of select="utml:read-only/child::node()"/>
- </xsl:when>
- <xsl:when test="(ancestor::*[name() = 'utml:group']/utml:read-only/child::node())">
- <xsl:copy-of select="ancestor::*[name() = 'utml:group']/utml:read-only/child::node()"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="ancestor::*[name() = 'utml:form']/utml:read-only/child::node()"/>
- </xsl:otherwise>
- </xsl:choose>
- </out:variable>
- <out:variable name="{$group-prefix}selected-value">
- <out:choose>
- <out:when test="key('env-param', '{@name}')"><out:value-of select="key('env-param', '{@name}')"/></out:when>
- <out:otherwise><xsl:copy-of select="utml:default-value/child::node()"/></out:otherwise>
- </out:choose>
- </out:variable>
- <xsl:choose>
- <xsl:when test="(utml:read-only) or (ancestor::*[name() = 'utml:form']/utml:read-only) or (ancestor::*[name() = 'utml:group']/utml:read-only)">
- <out:choose>
- <out:when test="${$group-prefix}read-only = 'true'">
- <xsl:apply-templates/>
- </out:when>
- <out:otherwise>
- <select>
- <xsl:copy-of select="@*[(local-name() != 'default-value') and (local-name() != 'readonly') and namespace-uri() != $utml-namespace-uri]"/>
- <xsl:apply-templates/>
- </select>
- </out:otherwise>
- </out:choose>
- </xsl:when>
- <xsl:otherwise>
- <select>
- <xsl:copy-of select="@*[(local-name() != 'default-value') and (local-name() != 'readonly') and namespace-uri() != $utml-namespace-uri]"/>
- <xsl:apply-templates/>
- </select>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- ================================================ -->
- <!-- ===================== Option =================== -->
- <!-- ================================================ -->
-
- <!--
-
- <utml:option (value="fieldvalue")>
- (<utml:value>....</utml:value>) - other place for value
- </utml:input>
-
- Notes:
- -if the value of the option isn't dynamic use the attribute and the code becomes smaller
-
- -->
- <xsl:template match="utml:option" priority="1">
- <xsl:variable name="group-prefix">
- <xsl:value-of select="concat(ancestor::*[name() = 'utml:select']/@name, '-')"/>
- </xsl:variable>
- <!-- out:value-of select="'test124'"/>
- <out:value-of select="${$group-prefix}selected-value"/>
- <out:value-of select="'{@value}'"/ -->
- <!-- this will try and streamline the code for when the value is hardcoded and not generated -->
- <xsl:choose>
- <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)">
- <out:choose>
- <out:when test="${$group-prefix}read-only = 'true'">
- <xsl:choose>
- <xsl:when test="@value">
- <out:if test="'{@value}' = ${$group-prefix}selected-value">
- <xsl:apply-templates/>
- </out:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="option-prefix">
- <xsl:value-of select="concat($group-prefix, position())"/>
- </xsl:variable>
- <out:variable name="{$option-prefix}value">
- <xsl:call-template name="get-value">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </out:variable>
- <out:if test="${$option-prefix}value = ${$group-prefix}selected-value">
- <xsl:apply-templates/>
- </out:if>
- </xsl:otherwise>
- </xsl:choose>
- </out:when>
- <out:otherwise>
- <xsl:choose>
- <xsl:when test="@value">
- <option>
- <xsl:copy-of select="@*[(local-name() != 'selected') and namespace-uri() != $utml-namespace-uri]"/>
- <out:if test="'{@value}' = ${$group-prefix}selected-value"><out:attribute name="selected">true</out:attribute></out:if>
- <xsl:apply-templates/>
- </option>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="option-prefix">
- <xsl:value-of select="concat($group-prefix, position())"/>
- </xsl:variable>
- <out:variable name="{$option-prefix}value">
- <xsl:call-template name="get-value">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </out:variable>
- <option>
- <xsl:copy-of select="@*[(local-name() != 'selected') and (local-name() != 'value') and namespace-uri() != $utml-namespace-uri]"/>
- <out:attribute name="value"><out:value-of select="${$option-prefix}value"/></out:attribute>
- <out:if test="${$option-prefix}value = ${$group-prefix}selected-value"><out:attribute name="selected">true</out:attribute></out:if>
- <xsl:apply-templates/>
- </option>
- </xsl:otherwise>
- </xsl:choose>
- </out:otherwise>
- </out:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="@value">
- <option>
- <xsl:copy-of select="@*[(local-name() != 'selected') and namespace-uri() != $utml-namespace-uri]"/>
- <out:if test="'{@value}' = ${$group-prefix}selected-value"><out:attribute name="selected">true</out:attribute></out:if>
- <xsl:apply-templates/>
- </option>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="option-prefix">
- <xsl:value-of select="concat($group-prefix, position())"/>
- </xsl:variable>
- <out:variable name="{$option-prefix}value">
- <xsl:call-template name="get-value">
- <xsl:with-param name="node" select="."/>
- </xsl:call-template>
- </out:variable>
- <option>
- <xsl:copy-of select="@*[(local-name() != 'selected') and (local-name() != 'value') and namespace-uri() != $utml-namespace-uri]"/>
- <out:attribute name="value"><out:value-of select="${$option-prefix}value"/></out:attribute>
- <out:if test="${$option-prefix}value = ${$group-prefix}selected-value"><out:attribute name="selected">true</out:attribute></out:if>
- <xsl:apply-templates/>
- </option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-
- </xsl:template>
-
-
- <!-- ================================================ -->
- <!-- ===================== A:HREF =================== -->
- <!-- ================================================ -->
-
- <!--
-
- <utml:a (href="javascriptfunction") (utml:op="operation") *utml:formName="pform"> * - not needed when in a utml:form
- (<utml:href>....</utml:href>) - other place for href
- (<utml:op>....</utml:op>) - other place for operation
- </utml:input>
-
- Notes:
- -default operation is maintain
- -if you aren't directly inside a form use utml:formName to define the name - if you are it isn't needed
- -the href has to be a valid javascript call with ; at the end
-
- -->
-
- <xsl:template match="utml:a[namespace-uri() = $utml-namespace-uri]" priority="1">
- <!-- get the utml:op value, currently it can only be plain text... -->
- <xsl:variable name="op">
- <xsl:choose>
- <xsl:when test="./@utml:op = 'push' or ./@utml:op = 'stack-up'">
- <xsl:value-of select="'push'"/>
- </xsl:when>
- <xsl:when test="./@utml:op = 'pop' or ./@utml:op = 'stack-down'">
- <xsl:value-of select="'pop'"/>
- </xsl:when>
- <xsl:when test="./@utml:op = 'drop' or ./@utml:op = 'stack-down-save'">
- <xsl:value-of select="'drop'"/>
- </xsl:when>
- <xsl:when test="./@utml:op = 'submit'">
- <xsl:value-of select="'submit'"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="'maintain'"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- get the defaultKey -->
- <xsl:variable name="utml-defaultKey">
- <xsl:if test="utml:defaultKey">
- <xsl:value-of select="utml:defaultKey"/>
- </xsl:if>
- </xsl:variable>
- <xsl:variable name="utml-defaultAct">
- <xsl:if test="utml:defaultAct">
- <xsl:value-of select="utml:defaultAct"/>
- </xsl:if>
- </xsl:variable>
-
- <!-- add key handlers for the link -->
- <xsl:variable name="utml-kbA11y">
- <xsl:if test="@utml:kbA11y">
- <xsl:value-of select="@utml:kbA11y"/>
- </xsl:if>
- </xsl:variable>
- <!-- get the target -->
- <xsl:variable name="utml-target">
- <xsl:choose>
- <xsl:when test="@utml:target"><xsl:value-of select="@utml:target"/></xsl:when>
- <xsl:when test="utml:target"><xsl:copy-of select="utml:target/child::node()"/></xsl:when>
- </xsl:choose>
- </xsl:variable>
- <!-- get the validate -->
- <xsl:variable name="utml-validate">
- <xsl:choose>
- <xsl:when test="@utml:validate"><xsl:value-of select="@utml:validate"/></xsl:when>
- <xsl:when test="utml:validate"><xsl:copy-of select="utml:validate/child::node()"/></xsl:when>
- </xsl:choose>
- </xsl:variable>
-
- <!-- get the href -->
- <xsl:variable name="utml-href">
- <xsl:choose>
- <xsl:when test="@utml:href"><xsl:value-of select="@utml:href"/></xsl:when>
- <xsl:when test="utml:href"><xsl:copy-of select="utml:href/child::node()"/></xsl:when>
- </xsl:choose>
- </xsl:variable>
-
- <!-- get the name of the parent form, necessary for setting form variables via JS -->
- <xsl:variable name="parent-form-name">
- <xsl:choose>
- <xsl:when test="ancestor::*[name() = 'utml:form' and namespace-uri() = $utml-namespace-uri]">
- <xsl:value-of select="ancestor::*[name() = 'utml:form' and namespace-uri() = $utml-namespace-uri]/@name"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@utml:formName"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="$utml-defaultKey='active'">
- <script language="JavaScript">
- function enterdfaultact()
- {
- var currentFocusEl = document.activeElement;
- if (currentFocusEl.tagName.toLowerCase()=='a' && currentFocusEl.getAttribute("class") == 'showOnFocus'){
- return true;
- }
- <xsl:if test="$utml-defaultAct != ''"><out:value-of select="$utml-defaultAct"/></xsl:if>
- <xsl:text/><xsl:copy-of select="$utml-href"/><xsl:text/>
- utmlSubmitForm(document.<xsl:value-of select="$parent-form-name"/>,'<xsl:copy-of select="$utml-target"/>','<xsl:value-of select="$op"/>','<xsl:copy-of select="$utml-validate"/>');
- return false;
- }
- </script>
- </xsl:if>
- <!-- Output the HTML anchor -->
- <xsl:choose>
- <xsl:when test="string($utml-kbA11y)='true'">
- <a href="#">
- <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
- <out:attribute name="onclick">javascript:<xsl:copy-of select="$utml-href"/>utmlSubmitForm(document.<xsl:value-of select="$parent-form-name"/>,'<xsl:copy-of select="$utml-target"/>','<xsl:value-of select="$op"/>','<xsl:copy-of select="$utml-validate"/>');</out:attribute>
- <out:attribute name="onkeypress">javascript:if( event.keyCode==13 || event.keyCode==32 || event.charCode==32 )<xsl:text>{</xsl:text>this.onclick(); return false; <xsl:text>}</xsl:text> return true;</out:attribute>
- <xsl:apply-templates/>
- </a>
- </xsl:when>
- <xsl:otherwise>
- <!-- copy all non-utml attributes... -->
- <a>
- <xsl:if test="count(ancestor::*[@role='tablist'])">
- <out:attribute name="role">tab</out:attribute>
- <out:attribute name="aria-selected"><out:value-of select="$isTabSelected"/></out:attribute>
- </xsl:if>
-
- <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
- <out:attribute name="href">
- <out:text/>javascript:<xsl:copy-of select="$utml-href"/>utmlSubmitForm(document.<xsl:value-of select="$parent-form-name"/>,'<xsl:copy-of select="$utml-target"/>','<xsl:value-of select="$op"/>','<xsl:copy-of select="$utml-validate"/>');
- </out:attribute>
- <!--copy all non-utml child elements... -->
- <xsl:apply-templates/>
- </a>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="utml:group[namespace-uri() = $utml-namespace-uri]" priority="1">
- <xsl:apply-templates/>
- </xsl:template>
-
- <!-- the main engine -->
- <xsl:template match="*[namespace-uri() = $utml-namespace-uri]" priority="0"/>
-
- <xsl:template match="*">
- <xsl:copy>
- <xsl:copy-of select="@*[namespace-uri() != $utml-namespace-uri]"/>
- <xsl:apply-templates/>
- </xsl:copy>
- </xsl:template>
-
- </xsl:stylesheet>
|