| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 | 
							- <?xml version="1.0" encoding="UTF-8"?>
 
- <!--
 
-     Licensed Materials - Property of IBM
 
-     IBM Cognos Products: ps
 
-     (C) Copyright IBM Corp. 2005, 2013
 
-     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:xts="http://developer.cognos.com/schemas/xts/" 
 
- 								xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt">
 
- 	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
 
- 	<xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
 
- 	<!-- ======================================================== -->
 
- 	<!--                       Variables                          -->
 
- 	<!-- ======================================================== -->
 
- 	<!-- NOTE:
 
- 			To prevent errors from showing up in the Tomcat window when not using the pre-compiled templates, client
 
- 			side validation has been forced off in the version of validation.xslt installed in the templates directory.
 
- 			To re-enable validation, do the following:
 
- 				1. Replace the value of the below rulesFile variable with the following select value:
 
- 					select="document( 'cafrules.xml' )/cafrules/variables"
 
- 				2. Place cafrules.xml in templates/ps and templates/ps/prompting
 
- 	-->
 
- 	<xsl:variable name="rulesFile"><noop/></xsl:variable>
 
- 	<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
 
- 	<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
 
- 	<!-- ======================================================== -->
 
- 	<!--       Applies validation rules to the form field         -->
 
- 	<!-- ======================================================== -->
 
- 	<xsl:template name="applyValidation">
 
- 		<xsl:param name="name"/>
 
- 		
 
- 		<!-- We need the field name in lower case -->
 
- 		<xsl:variable name="fieldName">
 
- 			<xsl:value-of select="translate($name,$ucletters,$lcletters)"/>
 
- 		</xsl:variable>
 
- 		<!-- Find the parameter in the caf rules file -->
 
- 		<xsl:variable name="theRule" select="$rulesFile/variable[@name=$fieldName]"/>
 
- 		<xsl:if test="$theRule">
 
- 			
 
- 			<!-- Set a maxlen on the field if it's not already there -->
 
- 			<xsl:if test="$theRule/@maxlen">				
 
- 				<xsl:if test="not(@maxlength)">
 
- 					<xsl:attribute name="maxlength">
 
- 						<xsl:value-of select="$theRule/@maxlen"/>
 
- 					</xsl:attribute>
 
- 				</xsl:if>
 
- 			</xsl:if>
 
-       
 
-       <!--  
 
-             If it is a int or uint and no maxlength is set: set it to 32: 
 
-        -->
 
-       <xsl:if test="$theRule/@type = 'int' or $theRule/@type = 'uint'">
 
-         <xsl:if test="not(@maxlength) and not($theRule/@maxlen)">
 
-           <xsl:attribute name="maxlength">32</xsl:attribute>
 
-         </xsl:if>
 
-       </xsl:if>
 
-       
 
- 			
 
- 			<!-- Add a call for this validation function -->
 
- 			<xsl:variable name="validationFunction">
 
- 				<xsl:call-template name="validationFunctionName">
 
- 					<xsl:with-param name="fieldName" select="$fieldName"/>
 
- 				</xsl:call-template>
 
- 			</xsl:variable>
 
- 			
 
- 			<!-- if there was an onblur handler passed in then enhance it with validation checking otherwise add a new onblur handler that does the validation -->
 
- 			<!-- BUG FIX -  541871.0; Capture the key strokes to prevent clearing input fields when tabbing to Cancel or Close key (KeyDownHandler)-->
 
- 			<out:variable name="handler">
 
- 				<BlurHandler>
 
- 					<xsl:choose>
 
- 						<xsl:when test="not(@onblur)">javascript:<xsl:value-of select="xtsext:javascriptencode(string($validationFunction))"/>(this);</xsl:when> <!-- SEC_INFO: No threat. $validationFunction is based on input/textarea names within the template, and it is only used if a matching rule name is found in the CAF rules -->
 
- 						<xsl:otherwise><xsl:variable name="oldOnBlur" select="@onblur"/><xsl:value-of select="$oldOnBlur"/>;<xsl:value-of select="xtsext:javascriptencode(string($validationFunction))"/>(this);</xsl:otherwise> <!-- SEC_INFO: No threat. $validationFunction is based on input/textarea names within the template, and it is only used if a matching rule name is found in the CAF rules -->
 
- 					</xsl:choose>	
 
- 				</BlurHandler>
 
- 				<KeyDownHandler>javascript:setGlobalKeyDownHandler(event);</KeyDownHandler>
 
- 			</out:variable>
 
- 			
 
- 			<!-- if the browser is ie then we need to add the onblur handler as an onfocusout handler so that we can check to see if the target of the onblur is a cancel or close button -->
 
- 			<out:choose>
 
- 				<out:when test="$browser = 'ie'">
 
- 					<out:attribute name="onkeydown">
 
- 						<out:value-of select="$handler/KeyDownHandler"/>
 
- 					</out:attribute>
 
