0

我正在使用编辑 XSLT 模板,这些模板将用于在博彩办公室显示价格/赔率。XML 文件包含我需要在 html 中显示的日期。这完全按照 Internet Explorer 中的预期显示,但是当我在 Firefox 中打开 XML 文件时, 会显示文字实体引用而不是不间断空格。

火狐(上)/ IE(下)

<competition status="O" id="1" name="STEVENAGE v TORQUAY" shortname="STEVENAG-TORQUAY" description="STEVENAGE v TORQUAY" startdatetime="2011-05-25T00:00" enddatetime="2011-05-25T00:00" venue="" leaguename="" country="">

它在屏幕上显示 startdatetime 属性。有没有人遇到过这个问题/理解为什么它显示&nbsp;而不是空格?任何帮助将不胜感激。

这是包含时间 DIV 的代码 (XSLT)

<xsl:if test="$displayTimeTitle=1">
          <div class="TIME editable" id="timeHeader">
            <div class="TIMETEXT">
              <xsl:call-template name="wysiwyg:doAttributes">
                <xsl:with-param name="WYSIWYG" select="$WYSIWYG" />
                <xsl:with-param name="pItem" select="//competition[1]/@startdatetime" />
              </xsl:call-template>
              <xsl:choose>
                <xsl:when test="//competition[1]/edited[@name='startdatetime']">
                  <xsl:value-of select="//competition[1]/@startdatetime"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:if test="//competition[1]/@startdatetime !=''">
                    <xsl:call-template name="doMM_Date">
                      <xsl:with-param name="Date">
                        <xsl:call-template name="Time_Add">
                          <xsl:with-param name="Date" select="//competition[1]/@startdatetime"/>
                          <xsl:with-param name="AddMinutes" select="$timeadjustment"/>
                        </xsl:call-template>
                      </xsl:with-param>
                      <xsl:with-param name="languagecode" select="E"/>
                    </xsl:call-template>
                  </xsl:if>
                  <xsl:if test="$displayHeaderAMPM=1">
                    <nobr>
                      <xsl:value-of select="$headerAMPM"/>
                    </nobr>
                  </xsl:if>
                </xsl:otherwise>
              </xsl:choose>
            </div>
          </div>
        </xsl:if>

这是外部样式表 Date_Time_Templates.xsl ,其中包含像 doMM_Date 这样的模板,如上所示

