xslt - Get value of an attribute, where you don't know the name -


say if have xml line such as:

<machine center="10" left="25" right="162" /> 

and, using xslt, want turn in like:

<measurement type="center">10</measurement> <measurement type="left">25</measurement> <measurement type="right">162</measurement> 

how do that? @ moment have following, missing 1 crucial part:

<measurement>   <xsl:for-each select="@">     <xsl:attribute name="type">       <xsl:value-of name="name()">     </xsl:attribute name="type">     <xsl:value-of name="[what_goes_here?]" />   </xsl:for-each> </measurement> 

try way;

<xsl:template match="machine">     <xsl:for-each select="@*">         <measurement type="{name()}">             <xsl:value-of select="." />         </measurement>     </xsl:for-each> </xsl:template> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -