设为首页】 【加入收藏】 【网站地图】 【商品折扣
娱乐一生 娱乐明星
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
首页  |  java  |  .NET  |  C/C++  |  网页技术  |  php  |  asp  |  delphi  |  VC  |  VB开发  |  游戏开发  |  软件工程  |  Power Builder  |  Linux开发  |  Windows开发技巧
当前位置:首页 >> 开发实例 >> A .NET XML/XSL Tra forms(转载www.a alliance.com)

A .NET XML/XSL Tra forms(转载www.a alliance.com) -

Tra forming an XML document using XSL/T and outputting the results to the browser is a fairly simple task in A .NET. The following user control demo trates the ease with which this can be accomplished. This user control has a parameter for the XML source(xmlSource), and a parameter for the XSL source(xslSource). When placing this user control on a page, simply  ecify both values (using relative paths, since they are Server.Ma ath'ed within the user control) and you're done! The tra formed result will be output to Re o e.Output and sent to the user's browser. You can use this to create a two line A X file that simply uses this user control to render its output. By using Output and/or Fragment caching, you can e ure that the CPU load required to tra form the XML is minimized.

<%@ Control Language="c#" %>
<%@ Import Name ace=" ystem.Xml" %>
<%@ Import Name ace=" ystem.Xml.Xsl" %>
<%@ Import Name ace=" ystem.Xml.XPath" %>
< cript runat=" erver" language="c#" gt;
public string xmlSource, xslSource;
void Page_Load(){
 XmlDocument docXml = new XmlDocument();
 docXml.Load(Server.Ma ath(xmlSource));
 XslTra form docXsl = new XslTra form();
 docXsl.Load(Server.Ma ath(xslSource));
 docXsl.Tra form(docXml,null,Re o e.Output);
// chapter.Text = docXml.Tra formNode(docXsl);
}
</script>

An example of a page using this user control, Output Caching for 1 minute:

<%@Page%>
<%@ Register TagPrefix="author quot; tagname="chapter quot; src=http://www.cndownz.com/article/5/368/389/2006/"/controls/chapters.ascx"%>
<%@ OutputCache Duration="60" VaryByParam=" one" %>
<authors:chapters id="chapter quot; runat=" erver"
 xmlSource="chapter.xml" xslSource="chapter.xsl" />

To test this out, you can use the following two files:

chapter.xml
<chapter>
 lt;!-- Chapter Name -->
 lt ame>Chapter Name</name>
 
 lt;!-- Author -->
 lt;author>
 lt ame> teven Smith</name>
 lt;email> mith@a alliance.com</email>
 lt;we ite>http://a alliance.com/stevesmith/</we ite>
 lt;/author>
 
 lt;!-- Examples from Chapter -->
 lt;example gt;
 
 lt;example>
 lt;!-- The number from the book, e.g. 2.3 -->
 lt;reference>2.1</reference>
 
 lt;!-- Link to working example -->
 lt;demo>
 lt;url>hellovb.a lt;/url>
 lt;link_text>HelloVB.a lt;/link_text>
 lt;/demo>
 
 lt;!-- Link to source code -->
 lt ource>
 lt;url>hellovb.txt</url>
 lt;link_text>HelloVB.a  source</link_text>
 lt;/source>
 
 lt;!-- Description of the example -->
 lt;descriptio gt;Hello World using Cla ic A .</descriptio gt;
 lt;/example>
 
 lt;/example gt;

</chapter>


chapter.xsl
<?xml version="1.0" ?>
<xsl:tra form xml :xsl="http://www.w3.org/1999/XSL/Tra form" version="1.0" gt;

<xsl:output method="xml" />

<xsl:template match="/" gt;
 lt gt;
 lt;xsl:a ly-templates select="chapter" />
 lt;/ gt;
</xsl:template>

<xsl:template match="/chapter" >
 lt gt lt;xsl:value-of select=" ame"/> lt;/ gt;
 lt r/>
 y <xsl:a ly-templates select="author" />
 lt r/> lt r/>
 lt;xsl:a ly-templates select="example quot; />
</xsl:template>

<xsl:template match="author" >
 lt;i> lt;xsl:value-of select=" ame"/> lt;/i>
</xsl:template>

<xsl:template match="example quot; >
 lt;table bgcolor="#000033" gt;
 lt;tr bgcolor="#CCCCFF" gt;
 lt;th>Reference</th>
 lt;th>Demo</th>
 lt;th> ource</th>
 lt;th>Descriptio lt;/th>
 lt;/tr>
 lt;xsl:a ly-templates select="example" />
 lt;/table>
</xsl:template>

<xsl:template match="example" >
 lt;tr bgcolor="#DDDDDD" gt;
 lt;td> lt;xsl:value-of select="reference"/> lt;/td>
 lt;td>
 lt;a>
 lt;xsl:attribute name="href" gt;
 lt;xsl:value-of select="demo/url"/>
 lt;/xsl:attribute>
 



 

娱乐图摘

更多 >>

靓丽清纯美女meimei

美女私房全裸照
导演劝女演员脱衣服(视频)

大胆火辣人体艺术写真(图)

黑丝妹妹热辣诱惑-丝袜美女妹妹

PLMM 漂亮妹妹图集-妹妹图库

全球美女图库-美女集中营

52MM 我爱漂亮妹妹-制服妹妹诱惑

图王图库-世界美女明星图片资料库
美女写真集锦

激情两性-解密性生活
浴室MM湿身内衣诱惑
邻家小妹洗澡被偷拍(视频)

热点文章

更多

· A .NET验证控件祥解(转)
· A .net:Literal控件用法
· A .NET中文件上传下载方法集合
· A .NET中Cookie编程的基础知识(3)
· A .net 验证码(C#)
· 在A .Net中创建动态表格
· 设计A .NET新闻管理系统
· 将A .NET页面内的数据导出到Excel&nbs
· A .Net2.0 GridView&n
· 利用A .NET设计FTP文件上传

热点文章

更多