<?xml version="1.0"?>
<!-- (C) Copyright 2DB Limited 2012. No part of this document can be reproduced without the express written permission of 2DB Limited. -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template name="Time_Add">
    <xsl:param name="Date"/>
    <xsl:param name="AddMinutes"/>

    <xsl:param name="year">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,1,4)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,7,4)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    <xsl:param name="month">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,6,2)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,4,2)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    <xsl:param name="day">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,9,2)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,1,2)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>

    <xsl:param name="hour" select="substring($Date,12,2)"/>
    <xsl:param name="minute" select="substring($Date,15,2)"/>
    <xsl:variable name="newhour">
        <xsl:choose>
            <xsl:when test="($hour + ($AddMinutes div 60)) &gt; 23">
                <xsl:value-of select="($hour + ($AddMinutes div 60)) - 24"/>
            </xsl:when>
            <xsl:when test="($hour + ($AddMinutes div 60)) &lt; 00">
                <xsl:value-of select="($hour + ($AddMinutes div 60)) + 24"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="($hour + ($AddMinutes div 60))"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

    <xsl:variable name="tempday">
        <xsl:choose>
            <xsl:when test="($hour + ($AddMinutes div 60)) &gt; 23">
                <xsl:value-of select="$day + 1"/>
            </xsl:when>
            <xsl:when test="($hour + ($AddMinutes div 60)) &lt; 00">
                <xsl:value-of select="$day - 1"/>

            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$day"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

    <xsl:variable name="newday">
        <xsl:choose>
            <xsl:when test="($month='01' or $month='03' or $month='05' or $month='08' or $month='10' or $month='12') and  $tempday &gt; 31">
                <xsl:value-of select="01"/>
            </xsl:when>
            <xsl:when test="($month='04' or $month='06' or $month='09' or $month='11') and  $tempday &gt; 30">
                <xsl:value-of select="01"/>
            </xsl:when>
            <xsl:when test="($month='02') and  $tempday &gt; 28">
                <xsl:value-of select="01"/>
            </xsl:when>
            <xsl:when test="($month='02' or $month='04' or $month='06' or $month='09' or $month='11' or $month='01') and $tempday = 00">
                <xsl:value-of select="31"/>
            </xsl:when>
            <xsl:when test="($month='05' or $month='07' or $month='10' or $month='12') and $tempday = 00">
                <xsl:value-of select="30"/>
            </xsl:when>
            <xsl:when test="($month='03') and $tempday = 00">
                <xsl:value-of select="28"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$tempday"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

    <xsl:variable name="tempmonth">
        <xsl:choose>
            <xsl:when test="($newday = 01 or $newday = 1) and $newday != $day and $day != 02">
                <xsl:value-of select="$month + 1"/>
            </xsl:when>
            <xsl:when test="($newday = 31 or $newday = 28 or $newday = 30) and $newday != $day and $day != 02">
                <xsl:value-of select="$month - 1"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$month"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

    <xsl:variable name="newmonth">
        <xsl:choose>
            <xsl:when test="$tempmonth &gt; 12">
                <xsl:value-of select="01"/>
            </xsl:when>
            <xsl:when test="$tempmonth = 00">
                <xsl:value-of select="12"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$tempmonth"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

    <xsl:variable name="newyear">
        <xsl:choose>
            <xsl:when test="($newmonth = 01 or newmonth = 1) and $newmonth != $month">
                <xsl:value-of select="$year + 1"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$year"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

    <xsl:variable name="finalday">
        <xsl:choose>
            <xsl:when test="string-length($newday) = 1">0<xsl:value-of select="$newday"></xsl:value-of></xsl:when>
            <xsl:otherwise><xsl:value-of select="$newday"></xsl:value-of></xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="finalmonth">
        <xsl:choose>
            <xsl:when test="string-length($newmonth) = 1">0<xsl:value-of select="$newmonth"></xsl:value-of></xsl:when>
            <xsl:otherwise><xsl:value-of select="$newmonth"></xsl:value-of></xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="finalhour">
        <xsl:choose>
            <xsl:when test="string-length($newhour) = 1">0<xsl:value-of select="$newhour"></xsl:value-of></xsl:when>
            <xsl:otherwise><xsl:value-of select="$newhour"></xsl:value-of></xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:value-of select="$finalday"/>/<xsl:value-of select="$finalmonth"/>/<xsl:value-of select="$newyear"/>/<xsl:value-of select="$finalhour"/>:<xsl:value-of select="$minute"/>

</xsl:template>

<xsl:template name="Time_Add_NoDate">
    <xsl:param name="Date"/>
    <xsl:param name="AddMinutes"/>


    <xsl:param name="hour" select="substring($Date,1,2)"/>
    <xsl:param name="minute" select="substring($Date,4,2)"/>
    <xsl:variable name="newhour">
        <xsl:choose>
            <xsl:when test="($hour + ($AddMinutes div 60)) &gt; 23">
                <xsl:value-of select="($hour + ($AddMinutes div 60)) - 24"/>
            </xsl:when>
            <xsl:when test="($hour + ($AddMinutes div 60)) &lt; 00">
                <xsl:value-of select="($hour + ($AddMinutes div 60)) + 24"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="($hour + ($AddMinutes div 60))"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>


    <xsl:variable name="finalhour">
        <xsl:choose>
            <xsl:when test="string-length($newhour) = 1">0<xsl:value-of select="$newhour"></xsl:value-of></xsl:when>
            <xsl:otherwise><xsl:value-of select="$newhour"></xsl:value-of></xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:call-template name="TwentyFourToTwelveHrClock">
        <xsl:with-param name="Time"><xsl:value-of select="$finalhour"/>:<xsl:value-of select="$minute"/></xsl:with-param>
    </xsl:call-template>




</xsl:template>


