正 文

针对不可访问 Web 页的文本选择


www.7dspace.com  更新日期:2005-10-4 12:28:45  七度空间


另一方面,如果用户已经选择了页面的纯文本视图,就会应用该 XSLT 代码,如示例 7 中所示。

代码示例 7. XSLT 纯文本代码

<xsl:template match="table | TABLE | Table">
   <div>
      <xsl:apply-templates />
   </div>
</xsl:template>
<xsl:template match="tr | TR">
   <div>
      <xsl:apply-templates />
   </div>
</xsl:template>
<xsl:template match="th | TH">
   <div>
      <xsl:apply-templates />
   </div>
</xsl:template>
<xsl:template match="td | TD">
   <div>
      <xsl:apply-templates />
   </div>
</xsl:template>
<xsl:template match="img | IMG | Img">
   <xsl:if test="not(ancestor::banner) and not(ancestor::BANNER) and
not(ancestor::Banner)">
      <xsl:for-each select="@*">
         <xsl:if test="((name()='alt') or (name()='ALT') or
(name()='Alt')) and (normalize-space(.)!='')">
            [image: <xsl:value-of select="." />]
         </xsl:if>
      </xsl:for-each>           
      <xsl:apply-templates />
   </xsl:if>
</xsl:template>

示例 8 产生一个简单得多的数据视图。

代码示例 8. 得到的纯文本显示

<div>
   <div>
      <div>
         [image: Man with laptop]
      </div>
   </div>
   <div>
      <div>
         [image: Hand on keyboard]
      </div>
   </div>
   <div>
      <div>
         [image: Fingers feeling Braille text]
      </div>
   </div>

正如您能看到的,表已由 DIV 替换,图像和格式设置已移除,而且每个图像的 ALT 属性替换了该图像。

上面所描述的技术提供了一组既带有丰富视图又带有纯文本视图的数据。由于数据不是重复的,因此更新站点只需更新一组数据页面。

5页,页码:[1] [2] [3] [4] [5] 

上一篇:SQL Server 本机 Web 服务的使用方案
下一篇:ASP.NET Starter Kit 入门指南
作者:  来源:MSDN ( 责任编辑:7dspace )
收藏此页】【打印】【关闭
站 内 搜 索
 

热 点 导 读
特 别 推 荐