| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 | <?xml version="1.0"?><!-- Licensed Materials - Property of IBM IBM Cognos Products: fmmd (C) Copyright IBM Corp. 2003, 2010 US Government Users Restricted Rights - Use, duplication or disclosure  restricted by GSA ADP Schedule Contract with IBM Corp.--><!--XSLT version 1-->  <!--Action Log Upgrade NOTES:  There are 5 user gestures in FM 1.0 RTM that need to be upgraded to run in FM 1.1 GA    (1) Give visibility rights - calls "SetObjectAccess" action    first param - object that exists in the DOM parameter  second param - the roles and rule specified.  third param - "0" indicates not to do anything to the other role-based packages that exist in the model    (2) Remove visibility rights - calls "SetObjectAccess" action    first param - object that exists in the DOM parameter  second param - the roles and rule specified.  third param - "0" indicates not to do anything to the other role-based packages that exist in the model    (3) Clear visibility rights - calls "Modify" action (on "secured" property, setting value to "unsecured").    first param - ID of the object specified in the given property handle ID  second param - the "Everyone" role, together with a rule of "unspecified".  third param - "1" - indicates to remove the rule for any other role-based package as well.    (4) Merge  - drop the first input parameter  - change the value of the last argument to 1    (5) SetPromptValue  - the type of the second argument has changed from string to ccl-node  - example of the old one:  		<action seq="30" type="SetPromptValue">  			<inputparams>  				<param seq="1" type="i18nstring">  					<value>abc</value>  				</param>  				<param seq="2" type="i18nstring">  					<value>10</value>  				</param>  			</inputparams>  			...  		</action>  		  - the second param should change to:  <param seq="2" type="cclnode">  	<value><![CDATA[<<item><name>abc</name><type>xsdString</type><value><item xsi:type="bus:simpleParmValueItem"><inclusive>true</inclusive><use>10</use></item></value></item>]]></value>  </param>  -->  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  	<xsl:output method="xml" indent="yes"/>  	<!--root match-->  	<xsl:template match="/">  		<!--make sure that this transformation is performed on a version 1.0 FM Action Log -->  		<xsl:if test="not(/*[local-name() = 'bmtactionlog']) ">  			<xsl:message terminate="yes">The input file for this transformer must be a FM Action log.  Exiting...  </xsl:message>  		</xsl:if>  		<xsl:if test="/*[local-name() = 'bmtactionlog']/@version">  			<xsl:message terminate="yes">The input file for this transformer must be a FM 1.0 Action log.  Exiting...  </xsl:message>  		</xsl:if>  		<xsl:apply-templates/>  	</xsl:template>     	<!-- Default copy override:  CData fix -->     	<xsl:template match="value/text()">     		<xsl:if test="name(.) = 'cdata'">     			<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>     			<xsl:value-of disable-output-escaping="yes" select="."/>     			<xsl:text disable-output-escaping="yes">]]></xsl:text>     		</xsl:if>     		<xsl:if test="not(name(.) = 'cdata')">     			<xsl:value-of disable-output-escaping="no" select="."/>     		</xsl:if>     	</xsl:template>  	<!-- general copy -->  	<xsl:template match="*">  		<xsl:element name="{name(.)}">  			<xsl:for-each select="@*">  				<xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>  			</xsl:for-each>  			<xsl:apply-templates select="node()"/>  		</xsl:element>  	</xsl:template>  	<!-- Change the actionlog version to 1.1 version-->  	<xsl:template match="*[local-name()='bmtactionlog']">  		<xsl:element name="bmtactionlog">  			<xsl:for-each select="@*">  				<xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>  			</xsl:for-each>  			<!--Insert the version tag v1.0 (there is tag version tag for the FM 1.0 release) to 1.1-->  			<xsl:attribute name="version">1.1</xsl:attribute>  			<xsl:apply-templates select="node()"/>  		</xsl:element>  	</xsl:template>  	<!-- (1) & (2) Change the Transaction/action for objectaccess to reflect the 1.1 schema changes for adding removing visibility rights-->  	<xsl:template match="*[local-name()='action' and @type = 'SetObjectAccess']/inputparams/param">  		<xsl:call-template name="CDATA2ParamHandles">  			<xsl:with-param name="string" select="./value/text()"/>  			<xsl:with-param name="search" select="string('refobj=')"/>  			<xsl:with-param name="seq_val" select="1"/>  			<xsl:with-param name="cdata_str" select="./value/text()"/>  		</xsl:call-template>  	</xsl:template>  	<!-- Helper template for above:  Generate the inputparams/param handles, param cclnode, and param integer using the MR1 param/value/CDATA -->  	<xsl:template name="CDATA2ParamHandles">  		<xsl:param name="string"/>  		<xsl:param name="search"/>  		<xsl:param name="seq_val"/>  		<xsl:param name="cdata_str"/>  		<xsl:if test="contains($string, $search)">  			<xsl:element name="param">  				<xsl:attribute name="seq"><xsl:value-of select="$seq_val"/></xsl:attribute>  				<xsl:attribute name="type">handle</xsl:attribute>  				<!-- NOTE:  <mappingpath/> elements are optional as there is no mechanism to supply these values from 1.0RTM.  The line below is commented out but there for completeness. -->  				<!--<xsl:element name="mappingpath">PLACEHOLDER</xsl:element> -->  				<xsl:element name="value">  					<xsl:value-of select="substring-before(substring-after(substring-after($string, $search), '"'), '"')"/>  				</xsl:element>  			</xsl:element>  			<!-- Recurse through the CDATA for the remaining list of param handles -->  			<xsl:call-template name="CDATA2ParamHandles">  				<xsl:with-param name="string" select="substring-after($string, $search)"/>  				<xsl:with-param name="search" select="$search"/>  				<xsl:with-param name="seq_val" select="number($seq_val+1)"/>  				<xsl:with-param name="cdata_str" select="$cdata_str"/>  			</xsl:call-template>  		</xsl:if>  		<xsl:if test="not(contains($string, $search))">  			<xsl:element name="param">  				<xsl:attribute name="seq"><xsl:value-of select="$seq_val"/></xsl:attribute>  				<xsl:attribute name="type">cclnode</xsl:attribute>  				<xsl:element name="value">  					<xsl:call-template name="CDATAreformat">  						<xsl:with-param name="cdata_str" select="$cdata_str"/>  					</xsl:call-template>  				</xsl:element>  			</xsl:element>  			<xsl:element name="param">  				<xsl:attribute name="seq"><xsl:value-of select="number($seq_val+1)"/></xsl:attribute>  				<xsl:attribute name="type">int</xsl:attribute>  				<xsl:element name="value">0</xsl:element>  			</xsl:element>  		</xsl:if>  	</xsl:template>  	<!-- Helper template for above:  Reformat the CDATA element for FM 1.1-->  	<xsl:template name="CDATAreformat">  		<xsl:param name="cdata_str"/>  		<xsl:variable name="object" select="substring-before(substring-after($cdata_str, '<object'), '</object>')"/>  		<xsl:variable name="rule" select="substring-before(substring-after($object, 'rule="'), '"')"/>  		<xsl:variable name="rule1">  			<xsl:call-template name="substring-replace">  				<xsl:with-param name="string" select="$rule"/>  				<xsl:with-param name="search" select="string('include')"/>  				<xsl:with-param name="replace" select="string('allow')"/>  			</xsl:call-template>  		</xsl:variable>  		<xsl:variable name="rule2">  			<xsl:call-template name="substring-replace">  				<xsl:with-param name="string" select="$rule1"/>  				<xsl:with-param name="search" select="string('hide')"/>  				<xsl:with-param name="replace" select="string('deny')"/>  			</xsl:call-template>  		</xsl:variable>  		<xsl:variable name="rule3" select="concat(concat(string('<rule>'), $rule2), string('</rule>'))"/>  		<xsl:variable name="access" select="concat('<access', substring-after($object, '<access'))"/>  		<xsl:variable name="securityObject">  			<xsl:call-template name="substring-replace">  				<xsl:with-param name="string" select="$access"/>  				<xsl:with-param name="search" select="string('access')"/>  				<xsl:with-param name="replace" select="string('securityObject')"/>  			</xsl:call-template>  		</xsl:variable>  		<xsl:variable name="AddRules">  			<xsl:call-template name="substring-replace">  				<xsl:with-param name="string" select="$securityObject"/>  				<xsl:with-param name="search" select="string('/>')"/>  				<xsl:with-param name="replace" select="concat(concat(string('>'), $rule3), string('</securityObject>'))"/>  			</xsl:call-template>  		</xsl:variable>  		<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>  		<xsl:element name="objectAccess">  			<xsl:value-of disable-output-escaping="yes" select="$AddRules"/>  		</xsl:element>  		<xsl:text disable-output-escaping="yes">]]></xsl:text>  	</xsl:template>  	<!-- (3) Convert the MR1 Transaction/action modify for removing visibility rights into a 11GA Transaction\action SetObjectAccess call -->  	<xsl:template match="*[local-name()='action' and @type = 'Modify']">  		<xsl:choose>  			<xsl:when test="contains(./inputparams/param/value, '/O/secured')">  				<xsl:variable name="handle" select="concat('[', substring-after(./inputparams/param/value, '/['))"/>  				<action seq="1" type="SetObjectAccess">  					<inputparams>  						<param seq="1" type="handle">  							<value>  								<xsl:value-of select="$handle"/>  							</value>  						</param>  						<param seq="2" type="cclnode">  							<value>  								<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>  								<xsl:text disable-output-escaping="yes"><![CDATA[<objectAccess><securityObject type="role" displayPath="Everyone [Directory > Cognos]" cmSearchPath="CAMID("::Everyone")"><rule>unspecified</rule></securityObject></objectAccess>]]></xsl:text>  								<xsl:text disable-output-escaping="yes">]]></xsl:text>  							</value>  						</param>  						<param seq="3" type="int">  							<value>1</value>  						</param>  					</inputparams>  					<domchanges/>  				</action>  			</xsl:when>  			<xsl:otherwise>  				<!-- standard copy -->  				<xsl:element name="{name(.)}">  					<xsl:for-each select="@*">  						<xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>  					</xsl:for-each>  					<xsl:apply-templates select="node()"/>  				</xsl:element>  			</xsl:otherwise>  		</xsl:choose>  	</xsl:template>  	<!-- (4) Merge:  drop the first input parameter and change the value of the last argument to 1 -->  	<xsl:template match="/bmtactionlog/transaction/action[@type = 'Merge']/inputparams">  		<xsl:element name="{name(.)}">  			<xsl:for-each select="param">  				<xsl:variable name="newseq">  					<xsl:number count="param[ not (@seq = '1')]"/>  				</xsl:variable>  				<xsl:choose>  					<xsl:when test="@seq = '1'">  						<!-- drop the first input param -->  					</xsl:when>  					<xsl:when test="@seq = last()">  						<!-- resequence last param and set it's value to one -->  						<xsl:element name="{name(.)}">  							<!-- resequence -->  							<xsl:attribute name="seq"><xsl:value-of select="$newseq"/></xsl:attribute>  							<xsl:attribute name="type">integer</xsl:attribute>  							<!-- set value to 1 -->  							<xsl:element name="value">1</xsl:element>  						</xsl:element>  					</xsl:when>  					<xsl:otherwise>  						<!-- resequence param -->  						<xsl:element name="{name(.)}">  							<!-- copy old -->  							<xsl:for-each select="@*">  								<xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>  							</xsl:for-each>  							<!-- resequence -->  							<xsl:attribute name="seq"><xsl:value-of select="$newseq"/></xsl:attribute>  							<xsl:apply-templates select="node()"/>  						</xsl:element>  					</xsl:otherwise>  				</xsl:choose>  			</xsl:for-each>  		</xsl:element>  	</xsl:template>  	<!-- (5) SetPromptValue:  The type of the second argument has changed from string to cclnode-->  	<xsl:template match="/bmtactionlog/transaction/action[@type = 'SetPromptValue']/inputparams/param[@seq='2' and @type='i18nstring']">  		<xsl:element name="param">  			<xsl:attribute name="seq">2</xsl:attribute>  			<xsl:attribute name="type">cclnode</xsl:attribute>  			<xsl:element name="value">  				<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>  				<xsl:text disable-output-escaping="yes"><![CDATA[<item 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><name>]]></xsl:text>  				<xsl:value-of select="../param[@seq='1']/value"/>  				<xsl:text disable-output-escaping="yes"><![CDATA[</name><type>xsdString</type><value><item xsi:type="bus:simpleParmValueItem"><inclusive>true</inclusive><use>]]></xsl:text>  				<xsl:value-of select="./value"/>  				<xsl:text disable-output-escaping="yes"><![CDATA[</use></item></value></item>]]></xsl:text>  				<xsl:text disable-output-escaping="yes">]]></xsl:text>  			</xsl:element>  		</xsl:element>  	</xsl:template>  	<!-- Helper function:  Substring Replace-->  	<xsl:template name="substring-replace">  		<xsl:param name="string"/>  		<xsl:param name="search"/>  		<xsl:param name="replace"/>  		<xsl:choose>  			<xsl:when test="contains($string, $search)">  				<xsl:value-of select="concat(substring-before($string, $search), $replace)"/>  				<xsl:call-template name="substring-replace">  					<xsl:with-param name="string" select="substring-after($string, $search)"/>  					<xsl:with-param name="search" select="$search"/>  					<xsl:with-param name="replace" select="$replace"/>  				</xsl:call-template>  			</xsl:when>  			<xsl:otherwise>  				<xsl:value-of select="$string"/>  			</xsl:otherwise>  		</xsl:choose>  	</xsl:template>  </xsl:stylesheet>   
 |