xslt 的基本操作

1)xml、xslt被html调用

<html>
<head>
<title></title>
<script language="javascript" type="text/javascript">
    // Load XML 
    var xml = new ActiveXObject("Microsoft.XMLDOM")
    xml.async = false
    xml.load("cdcatalog.xml")
    // Load XSL
    var xsl = new ActiveXObject("Microsoft.XMLDOM")
    xsl.async = false
    xsl.load("cdcatalog.xsl")
    // Transform
    document.write(xml.transformNode(xsl))
</script>
</head>
<body>
</body>
</html>

2)xml、xslt被c#后台调用

1) 后台

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.Xsl;
using System.Text;
using System.IO;
namespace xslt
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            StringWriter output = new StringWriter();
            //load xsl
            XslCompiledTransform transform = new XslCompiledTransform();
            transform.Load(Server.MapPath("cdcatalog.xsl"));
            //transform the xml
            transform.Transform(Server.MapPath("cdcatalog.xml"), null, output);
            Response.Write(output.ToString());
        }
    }
}

3)cdcatalog.xsl

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
  <xsl:template match="/">
    <!--模板与 XML 源文档的根相联系-->
    <html>
      <body>
        <h2>zhcao's CD Collection</h2>
        <table border="0">
          <tr bgcolor="#9acd32">
            <th align="left">title</th>
            <th align="left">artist</th>
            <th align="left">country</th>
            <th align="left">company</th>
            <th align="left">price</th>
            <th align="left">year</th>
          </tr>
          <!--遍历XML源文档catalog节点下的cd节点-->
          <!--获取year>1990年的数据[=  (等于)、!= (不等于)、< (小于)、> (大于)]-->
          <xsl:for-each select="catalog/cd[year>'1990']">
            <!--根据year排序升序(ascending)倒序(descending)-->
            <xsl:sort select="year" order="descending"/>
            <!--根据price获取价格大于10的数据-->
            <xsl:if test="price>10">
              <!--多重选择-->
              <xsl:choose>
                <xsl:when test="price=10.80">
                  <tr bgcolor="#ff00ff">
                    <td>
                      <xsl:value-of select="title"/>
                    </td>
                    <td>
                      <xsl:value-of select="artist"/>
                    </td>
                    <td>
                      <xsl:value-of select="country"/>
                    </td>
                    <td>
                      <xsl:value-of select="company"/>
                    </td>
                    <td>
                      <xsl:value-of select="price"/>
                    </td>
                    <td>
                      <xsl:value-of select="year"/>
                    </td>
                  </tr>
                </xsl:when>
                <xsl:otherwise>
                  <tr>
                    <td>
                      <xsl:value-of select="title"/>
                    </td>
                    <td>
                      <xsl:value-of select="artist"/>
                    </td>
                    <td>
                      <xsl:value-of select="country"/>
                    </td>
                    <td>
                      <xsl:value-of select="company"/>
                    </td>
                    <td>
                      <xsl:value-of select="price"/>
                    </td>
                    <td>
                      <xsl:value-of select="year"/>
                    </td>
                  </tr>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:if>
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

