溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

用XsltArgumentList怎么實現(xiàn)xsl的參數(shù)調(diào)用

發(fā)布時間:2020-10-19 15:24:36 來源:億速云 閱讀:147 作者:小新 欄目:編程語言

小編給大家分享一下用XsltArgumentList怎么實現(xiàn)xsl的參數(shù)調(diào)用,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!

選擇自 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怎么實現(xiàn)xsl的參數(shù)調(diào)用有了一定的了解,想了解更多相關知識,歡迎關注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI