欢迎光临
我们一直在努力

用XsltArgumentList实现xsl的参数调用-ASP教程,ASP应用

建站超值云服务器,限时71元/月

 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>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用XsltArgumentList实现xsl的参数调用-ASP教程,ASP应用
分享到: 更多 (0)