4)cdcatalog.xml

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
<!--引用xsl文件-->
<catalog>
  <cd>
    <title>Empire Burlesque</title>
    <artist>Bob Dylan</artist>
    <country>USA</country>
    <company>Columbia</company>
    <price>10.90</price>
    <year>1985</year>
  </cd>
  <cd>
    <title>Hide your heart</title>
    <artist>Bonnie Tyler</artist>
    <country>UK</country>
    <company>CBS Records</company>
    <price>9.90</price>
    <year>1988</year>
  </cd>
  <cd>
    <title>Greatest Hits</title>
    <artist>Dolly Parton</artist>
    <country>USA</country>
    <company>RCA</company>
    <price>9.90</price>
    <year>1982</year>
  </cd>
  <cd>
    <title>Still got the blues</title>
    <artist>Gary Moore</artist>
    <country>UK</country>
    <company>Virgin records</company>
    <price>10.20</price>
    <year>1990</year>
  </cd>
  <cd>
    <title>Eros</title>
    <artist>Eros Ramazzotti</artist>
    <country>EU</country>
    <company>BMG</company>
    <price>9.90</price>
    <year>1997</year>
  </cd>
  <cd>
    <title>One night only</title>
    <artist>Bee Gees</artist>
    <country>UK</country>
    <company>Polydor</company>
    <price>10.90</price>
    <year>1998</year>
  </cd>
  <cd>
    <title>Sylvias Mother</title>
    <artist>Dr.Hook</artist>
    <country>UK</country>
    <company>CBS</company>
    <price>8.10</price>
    <year>1973</year>
  </cd>
  <cd>
    <title>Maggie May</title>
    <artist>Rod Stewart</artist>
    <country>UK</country>
    <company>Pickwick</company>
    <price>8.50</price>
    <year>1990</year>
  </cd>
  <cd>
    <title>Romanza</title>
    <artist>Andrea Bocelli</artist>
    <country>EU</country>
    <company>Polydor</company>
    <price>10.80</price>
    <year>1996</year>
  </cd>
  <cd>
    <title>When a man loves a woman</title>
    <artist>Percy Sledge</artist>
    <country>USA</country>
    <company>Atlantic</company>
    <price>8.70</price>
    <year>1987</year>
  </cd>
  <cd>
    <title>Black angel</title>
    <artist>Savage Rose</artist>
    <country>EU</country>
    <company>Mega</company>
    <price>10.90</price>
    <year>1995</year>
  </cd>
  <cd>
    <title>1999 Grammy Nominees</title>
    <artist>Many</artist>
    <country>USA</country>
    <company>Grammy</company>
    <price>10.20</price>
    <year>1999</year>
  </cd>
  <cd>
    <title>For the good times</title>
    <artist>Kenny Rogers</artist>
    <country>UK</country>
    <company>Mucik Master</company>
    <price>8.70</price>
    <year>1995</year>
  </cd>
  <cd>
    <title>Big Willie style</title>
    <artist>Will Smith</artist>
    <country>USA</country>
    <company>Columbia</company>
    <price>9.90</price>
    <year>1997</year>
  </cd>
  <cd>
    <title>Tupelo Honey</title>
    <artist>Van Morrison</artist>
    <country>UK</country>
    <company>Polydor</company>
    <price>8.20</price>
    <year>1971</year>
  </cd>
  <cd>
    <title>Soulsville</title>
    <artist>Jorn Hoel</artist>
    <country>Norway</country>
    <company>WEA</company>
    <price>7.90</price>
    <year>1996</year>
  </cd>
  <cd>
    <title>The very best of</title>
    <artist>Cat Stevens</artist>
    <country>UK</country>
    <company>Island</company>
    <price>8.90</price>
    <year>1990</year>
  </cd>
  <cd>
    <title>Stop</title>
    <artist>Sam Brown</artist>
    <country>UK</country>
    <company>A and M</company>
    <price>8.90</price>
    <year>1988</year>
  </cd>
  <cd>
    <title>Bridge of Spies</title>
    <artist>T`Pau</artist>
    <country>UK</country>
    <company>Siren</company>
    <price>7.90</price>
    <year>1987</year>
  </cd>
  <cd>
    <title>Private Dancer</title>
    <artist>Tina Turner</artist>
    <country>UK</country>
    <company>Capitol</company>
    <price>8.90</price>
    <year>1983</year>
  </cd>
  <cd>
    <title>Midt om natten</title>
    <artist>Kim Larsen</artist>
    <country>EU</country>
    <company>Medley</company>
    <price>7.80</price>
    <year>1983</year>
  </cd>
  <cd>
    <title>Pavarotti Gala Concert</title>
    <artist>Luciano Pavarotti</artist>
    <country>UK</country>
    <company>DECCA</company>
    <price>9.90</price>
    <year>1991</year>
  </cd>
  <cd>
    <title>The dock of the bay</title>
    <artist>Otis Redding</artist>
    <country>USA</country>
    <company>Atlantic</company>
    <price>7.90</price>
    <year>1987</year>
  </cd>
  <cd>
    <title>Picture book</title>
    <artist>Simply Red</artist>
    <country>EU</country>
    <company>Elektra</company>
    <price>7.20</price>
    <year>1985</year>
  </cd>
  <cd>
    <title>Red</title>
    <artist>The Communards</artist>
    <country>UK</country>
    <company>London</company>
    <price>7.80</price>
    <year>1987</year>
  </cd>
  <cd>
    <title>Unchain my heart</title>
    <artist>Joe Cocker</artist>
    <country>USA</country>
    <company>EMI</company>
    <price>8.20</price>
    <year>1987</year>
  </cd>
</catalog>


 5)实例下载

内容概要:本文介绍了多种开发者工具及其对开发效率的提升作用。首先,介绍了两款集成开发环境(IDE):IntelliJ IDEA 以其智能代码补全、强大的调试工具和项目管理功能适用于Java开发者;VS Code 则凭借轻量级和多种编程语言的插件支持成为前端开发者的常用工具。其次,提到了基于 GPT-4 的智能代码生成工具 Cursor,它通过对话式编程显著提高了开发效率。接着,阐述了版本控制系统 Git 的重要性,包括记录代码修改、分支管理和协作功能。然后,介绍了 Postman 作为 API 全生命周期管理工具,可创建、测试和文档化 API,缩短前后端联调时间。再者,提到 SonarQube 这款代码质量管理工具,能自动扫描代码并检测潜在的质量问题。还介绍了 Docker 容器化工具,通过定义应用的运行环境和依赖,确保环境一致性。最后,提及了线上诊断工具 Arthas 和性能调优工具 JProfiler,分别用于生产环境排障和性能优化。 适合人群:所有希望提高开发效率的程序员,尤其是有一定开发经验的软件工程师和技术团队。 使用场景及目标:①选择合适的 IDE 提升编码速度和代码质量;②利用 AI 编程助手加快开发进程;③通过 Git 实现高效的版本控制和团队协作;④使用 Postman 管理 API 的全生命周期;⑤借助 SonarQube 提高代码质量;⑥采用 Docker 实现环境一致性;⑦运用 Arthas 和 JProfiler 进行线上诊断和性能调优。 阅读建议:根据个人或团队的需求选择适合的工具,深入理解每种工具的功能特点,并在实际开发中不断实践和优化。
内容概要:本文围绕低轨(LEO)卫星通信系统的星间切换策略展开研究,针对现有研究忽略终端运动影响导致切换失败率高的问题,提出了两种改进策略。第一种是基于预测的多属性无偏好切换策略,通过预测终端位置建立切换有向图,并利用NPGA算法综合服务时长、通信仰角和空闲信道数优化切换路径。第二种是多业务切换策略,根据不同业务需求使用层次分析法设置属性权重,并采用遗传算法筛选切换路径,同时引入多业务切换管理方法保障实时业务。仿真结果显示,这两种策略能有效降低切换失败率和新呼叫阻塞率,均衡卫星负载。 适合人群:从事卫星通信系统研究的科研人员、通信工程领域的研究生及工程师。 使用场景及目标:①研究和优化低轨卫星通信系统中的星间切换策略;②提高卫星通信系统的可靠性和效率;③保障不同类型业务的服务质量(QoS),特别是实时业务的需求。 其他说明:文章不仅详细介绍了两种策略的具体实现方法,还提供了Python代码示例,包括终端位置预测、有向图构建、多目标优化算法以及业务感知的资源分配等关键环节。此外,还设计了完整的仿真测试框架,用于验证所提策略的有效性,并提供了自动化验证脚本和创新点技术验证方案。部署建议方面,推荐使用Docker容器化仿真环境、Redis缓存卫星位置数据、GPU加速遗传算法运算等措施,以提升系统的实时性和计算效率。
内容概要:该论文深入研究了光纤陀螺(FOG)的温度特性及其补偿方法。首先分析了光纤陀螺各主要光学和电子器件的温度特性,通过有限元方法模拟温度场对陀螺的影响,进行了稳态和瞬态热分析。接着提出了高阶多项式算法和RBF神经网络算法两种温度补偿方法,并建立了相应的数学模型。论文还设计了不同温度条件下的实验以验证补偿效果,研究表明结合这两种算法能有效补偿光纤陀螺的温度漂移误差。此外,论文提供了详细的Python代码实现,包括数据预处理、补偿算法实现、有限元热分析模拟以及补偿效果的可视化。 适合人群:具备一定编程基础和物理基础知识的研究人员或工程师,尤其是从事惯性导航系统、光纤传感技术领域工作的人员。 使用场景及目标:①研究光纤陀螺在不同温度条件下的性能变化;②开发和优化温度补偿算法以提高光纤陀螺的精度;③利用提供的代码框架进行实验设计和数据分析,探索更有效的补偿策略。 其他说明:论文不仅提供了理论分析,还有具体的代码实现,有助于读者更好地理解和应用。文中涉及的补偿算法和有限元分析方法可以为其他相关领域的研究提供参考。此外,论文还讨论了温度误差的多物理场耦合机理、静态与动态补偿的综合效果以及工程实现中的关键技术瓶颈和解决方案。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值