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

XML
XML(一)
一日精通Ajax技术
使用XML文件记录操作日志
XMLHTTP对象封装技术
轻松使用DOM 的技巧和诀窍
如何生成XML数据
使用xml作为数据源,让asp:Menu类自由扩展菜单项
使用PHP和AJAX的XML编程(4)
使用PHP和AJAX的XML编程(3)
使用PHP和AJAX的XML编程(2)
使用PHP和AJAX的XML编程(1)
Web 2.0 编程思想:16条法则
如何用ASP生成XML数据文档
在SQLServer中用XQuery分解XML数据
巧用XML做多语言界面的FLASH
XML文档搜索使用小结
XML入门指南(1)XML简介
xml中的空格之完全解说
为何XML对Web服务很重要
XML数据库中几个容易混淆的概念

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-17   浏览: 50 ::
收藏到网摘: 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>