XSL相关

时间:2023-03-09 07:23:33
XSL相关
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="C:\Users\Administrator\Desktop\emp1.xsl" ?>
<employees>
  <employee on="01">
    <name>Tom</name>
    <sex>男</sex>
    <birth>
      <year>1982</year>
      <month>5</month>
      <day>22</day>
    </birth>
    <sales>
      <year>2010</year>
      <month>1</month>
      <sale>320000</sale>
    </sales>
    <salary>8600</salary>
  </employee>
  <employee on="02">
    <name>Jack</name>
    <sex>男</sex>
    <birth>
      <year>1981</year>
      <month>7</month>
      <day>10</day>
    </birth>
    <sales>
      <year>2010</year>
      <month>1</month>
      <sale>300000</sale>
    </sales>
    <salary>6000</salary>
  </employee>
  <employee on="03">
    <name>Jennifer</name>
    <sex>女</sex>
    <birth>
      <year>1982</year>
      <month>6</month>
      <day>22</day>
    </birth>
    <sales>
      <year>2010</year>
      <month>1</month>
      <sale>500000</sale>
    </sales>
    <salary>7000</salary>
  </employee>
</employees>
=========================================================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:fo="http://www.w3.org/1999/XSL/Format" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:fn="http://www.w3.org/2005/xpath-functions" 
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes">
<!-- 模板 -->
  <xsl:template match="/employees/employee">
     <html>
<head><title></title></head>
<body>
   <div>
                    <u>
       <h2>编号:<xsl:value-of select="@no"/>  </h2>
           </u>    
   </div>
   <div>
       姓名:<xsl:value-of select="name"/>
   </div>
   <div>
        <i> 
          生日:
          <xsl:value-of select="birth/year"/>年
          <xsl:value-of select="birth/month"/>月
          <xsl:value-of select="birth/day"/>日
        </i>
   </div>
</body>
     </html>
  </xsl:template>
</xsl:stylesheet>