XSLT转换中的问题请教

 1<root>
 2<node>
 3<id>1</id>
 4<name>yu</name>
 5</node>
 6<root>   
 7需要转成   
 8<root>
 9<node id="1">
10<name>yu</name>
11</node>
12</root>   
13也就是把一个元素变成一个属性,怎么写呀   
14非常感谢   
15  
16\---------------------------------------------------------------   
17  
18try   
19  
20<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
21<xsl:output indent="yes" method="xml"></xsl:output>
22<xsl:template match="node()">
23<xsl:copy>
24<xsl:copy-of select="@*"></xsl:copy-of>
25<xsl:apply-templates></xsl:apply-templates>
26</xsl:copy>
27</xsl:template>
28<xsl:template match="id">
29<xsl:attribute name="id"><xsl:value-of select="."></xsl:value-of></xsl:attribute>
30</xsl:template>
31</xsl:stylesheet></root></root>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus