用XsltArgumentList实现xsl的参数调用

来源:互联网 时间:2008-09-04 11:24:00 


           

    XmlDocument XmlDoc=new XmlDocument();
    XmlDoc.Load(strFilePath);

    XslTransform xslt = new XslTransform();
    xslt.Load(strXslPath);

    XsltArgumentList xslArg = new XsltArgumentList();
    xslArg.AddParam("Key1", "",IXPath);
    xslArg.AddParam("Path", "",strPath);

    StringBuilder sb = new StringBuilder("");
    StringWriter sw = new StringWriter(sb);
    XmlTextWriter writer = new XmlTextWriter(sw);
    xslt.Transform(XmlDoc,xslArg,writer,null);
    writer.Close();
    HXML.InnerHtml=sb.ToString();


这是xsl文件


<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 <xsl:param name="Key1"/>
 <xsl:param name="Path"/>
 <xsl:template match="/">
  <xsl:apply-templates select="/DB/L[@Key=$Key1]" />
 </xsl:template>
 
 <xsl:template  match="L[@Type='1']">
  <a target="_blank">
   <xsl:attribute name="href"><xsl:value-of select="@Link" /></xsl:attribute>
   <img border="0">
    <xsl:attribute name="width"><xsl:value-of select="@width" /></xsl:attribute>
    <xsl:attribute name="height"><xsl:value-of select="@height" /></xsl:attribute>   
    <xsl:attribute name="src"><xsl:value-of select="$Path" />Res/AD/<xsl:value-of select="@File" /></xsl:attribute>
   </img>  
  </a>
 </xsl:template>

<xsl:template  match="L[@Type='2']">
   <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" >
    <xsl:attribute name="width"><xsl:value-of select="@width" /></xsl:attribute>
    <xsl:attribute name="height"><xsl:value-of select="@height" /></xsl:attribute>   
    <param name="movie"><xsl:attribute name="value"><xsl:value-of select="$Path" />Res/AD/<xsl:value-of select="@File" /></xsl:attribute></param>
    <param name="quality" value="http://www.chinaz.com/high"/>
    <embed quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">
     <xsl:attribute name="width"><xsl:value-of select="@width" /></xsl:attribute>
     <xsl:attribute name="height"><xsl:value-of select="@height" /></xsl:attribute>   
     <xsl:attribute name="src"><xsl:value-of select="$Path" />Res/AD/<xsl:value-of select="@File" /></xsl:attribute>   
    </embed>
   </object>
 </xsl:template>
 
</xsl:stylesheet>

xml文件


           

<?xml version="1.0" encoding="GB2312"?>
<DB>
  <L Name="测试1" height="100" width="100" Link="http://www.chinaz.com" File="20056171345164340.gif" Key="200561713451653143405" Type="1" />
</DB>


标签:
0
投稿

猜你喜欢

  • IE8"开发人员工具"使用详解

    2009-03-26 12:51:00
  • 如何在不同版本的SQL Server中存储数据

    2009-01-15 13:06:00
  • 精巧支付宝导航条制作教程

    2010-03-20 21:25:00
  • 最全的MYSQL备份方法

    2009-12-29 10:19:00
  • 当设计师遭遇HTML5

    2011-08-05 18:59:53
  • 八种获取当前日期的js代码

    2007-09-07 10:26:00
  • javascript权威指南,学习笔记,之运算符号

    2008-04-20 16:43:00
  • MySQL优化之数据类型的使用

    2009-03-16 17:12:00
  • DHTML中重要的属性方法

    2008-06-21 17:13:00
  • Asp生成RSS的类_给网站加上RSS

    2011-04-19 11:06:00
  • ASP实现上传图片自动压缩图片大小

    2010-01-25 12:47:00
  • 慎用 script 节点的 src 属性来传递参数

    2009-11-18 12:59:00
  • SQLServer 跨库查询实现方法

    2012-04-13 12:07:09
  • 文本框textarea限制输入文字个数的方法

    2008-01-28 13:02:00
  • 一个功能更强大的字符串格式化函数

    2008-04-30 17:44:00
  • css模拟title和alt的提示效果

    2007-11-08 13:03:00
  • CSS在Internet Explorer 6, 7 和8中的差别

    2009-10-26 18:14:00
  • IE6与IE7的unshift 方法

    2010-01-19 13:59:00
  • 利用MySQL加密函数保护Web网站敏感数据

    2008-12-17 16:11:00
  • asp分段插入数据库

    2010-07-02 13:13:00
  • asp之家 网络编程 m.aspxhome.com