- 					<out:attribute name="onfocusout">
 
- 						<out:value-of select="$handler/BlurHandler"/>
 
- 					</out:attribute>
 
- 				</out:when>
 
- 				<out:otherwise>
 
- 					<out:attribute name="onblur">
 
- 						<out:value-of select="$handler/BlurHandler"/>
 
- 					</out:attribute>
 
- 				</out:otherwise>
 
- 			</out:choose>
 
- 		</xsl:if>
 
- 		
 
- 	</xsl:template>
 
- 	<xsl:template name="createValidationFunction">
 
- 		<xsl:param name="name"/>
 
- 		<xsl:param name="validateobject" select="''"/>
 
- 		
 
- 		<xsl:variable name="fieldName">
 
- 			<xsl:value-of select="translate($name,$ucletters,$lcletters)"/>
 
- 		</xsl:variable>
 
- 		<!-- Find the parameter in the caf rules file -->
 
- 		<xsl:variable name="theRule" select="$rulesFile/variable[@name=$fieldName]"/>
 
- 		<xsl:if test="$theRule">
 
- 			<xsl:variable name="validationFunction">
 
- 				<xsl:call-template name="validationFunctionName">
 
- 					<xsl:with-param name="fieldName" select="$fieldName"/>
 
- 				</xsl:call-template>
 
- 			</xsl:variable>
 
- 			function <xsl:value-of select="xtsext:javascriptencode(string($validationFunction))"/>(field) <!-- SEC_INFO: No threat. $validationFunction is based on input/textarea names within the template, and it is only used if a matching rule name is found in the CAF rules -->
 
- 			{	
 
- 				<out:if test="$browser = 'ie'">
 
- 					if (cafGKeyPress != 9 && event.toElement &&  (event.toElement.id == "IDS_CANCEL" || event.toElement.id == "IDS_CLOSE" || event.toElement.id == "IDS_CLOSE_ICON"<xsl:if test="$validateobject !=''"> || event.toElement.name == "<xsl:value-of select="$validateobject"/>"</xsl:if>))
 
- 					{  
 
- 						<xsl:if test="$validateobject != ''">
 
- 						if( event.toElement.name == "<xsl:value-of select="$validateobject"/>")
 
- 							field.value="";
 
- 						else
 
- 						</xsl:if>
 
- 						  field.form.reset();
 
-   				  return;
 
- 					} else if (cafGKeyPress == 9) {
 
- 						cafGKeyPress = "";
 
- 					}
 
- 					
 
- 				</out:if>
 
-         
 
- 				if (window.CAFReportValidationError) {
 
- 					var value = field.value;
 
- 					var highlight = null;
 
- 			<!-- check for invalid strings -->
 
- 			<xsl:if test="not( $theRule[@skipglobalrule = 'true'] )">
 
- 					var res = CAFContainsInvalidString(value);
 
- 					if (res) {
 
- 						CAFReportValidationError(cafInvalidStringMsg + res);
 
- 						highlight = res;
 
- 					}
 
- 			</xsl:if>
 
- 			
 
- 			<!-- Check for maximum length. This is needed for textareas as they don't support the maxlength attribute. -->
 
- 			<xsl:if test="$theRule/@maxlen">
 
- 					if (value.length > <xsl:value-of select="$theRule/@maxlen"/>)
 
- 					{
 
- 						CAFReportValidationError(cafInvalidLength);
 
- 						highlight=value;
 
- 					}
 
- 			</xsl:if>
 
- 			<!-- Check for int/uint types. -->
 
- 			<xsl:if test="$theRule/@type = 'int'">
 
- 				if (value != null && value != "") {
 
-           if (!CAFisInteger(value)) {
 
-             CAFReportValidationError(cafInvalidInteger);
 
-             highlight = value;
 
-           }
 
-         }
 
- 			</xsl:if>
 
- 			<xsl:if test="$theRule/@type = 'uint'">
 
-           if (value != null && value != "") {
 
-             if (!CAFisInteger(value,true)) {
 
-               CAFReportValidationError(cafInvalidUnsignedInteger);
 
-               highlight = value;
 
-             }
 
- 					}
 
- 			</xsl:if>
 
- 			<!-- check for int/uint patternrefs -->
 
- 			<xsl:for-each select="$theRule/patternref">
 
- 				<xsl:choose>
 
- 					<xsl:when test="@name = 'type_int'">
 
-             if (value != null && value != "") {
 
-               if (!CAFisInteger(value)) {
 
-     						CAFReportValidationError(cafInvalidInteger);
 
-     						highlight = value;
 
-     					}
 
-             }
 
- 					</xsl:when>
 
- 					<xsl:otherwise>
 
- 						<xsl:if test="@name = 'type_uint'">
 
-     					if (value != null && value != "") {
 
-                 if (!CAFisInteger(value,true)) {
 
-                   CAFReportValidationError(cafInvalidUnsignedInteger);
 
-                   highlight = value;
 
-                 }
 
-               }
 
- 						</xsl:if>
 
- 					</xsl:otherwise>
 
- 				</xsl:choose>
 
- 			</xsl:for-each>
 
- 					if (highlight != null) {
 
-             cafValidation_field = field;
 
-             cafValidation_highlight = highlight;
 
-             //use the setTimout to fix the following event conflicts 
 
-             //in FF: clicking tab selects the next field,
 
-             //in IE: message is displayed twice when the next field is a select element          
 
- 						setTimeout("CAFSelectText(cafValidation_field, cafValidation_highlight);",0);
 
- 					}
 
- 				}
 
- 			}
 