<xsl:template name="Date_Day">

    <xsl:param name="Date"/>
    <xsl:param name="year">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,1,4)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,7,4)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    <xsl:param name="month">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,6,2)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,4,2)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    <xsl:param name="day">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,9,2)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,1,2)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>

    <!--<xsl:value-of select="$year"/>-->
    <xsl:variable name="a" select="floor((14 - $month) div 12)"/>
        <xsl:variable name="y" select="$year - $a"/>
        <xsl:variable name="m" select="$month + 12 * $a - 2"/>
    <xsl:variable name="WkDay" select="($day + $y + floor($y div 4) - floor($y div 100) + floor($y div 400) + floor((31 * $m) div 12)) mod 7"/>

     <xsl:choose>
        <xsl:when test="$WkDay = 0">Sunday</xsl:when>
        <xsl:when test="$WkDay = 1">Monday</xsl:when>
        <xsl:when test="$WkDay = 2">Tuesday</xsl:when>
          <xsl:when test="$WkDay = 3">Wednesday</xsl:when>
          <xsl:when test="$WkDay = 4">Thursday</xsl:when>
          <xsl:when test="$WkDay = 5">Friday</xsl:when>
          <xsl:when test="$WkDay = 6">Saturday</xsl:when>
          <xsl:otherwise>error: <xsl:value-of select="$WkDay"/></xsl:otherwise>
    </xsl:choose>

</xsl:template>

  <xsl:template name="Date_Day2">

    <xsl:param name="Date"/>
    <xsl:param name="year">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,1,4)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,7,4)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    <xsl:param name="month">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,6,2)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,4,2)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    <xsl:param name="day">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,9,2)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,1,2)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>

    <xsl:variable name="a" select="floor((14 - $month) div 12)"/>
    <xsl:variable name="y" select="$year - $a"/>
    <xsl:variable name="m" select="$month + 12 * $a - 2"/>
    <xsl:variable name="WkDay" select="($day + $y + floor($y div 4) - floor($y div 100) + floor($y div 400) + floor((31 * $m) div 12)) mod 7"/>

    <xsl:choose>
      <xsl:when test="$WkDay = 0">Sun </xsl:when>
      <xsl:when test="$WkDay = 1">Mon </xsl:when>
      <xsl:when test="$WkDay = 2">Tue </xsl:when>
      <xsl:when test="$WkDay = 3">Wed </xsl:when>
      <xsl:when test="$WkDay = 4">Thu </xsl:when>
      <xsl:when test="$WkDay = 5">Fri </xsl:when>
      <xsl:when test="$WkDay = 6">Sat </xsl:when>
      <xsl:otherwise>
        error: <xsl:value-of select="$WkDay"/>
      </xsl:otherwise>
    </xsl:choose>

  </xsl:template>


<xsl:template name="doMM_Date">
<xsl:param name="Date"/>

            <xsl:call-template name="Date_Day_MM"><xsl:with-param name="Date" select="$Date"/></xsl:call-template>
            <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>

            <xsl:value-of select="substring($Date, 1, 2)"/>
            <xsl:call-template name="StNd"><xsl:with-param name="Day" select="substring($Date, 1, 2)"/></xsl:call-template>

            <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
            <xsl:call-template name="Date_Month_MM"><xsl:with-param name="Date" select="$Date"/></xsl:call-template> 

            <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
            <xsl:call-template name="TwentyFourToTwelveHrClock">
                <xsl:with-param name="Time"><xsl:value-of select="substring($Date, 12, 5)"/></xsl:with-param>
            </xsl:call-template>


</xsl:template>         


<xsl:template name="Date_Day_MM">
    <xsl:param name="Date"/>

    <xsl:param name="year">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,1,4)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,7,4)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    <xsl:param name="month">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,6,2)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,4,2)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>
    <xsl:param name="day">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,9,2)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,1,2)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>

    <xsl:variable name="a" select="floor((14 - $month) div 12)"/>
        <xsl:variable name="y" select="$year - $a"/>
        <xsl:variable name="m" select="$month + 12 * $a - 2"/>
    <xsl:variable name="WkDay" select="($day + $y + floor($y div 4) - floor($y div 100) + floor($y div 400) + floor((31 * $m) div 12)) mod 7"/>

     <xsl:choose>
        <xsl:when test="$WkDay = 0">Sunday</xsl:when>
        <xsl:when test="$WkDay = 1">Monday</xsl:when>
        <xsl:when test="$WkDay = 2">Tuesday</xsl:when>
          <xsl:when test="$WkDay = 3">Wednesday</xsl:when>
          <xsl:when test="$WkDay = 4">Thursday</xsl:when>
          <xsl:when test="$WkDay = 5">Friday</xsl:when>
          <xsl:when test="$WkDay = 6">Saturday</xsl:when>
          <xsl:otherwise></xsl:otherwise>
    </xsl:choose>



</xsl:template>

