zoukankan      html  css  js  c++  java
  • XML 基础

    使用 XSLT 将 XML 文档转换为其他文档

    定义一个CD的html模板,命名为 cd.xsl

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
      <html>
      <body>
        <h2>My CD Collection</h2>
        <table border="1">
        <tr bgcolor="#9acd32">
          <th align="left">Title</th>
          <th align="left">Artist</th>
        </tr>
        <xsl:for-each select="catalog/cd">
        <tr>
          <td><xsl:value-of select="title"/></td>
          <td><xsl:value-of select="artist"/></td>
        </tr>
        </xsl:for-each>
        </table>
      </body>
      </html>
    </xsl:template>
    </xsl:stylesheet>

    使用 cd.xsl 显示 XML

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="cd.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>
    </catalog>

    将此XML拖入浏览器,将会根据cd.xsl来如下显示:

  • 相关阅读:
    java抽象类和接口
    java的三大特征:封装,继承和多态
    java的数组
    django 4.get接口开发
    django 3.post接口开发
    C# 程序启动最小化至任务栏及闪烁
    续Html5
    使用intellij idea搭建MAVEN+SSM(Spring+SpringMVC+MyBatis)框架
    Spring MVC拦截器
    Html5高级
  • 原文地址:https://www.cnblogs.com/yipeng-yu/p/3514773.html
Copyright © 2011-2022 走看看