- 		</xsl:if>
 
- 		
 
- 	</xsl:template>
 
- 	
 
- 	<xsl:template name="validationFunctionName">
 
- 		<xsl:param name="fieldName"/>
 
- 		<xsl:value-of select="concat('caf_', $fieldName)"/>
 
- 	</xsl:template>
 
- 	<!-- ======================================================== -->
 
- 	<!--                     Form handler                         -->
 
- 	<!-- ======================================================== -->
 
- 	<xsl:template match="form">
 
- 		<xsl:copy>			
 
- 			<xsl:copy-of select="@*"/>
 
- 			<xsl:apply-templates/>
 
- 			
 
- 			<script language="javascript" src="{'{$webRoot}'}/cr1/caf.js"/>
 
- 			<script language="javascript" src="{'{$webcontent}'}/portal/js/validation.js"/>
 
- 			<script language="javascript">
 
- 				var cafInvalidStringMsg = "<xts:string id="IDS_VAL_ERR_INVALID_STRING" encode="javascript"/>";
 
- 				var cafInvalidInteger = "<xts:string id="IDS_VAL_ERR_INVALID_INTEGER" encode="javascript"/>";
 
- 				var cafInvalidUnsignedInteger = "<xts:string id="IDS_VAL_ERR_UNSIGNED_INTEGER" encode="javascript"/>";
 
- 				var cafInvalidLength = "<xts:string id="IDS_VAL_ERR_MAXIMUM_LENGTH" encode="javascript"/>";
 
- 				<out:if test="$browser = 'ie'">
 
- 					var cafGKeyPress = ""
 
- 					function setGlobalKeyDownHandler(event)
 
- 					{
 
- 						cafGKeyPress = event.keyCode;
 
- 					}
 
- 				</out:if>
 
- 			</script>
 
- 			
 
- 		</xsl:copy>
 
- 	</xsl:template>
 
- 	<!-- ======================================================== -->
 
- 	<!--          Handlers for individual form fields             -->
 
- 	<!-- ======================================================== -->
 
- 	<xsl:template match="input[@type='text']">
 
- 		<!-- validateobject contains the object that focus can be set to without the validation error being triggered (only an issue with IE) -->
 
- 		<xsl:variable name="validateobject" select="@validateobject"/>
 
- 		<script language="javascript">
 
- 			<xsl:call-template name="createValidationFunction">
 
- 				<xsl:with-param name="name" select="@name"/>
 
- 				<xsl:with-param name="validateobject" select="$validateobject"/>
 
- 			</xsl:call-template>
 
- 		</script>
 
- 		<xsl:copy>
 
- 			<xsl:copy-of select="@*[not(name()='validateobject')]"/>
 
- 			<xsl:call-template name="applyValidation">
 
- 				<xsl:with-param name="name" select="@name"/>
 
- 			</xsl:call-template>
 
- 			<xsl:apply-templates/>
 
- 		</xsl:copy>
 
- 	</xsl:template>
 
- 	
 
- 	<xsl:template match="textarea">
 
- 		<!-- validateobject contains the object that focus can be set to without the validation error being triggered (only an issue with IE) -->
 
- 		<xsl:variable name="validateobject" select="@validateobject"/>
 
- 		<script language="javascript">
 
- 			<xsl:call-template name="createValidationFunction">
 
- 				<xsl:with-param name="name" select="@name"/>
 
- 				<xsl:with-param name="validateobject" select="$validateobject"/>
 
- 			</xsl:call-template>
 
- 		</script>
 
- 		<xsl:copy>
 
- 			<xsl:copy-of select="@*[not(name()='validateobject')]"/>
 
- 			<xsl:call-template name="applyValidation">
 
- 				<xsl:with-param name="name" select="@name"/>
 
- 			</xsl:call-template>
 
- 			<xsl:apply-templates/>
 
- 		</xsl:copy>
 
- 	</xsl:template>	
 
- 	
 
- 	<xsl:template match="*">
 
- 		<xsl:copy>
 
- 			<xsl:copy-of select="@*"/>
 
- 			<xsl:apply-templates/>
 
- 		</xsl:copy>
 
- 	</xsl:template>
 
- </xsl:stylesheet>
 
 
  |