<xsl:template name="Date_Month_MM">

    <xsl:param name="Date"/>
    <xsl:param name="month">
        <xsl:choose>
            <xsl:when test="contains($Date,'-')">
                <xsl:value-of select="substring($Date,6,2)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="substring($Date,4,2)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:param>



     <xsl:choose>
        <xsl:when test="$month = 1 or $month = 01">January</xsl:when>
        <xsl:when test="$month = 2 or $month = 02">February</xsl:when>
        <xsl:when test="$month = 3 or $month = 03">March</xsl:when>
        <xsl:when test="$month = 4 or $month = 04">April</xsl:when>
        <xsl:when test="$month = 5 or $month = 05">May</xsl:when>
        <xsl:when test="$month = 6 or $month = 06">June</xsl:when>
        <xsl:when test="$month = 7 or $month = 07">July</xsl:when>
        <xsl:when test="$month = 8 or $month = 08">August</xsl:when>
        <xsl:when test="$month = 9 or $month = 09">September</xsl:when>
        <xsl:when test="$month = 10">October</xsl:when>
        <xsl:when test="$month = 11">November</xsl:when>
        <xsl:when test="$month = 12">December</xsl:when>
        <xsl:otherwise></xsl:otherwise>
    </xsl:choose>

</xsl:template>


<xsl:template name="Sh_Month">

    <xsl:param name="Month"/>
    <xsl:choose>
        <xsl:when test="$Month = 01">January</xsl:when>
        <xsl:when test="$Month = 02">February</xsl:when>
        <xsl:when test="$Month = 03">March</xsl:when>
        <xsl:when test="$Month = 04">April</xsl:when>
        <xsl:when test="$Month = 05">May</xsl:when>
        <xsl:when test="$Month = 06">June</xsl:when>
        <xsl:when test="$Month = 07">July</xsl:when>
        <xsl:when test="$Month = 08">August</xsl:when>
        <xsl:when test="$Month = 09">September</xsl:when>
        <xsl:when test="$Month = 10">October</xsl:when>
        <xsl:when test="$Month = 11">November</xsl:when>
        <xsl:when test="$Month = 12">December</xsl:when>
        <xsl:otherwise>error: <xsl:value-of select="$Month"/></xsl:otherwise>

    </xsl:choose>

</xsl:template>

<xsl:template name="StNd">
    <xsl:param name="Day"/>
        <xsl:if test="$Day != ''">
        <xsl:choose>
            <xsl:when test="$Day = 01">st</xsl:when>
            <xsl:when test="$Day = 02">nd</xsl:when>
            <xsl:when test="$Day = 03">rd</xsl:when>
            <xsl:when test="$Day = 21">st</xsl:when>
            <xsl:when test="$Day = 22">nd</xsl:when>
            <xsl:when test="$Day = 23">rd</xsl:when>
            <xsl:when test="$Day = 31">st</xsl:when>
            <xsl:otherwise>th</xsl:otherwise>
        </xsl:choose>
        </xsl:if>
</xsl:template>


<!--
    This Template Converts a time to 12 hour clock from 24 in the format HH:MM.
    Use the xsl:call-template name="TwentyFourToTwelveHrClock"><xsl:with-param name="Time" select="HH:MM"/>" 
 -->

<xsl:template name="TwentyFourToTwelveHrClock">
    <xsl:param name="Time"/>
    <xsl:choose>
        <xsl:when test="substring($Time,1,2) &gt; 12">
            <xsl:value-of select="substring($Time,1,2) - 12" />
            <xsl:value-of select="substring($Time,3,3)" />
        </xsl:when>
        <xsl:otherwise> <!-- nothing to do as am, output as normal -->
            <xsl:value-of select="substring($Time,1,5)"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>


</xsl:stylesheet>
4

1 回答 1

2

至少在某些版本的 FF 中,带有 DOE 的 xsl:text 不起作用。这是FF 中的错误。您的样式表正在广泛使用 xsl:text+DOE 。我建议重新设计样式表,使其不使用任何 DOE。这应该是一个微不足道的练习。

边注

在所有浏览器中,FF 对 XSLT 的支持最差。考虑到 FF 多年来在推动浏览器边界方面发挥的主导作用,这真是一场悲剧。即使是垃圾恶意软件 MS Internet Exploder,也比 FF 具有更好的 XSLT 支持。哦——耻辱!

于 2012-08-29T14:14:23.097 回答