123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <?xml version="1.0" encoding="UTF-8"?>
- <?xml-stylesheet type="text/xsl" ?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1"
- xmlns="http://developer.cognos.com/schemas/report/1/"
- xmlns:x="http://developer.cognos.com/schemas/report/1/"
- xmlns:str="http://www.ora.com/XSLTCookbook/namespaces/strings"
- extension-element-prefixes="str"
- exclude-result-prefixes="x str"
- >
- <xsl:import href="copy.xslt"/>
-
- <xsl:import href="str.find-last.xslt" xmlns:str="http://www.ora.com/XSLTCookbook/namespaces/strings" />
-
- <xsl:output method="xml" />
-
- <xsl:strip-space elements="*"/>
- <xsl:preserve-space elements="x:defaultSelection x:text"/>
-
-
- <xsl:template name="merge-conditional-style-variable-expressions">
- <xsl:param name="nodes"/>
- <xsl:param name="pos"/>
- <xsl:variable name="current-variable" select="$nodes[$pos]"/>
- <xsl:choose>
- <xsl:when test="$current-variable">
- <xsl:variable name="expr-text" select="$current-variable/x:expression"/>
- <xsl:variable name="tail" select="' then ( 1 ) else ( 0 )'"/>
- <xsl:variable name="head">
- <xsl:call-template name="str:substring-before-last">
- <xsl:with-param name="input" select="$expr-text"/>
- <xsl:with-param name="substr" select="$tail"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="new-expr-text">
- <xsl:value-of select="$head"/>
- <xsl:text> then (</xsl:text>
- <xsl:text> </xsl:text>
- <xsl:text>'</xsl:text>
- <xsl:value-of select="$pos"/>
- <xsl:text>'</xsl:text>
- <xsl:text> )</xsl:text>
- <xsl:text> else (</xsl:text>
- <xsl:call-template name="merge-conditional-style-variable-expressions">
- <xsl:with-param name="nodes" select="$nodes"/>
- <xsl:with-param name="pos" select="$pos+1"/>
- </xsl:call-template>
- <xsl:text> )</xsl:text>
- </xsl:variable>
- <xsl:value-of select="$new-expr-text"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text> </xsl:text>
- <xsl:text>'</xsl:text>
- <xsl:text>0</xsl:text>
- <xsl:text>'</xsl:text>
-
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="x:variableList">
- <xsl:variable name="variable-list" select="."/>
- <xsl:variable name="conditional-style-parents" select="//*[ x:conditionalStyle ]"/>
- <variableList>
- <xsl:for-each select="$conditional-style-parents">
- <xsl:if test="count( x:conditionalStyle ) > 1">
-
- <xsl:variable name="conditional-styles" select="x:conditionalStyle"/>
- <xsl:variable name="referenced-variables" select="$variable-list/x:variable[ @name = $conditional-styles/@refVariable ]"/>
- <variable>
- <xsl:attribute name="name">
- <xsl:call-template name="make-selector-name">
- <xsl:with-param name="parent-node-of-conditional-styles" select="."/>
- </xsl:call-template>
- </xsl:attribute>
- <xsl:attribute name="type">
- <xsl:text>string</xsl:text>
- </xsl:attribute>
- <expression>
- <xsl:call-template name="merge-conditional-style-variable-expressions">
- <xsl:with-param name="nodes" select="$referenced-variables"/>
- <xsl:with-param name="pos" select="1"/>
- </xsl:call-template>
- </expression>
- <variableValueList>
-
- <xsl:for-each select="$referenced-variables">
- <variableValue >
- <xsl:attribute name="value">
- <xsl:value-of select="position()"/>
- </xsl:attribute>
- </variableValue>
- </xsl:for-each>
-
- <variableValue >
- <xsl:attribute name="value">
- <xsl:value-of select="0"/>
- </xsl:attribute>
- </variableValue>
- </variableValueList>
- </variable>
- </xsl:if>
- </xsl:for-each>
-
-
- <xsl:copy-of select="x:variable"/>
- </variableList>
- </xsl:template>
-
- <xsl:template name="make-selector-name">
- <xsl:param name="parent-node-of-conditional-styles"/>
- <xsl:text>ConditionalStyleSelector</xsl:text>
-
- <xsl:text>_</xsl:text>
- <xsl:value-of select="generate-id( $parent-node-of-conditional-styles )"/>
- </xsl:template>
-
- <xsl:template match="x:conditionalStyle">
-
- </xsl:template>
-
- <xsl:template match="*[ x:conditionalStyle ]">
- <xsl:copy>
- <xsl:copy-of select="@*"/>
- <xsl:variable name="conditional-styles" select="x:conditionalStyle"/>
- <xsl:choose>
- <xsl:when test="count( $conditional-styles) > 1">
-
- <xsl:apply-templates/>
-
- <conditionalStyle>
- <xsl:attribute name="refVariable">
- <xsl:call-template name="make-selector-name">
- <xsl:with-param name="parent-node-of-conditional-styles" select="."/>
- </xsl:call-template>
- </xsl:attribute>
- <xsl:for-each select="$conditional-styles">
- <style>
- <xsl:attribute name="refVariableValue">
- <xsl:value-of select="position()"/>
- </xsl:attribute>
- <xsl:copy-of select=".//x:CSS"/>
- </style>
- </xsl:for-each>
- </conditionalStyle>
- </xsl:when>
- <xsl:otherwise>
-
- <xsl:apply-templates/>
-
- <xsl:copy-of select="$conditional-styles"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:copy>
- </xsl:template>
- </xsl:stylesheet>
|