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

XML
WML学习之七 CGI编程
WAP建站WML语言语法基础教程
WML语法大全与相关介绍
非常不错的WAP常见问题问答大全(二)
WML语言的基本情况
WML开发教程之 WAP网站服务器配置方法
WMLScript的语法基础
收集的WML Script标准函数库
WML教程之文本框控件Input
WMLScript脚本程序设计
WML的简单例子及编辑、测试方法
初试WAP之wml+ASP查询
无线标记语言(WML)基础之WMLScript 基础
xml文件的结构解读
关于XSL - XSL教程
选择模式 - XSL教程 - 2
XPath入门 - XSL教程 - 3
匹配模式 - XSL教程 - 4
测试模式 - XSL教程 - 5
三十分钟掌握STL-教程

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


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