Some bug of Mark HTML >>
<< whizzer
Some utilities of XSLT

Author Zhou Renjian Create@ 2004-11-01 09:29
whizz Note icon
    <!--
        public String replace(String str, String regexp, String replacement);
    -- >
    <xsl:template name="replace">
        <xsl:param name="str"/>
        <xsl:param name="regexp"/>
        <xsl:param name="replacement"/>
        
        <xsl:choose>
            <xsl:when test="contains($str,$regexp)">
                <xsl:variable name="newstr">
                    <xsl:value-of select="substring-before($str, $regexp)"/>
                    <xsl:value-of select="$replacement"/>
                    <xsl:value-of select="substring-after($str, $regexp)"/>
                </xsl:variable>
                <xsl:call-template name="replace">
                    <xsl:with-param name="str" select="$newstr"/>
                    <xsl:with-param name="regexp" select="$regexp"/>
                    <xsl:with-param name="replacement" select="$replacement"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$str"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!--
        public String getReverseColor(String color);
    -- >
    <xsl:template name="getReverseColor">
        <xsl:param name="color"/><!--"#"######-->
        <xsl:choose>
            <xsl:when test="$color!=''">
                <xsl:value-of select="concat('#', substring($color, 6, 2), substring($color, 4, 2), substring($color, 2, 2))"/>
            </xsl:when>
        </xsl:choose>
    </xsl:template>

    <!--
        public String getStripText(String text);
    -->
    <xsl:template name="getStripText">
        <xsl:param name="text"/>
       
        <xsl:variable name="text1">
            <xsl:call-template name="replace">
                <xsl:with-param name="str" select="$text"/>
                <xsl:with-param name="regexp" select="'\r'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="replace">
            <xsl:with-param name="str">
                <xsl:call-template name="replace">
                    <xsl:with-param name="str">
                        <xsl:call-template name="replace">
                            <xsl:with-param name="str">
                                <xsl:call-template name="replace">
                                    <xsl:with-param name="str">
                                        <xsl:call-template name="replace">
                                            <xsl:with-param name="str">
                                                <xsl:call-template name="replace">
                                                    <xsl:with-param name="str">
                                                        <xsl:call-template name="replace">
                                                            <xsl:with-param name="str">
                                                        <xsl:call-template name="replace">
                                                            <xsl:with-param name="str">
                                                        <xsl:call-template name="replace">
                                                            <xsl:with-param name="str" select="$text1"/>
                                                            <xsl:with-param name="regexp" select="'\&amp;quot;'"/>
                                                            <xsl:with-param name="replacement" select="'&amp;quot;'"/> <!-- \":" -->
                                                        </xsl:call-template>
                                                            </xsl:with-param>
                                                            <xsl:with-param name="regexp" select="'\&amp;apos;'"/>
                                                            <xsl:with-param name="replacement" select="'&amp;apos;'"/> <!-- \':' -->
                                                        </xsl:call-template>
                                                            </xsl:with-param>
                                                            <xsl:with-param name="regexp" select="'\t'"/>
                                                            <xsl:with-param name="replacement" select="'&#9;'"/>
                                                        </xsl:call-template>
                                                    </xsl:with-param>
                                                    <xsl:with-param name="regexp" select="'\n'"/>
                                                    <xsl:with-param name="replacement" select="'&#10;'"/>
                                                </xsl:call-template>
                                            </xsl:with-param>
                                            <xsl:with-param name="regexp" select="'&amp;amp;'"/>
                                            <xsl:with-param name="replacement" select="'&amp;'"/>
                                        </xsl:call-template>
                                    </xsl:with-param>
                                    <xsl:with-param name="regexp" select="'&amp;quot;'"/>
                                    <xsl:with-param name="replacement" select="'&quot;'"/>
                                </xsl:call-template>
                            </xsl:with-param>
                            <xsl:with-param name="regexp" select="'&amp;apos;'"/>
                            <xsl:with-param name="replacement" select="&quot;&apos;&quot;"/>
                        </xsl:call-template>
                    </xsl:with-param>
                    <xsl:with-param name="regexp" select="'&amp;gt;'"/>
                    <xsl:with-param name="replacement" select="'&gt;'"/>
                </xsl:call-template>
            </xsl:with-param>
            <xsl:with-param name="regexp" select="'&amp;lt;'"/>
            <xsl:with-param name="replacement" select="'&lt;'"/>
        </xsl:call-template>
    </xsl:template>

本记录所在类别:
本记录相关记录: