温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

用XsltArgumentList怎么实现xsl的参数调用

发布时间:2020-10-19 15:24:36 来源:亿速云 阅读:138 作者:小新 栏目:编程语言

小编给大家分享一下用XsltArgumentList怎么实现xsl的参数调用,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

选择自 hstod 的 Blog

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="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.123.com" File="20056171345164340.gif" Key="200561713451653143405" Type="1" />
</DB>

看完了这篇文章,相信你对用XsltArgumentList怎么实现xsl的参数调用有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI