XML之XSL

  XSL是指XML的表现形式,相当于html的css

 

<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet type="text/xsl" href="company_stylesheet_xsl.xsl"?>
<company>
	<companyname>公司名称</companyname>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	<deparment>
		<name>张三</name>
		<age>10</age>
		<rank>暂时</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">more</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>天天</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>一星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment><deparment>
		<name>张三</name>
		<age>10</age>
		<rank>二星</rank>
		<salary>10000</salary>
		<description href="http://www.gogole.com">知道更多...</description>
	</deparment>
	
</company>

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:template match="/">
        <html>
            <head> 
                <title>使用xsl对xml进行样式格式化</title>   
            </head>
            <body>
                <xsl:apply-templates select="company"/>     <!--从根目录标签-->
                </body>
        </html>
</xsl:template>

<xsl:template match="company">
        <table>
            <tr>
                <td>姓名</td>
                <td>年龄</td>
                <td>等级</td>
                <td>工资</td>
                <td>描述</td>
            </tr>   
            <xsl:for-each select="deparment">
            <tr>
                <td><xsl:value-of  select="name"/></td>
                <td><xsl:value-of  select="age"/></td>
                <td><xsl:value-of  select="rank"/></td>
                <td><xsl:value-of  select="salary"/></td>
                <td>
                    <a>
                        <xsl:attribute name="href">
                                <xsl:value-of select="description/@href"/>
                            </xsl:attribute>
                        <xsl:value-of  select="description"/>
                       
                    </a>
                </td>
            </tr>   
            </xsl:for-each>
        </table>
</xsl:template>
</xsl:stylesheet>
 

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
<xsl:template match="/">
		<html>
			<head>  
				<title>使用xsl对xml进行样式格式化</title>	
			</head>
			<body>
				<xsl:apply-templates select="company"/> 	<!--从根目录标签-->
				</body>
		</html>
</xsl:template>

<xsl:template match="company">
		<table>
			<tr>
				<td>姓名</td>
				<td>年龄</td>
				<td>等级</td>
				<td>工资</td> 
				<td>描述</td>
			</tr>	
			<xsl:for-each select="deparment">
			<tr>
				<td><xsl:value-of  select="name"/></td>
				<td><xsl:value-of  select="age"/></td>
				<td><xsl:value-of  select="rank"/></td>
				<td><xsl:value-of  select="salary"/></td> 
				<td>
					<a>
						<xsl:attribute name="href">
								<xsl:value-of select="description/@href"/>
							</xsl:attribute>
						<xsl:value-of  select="description"/>
						
					</a>
				</td>
			</tr>	
			</xsl:for-each>
		</table>
</xsl:template>
</xsl:stylesheet>
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值