日期:2014-05-18 浏览次数:20537 次
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> function XmlTransactionXSL() { // alert("ZhangSan"); // Load XML var xml = new ActiveXObject("Microsoft.XMLDOM") // alert("ZhangSan1"); xml.async = false; xml.preserveWhiteSpace = true; xml.load("E:\testxsl.xml"); // alert("ZhangSan2"); // Load XSL var xsl = new ActiveXObject("Microsoft.XMLDOM") xsl.async = false xml.preserveWhiteSpace = true; // alert("ZhangSan3"); xsl.load("E:\testxsl.xsl") // alert("ZhangSan4"); // Transform document.write(xml.transformNode(xsl)) alert("ZhangSan5"); } </script> </head> <body onload="XmlTransactionXSL()"> <%-- <form id="form1" runat="server"> <div> TEST </div> </form>--%> </body> </html>
<?xml-stylesheet type= "text/xsl " href= "testxsl.xsl " ?> <document> <resume> <Name>网</Name> </resume> <resume> <Name>三</Name> </resume> <resume> <Name>七</Name> </resume> <resume> <Name>啊</Name> </resume> </document>
<xsl:stylesheet version= "1.0 " xmlns:xsl= "http://www.w3.org/1999/XSL/Transform "> <xsl:output method= "html " indent= "yes " /> <xsl:template match= "/ "> <html> <body> <xsl:apply-templates /> </body> </html> </xsl:template> <xsl:template match= "document "> <xsl:variable name= "cols " select= "3 " /> <table border= "1 "> <xsl:for-each select= "resume[(position() - 1) mod $cols = 0] "> <tr> <td> <xsl:value-of select= "Name " /> </td> <xsl:for-each select= "following-sibling::resume[position() < $cols ] "> <td> <xsl:value-of select= "Name " /> </td> </xsl:for-each> <!--ignore the following if you don 't understand it begin --> <xsl:variable name= "sibcount " select= "count(following-sibling::resume) " /> <xsl:if test= "$sibcount < $cols - 1 "> <xsl:for-each select= "(document( ' ')//namespace::*)[position() &am