当前位置: 首页 > 图文教程 > XML家族 > XML > 用XsltArgumentList实现xsl的参数调用

XML
采用XML数据来填充ASP表单
XML编程实例:用ASP+XML打造留言本
网页设计详细教程之XML简便省力技巧五则
动态产生XML文档的几种方式
WEB页面工具语言XML产生背景
XML教程 WEB页面工具语言XML的定义
WEB页面工具语言XML支持的工具之运用
WEB页面工具语言XML应用分类之运用
WEB页面工具语言XML带来的好处
XML 在使用中产生的二十个热点问题
Java操作XML编程实例解析
Thinking XML: 创建 XML 的好建议
WEB页面工具之语言XML的定义
使用XML技术上传文件的例子
使用xml http为网站增加域名查询功能
使用javascript+xml技术实现分页浏览
基于XML语言的来实现购物车的详细代码
XML to DDL的项目关键:与数据库同步
文档标准的真实谎言
利用xslt对xml进行缩进格式化处理

XML 中的 用XsltArgumentList实现xsl的参数调用


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-17   浏览: 39 ::
收藏到网摘: n/a


    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.ruanchen.com/"BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">

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