123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: cpscrn
- (C) Copyright IBM Corp. 2005, 2011
- 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:val="http://developer.cognos.com/schemas/validator/1/">
- <!--
- the following imports requires these variables to be defined:
- $metaData, $interactions, $logic, $userPreferences, $navRequest, $navResponse
- -->
- <xsl:import href="/common/propeditor/types/xsdtypes.xslt"/>
- <xsl:import href="/common/propeditor/types/fragextTypes.xslt"/>
- <xsl:import href="/common/propeditor/types/cmtypes.xslt"/>
- <xsl:import href="/common/propeditor/types/cmmtypes.xslt"/>
- <xsl:import href="/common/propeditor/types/generictypes.xslt"/>
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
- <!--
- Variable declarations. The xpath "/*[false()]" provides an empty node set result.
- -->
- <xsl:variable name="metaData" select="/root/fragment/meta"/>
- <xsl:variable name="interactions" select="/root/interactions"/>
- <xsl:variable name="state" select="/root/state"/>
- <xsl:variable name="userPreferences" select="/root/preferences"/>
- <xsl:variable name="logic" select="/*[false()]"/>
- <xsl:variable name="navRequest" select="/*[false()]"/>
- <xsl:variable name="navResponse" select="/*[false()]"/>
- <xsl:key name="env-param" match="/root/interactions/param" use="@name"/>
- <xsl:template match="/">
- <response>
- <fragment>
- <meta>
- <xsl:choose>
- <xsl:when test="$metaData/*[local-name() = 'globalValidator']">
- <globalValidator>
- <!-- first copy in the validator for the target fragment -->
- <xsl:copy-of select="$metaData/*[local-name() = 'globalValidator']/*"/>
- <!-- next copy in the validator of the generic editor -->
- <xsl:copy-of select="/root/input[@name='geMeta']/globalValidator/*"/>
- </globalValidator>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="/root/input[@name='geMeta']/globalValidator"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:copy-of select="$metaData/*[local-name() != 'globalValidator']"/>
- </meta>
- <xsl:if test="not ($interactions/param[@name='privateAction' and (.='save' or .='cancel')])">
- <markup>
- <validator>
- <xsl:apply-templates select="$metaData/customProperties" mode="logic-markup-validator"/>
- </validator>
- </markup>
- </xsl:if>
- </fragment>
- <logic>
- <targetMeta>
- <meta>
- <xsl:for-each select="/root/fragment/*[local-name() = 'meta']/customProperties[string(control/@appearance) != 'hidden']">
- <xsl:choose>
- <xsl:when test="(count(default/value) > 0) and (string(default/value/@xml:lang) = '')">
- <customProperties name="{@name}">
- <xsl:for-each select="./*">
- <xsl:if test="local-name() = 'control'">
- <xsl:call-template name="copyControlElement">
- <xsl:with-param name="controlElement" select="."/>
- </xsl:call-template>
- </xsl:if>
- <xsl:if test="local-name() != 'default' and local-name() != 'control'">
- <xsl:copy-of select="."/>
- </xsl:if>
- </xsl:for-each>
- <default>
- <value xml:lang="{$userPreferences/param[@name='contentLocale']}">
- <xsl:value-of select="default/value"/>
- </value>
- </default>
- </customProperties>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy>
- <xsl:copy-of select="@*"/>
- <xsl:copy-of select="./*[local-name() != 'control']"/>
- <xsl:for-each select="./*[local-name() = 'control']">
- <xsl:call-template name="copyControlElement">
- <xsl:with-param name="controlElement" select="."/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:copy>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </meta>
- </targetMeta>
- </logic>
- </response>
- </xsl:template>
- <xsl:template name="copyControlElement">
- <xsl:param name="controlElement"/>
- <xsl:copy>
- <xsl:copy-of select="$controlElement/@*"/>
- <xsl:variable name="currentGroupID" select="$controlElement/@group"/>
- <xsl:if test="$metaData/controlGroups[@id = $currentGroupID]">
- <xsl:element name="group">
- <xsl:if test="string($metaData/controlGroups[@id = $currentGroupID]/@order) != ''">
- <xsl:attribute name="order"><xsl:value-of select="$metaData/controlGroups[@id = $currentGroupID]/@order"/></xsl:attribute>
- </xsl:if>
- <xsl:value-of select="$metaData/controlGroups[@id = $currentGroupID]/label"/>
- </xsl:element>
- </xsl:if>
- <xsl:copy-of select="$controlElement/*"/>
- </xsl:copy>
- </xsl:template>
- <!-- these are templates required by the markup stage -->
- <xsl:template name="getPropertyValue"/>
- <xsl:template name="relatedControl"/>
- <xsl:template name="keyScript"/>
- <xsl:template name="createLanguageSelector"/>
- <xsl:template match="customProperties" mode="logic-markup-validator">
- <xsl:variable name="prefix" select="substring-before(datatype, ':')"/>
- <xsl:variable name="type" select="substring-after(datatype, ':')"/>
- <xsl:variable name="namespaceSpecificCustomProps">
- <xsl:element name="{$prefix}:{$type}" namespace="{datatype/namespace::*[name() = $prefix]}">
- <xsl:copy-of select="self::node()"/>
- </xsl:element>
- </xsl:variable>
- <xsl:apply-templates select="$namespaceSpecificCustomProps/*" mode="metaValidators"/>
- </xsl:template>
- </xsl:stylesheet>
- <!-- $Header: //cpscrn/main/src/java/etc/webapps/cps/WEB-INF/fragments/producers/common/propeditor/logic.xslt#1 $ -->
- <!-- $DateTime: 2008/10/22 11:12:04 $ -->
- <!-- $Change: 25109 $ -->
|