xslt

test.xml

<?xml version="1.0" encoding="utf-8" ?> 
<?xml-stylesheet type='text/xsl' href='test.xslt'?>
<Users Title="测试">
  <User MemName="用户1">
    
  </User>
  <User MemName="用户2">
    
  </User>
</Users>

 

test.xslt

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
    <xsl:output method="html" indent="yes"/>

    <xsl:template match="/">
      <html>
        <head>
          <link type="text/css" rel="stylesheet" href="test.css"/>
          <title>
            <xsl:value-of select="Users/@Title"/>
          </title>
        </head>
        <body>
          <table>
            <tr>
              <th>名称</th>
            </tr>
            <xsl:for-each select="Users/User">
              <tr>
                <td>
                  <xsl:value-of select="@MemName"/>
                </td>
              </tr>
            </xsl:for-each>
          </table>
        </body>
      </html>
    </xsl:template>
</xsl:stylesheet>

 

 

test.css

body
{
    background:#F3F3F4;
    color:#1E1E1F;
}

table
{
    border-collapse:collapse;
    font-size:10pt;
}

table th
{
    background:#3399FF;
    text-align:center;
}
table td
{
     border:1px solid #3399FF;
}

 

你可能感兴趣的:(xslt)