2017-02-16 63 views
0

我想將xml屬性的input xml轉換爲output xml的元素。 例XSL轉換屬性要素

<Price price1="2" price2="3" total="5" other="x" tax="2"/> to 

<Price> 
    <price1>2</price1> 
    <price2>3</price2> 
    <total>5</total> 
    <other>x</other> 
    <tax>2</tax> 
</Price> 

我試着像

<xsl:element name="Price"> 
    <xsl:for-each select="*:Price/@*"> 
    <xsl:element name="*> 
    <xsl:value-of select="@*"/> 
    </xsl:for-each> 
    </xsl:element></xsl:element> 

無法獲得所需要的output.Please建議。

回答

0

試試這樣說:

<xsl:template match="Price"> 
    <xsl:copy> 
     <xsl:for-each select="@*"> 
      <xsl:element name="{name()}"> 
       <xsl:value-of select="."/> 
      </xsl:element> 
     </xsl:for-each> 
    </xsl:copy> 
</xsl:template>