用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
投稿

猜你喜欢

  • vue项目中常用解决跨域的方法总结(CORS和Proxy)

    2024-04-28 09:33:05
  • Jquery对数组的操作技巧整理

    2024-04-22 22:32:52
  • JavaScript对JSON数据进行排序和搜索

    2024-06-09 22:02:57
  • Java timezone设置和mybatis连接数据库时区设置方式

    2024-01-24 09:43:18
  • Js setInterval与setTimeout(定时执行与循环执行)的代码(可以传入参数)

    2024-04-16 09:23:29
  • 用PHP编写和读取XML的几种方式

    2023-11-18 22:30:27
  • Python读取环境变量的方法和自定义类分享

    2022-11-13 23:47:08
  • MySQL中主键为0与主键自排约束的关系详解(细节)

    2024-01-22 20:10:04
  • python基于openpyxl生成excel文件

    2022-08-03 03:10:47
  • Python中关于property使用的小技巧

    2021-01-25 04:35:44
  • asp使用模板生成静态页面方法详解

    2007-09-24 12:29:00
  • python+appium自动化测试之如何控制App的启动和退出

    2023-06-24 12:45:01
  • 详细介绍Python中的偏函数

    2022-12-28 08:40:53
  • Python pandas中read_csv参数示例详解

    2021-05-14 06:17:12
  • windows系统Tensorflow2.x简单安装记录(图文)

    2023-02-22 04:41:23
  • CODEPAGE=936是什么意思?

    2009-07-05 18:37:00
  • 浅谈Python之Django(三)

    2021-07-07 00:38:25
  • Django基于Token的验证使用的实现

    2023-06-14 18:43:54
  • 一文详解Golang 定时任务库 gron 设计和原理

    2023-08-06 21:34:38
  • 深入探讨:PHP使用数据库永久连接方式操作MySQL的是与非

    2023-11-20 22:41:16
  • asp之家 网络编程 m.aspxhome.com