XML : How can I select individual attribute values in XSL?

I have some XML that looks like this:

  <interp type="flowers color">Here is something concerning flowers and color.</interp>    

And I'm trying to transform it into something like this:

  <td class="interp">      <span class="tag">flowers</span>      <span class="tab">color</span>      Here is something concerning flowers and color.   </td>    

So this is the XSL I've been trying:

  <xsl:template match="interp">      <td class="interp">          <xsl:apply-templates select="@type | node()"/>      </td>  </xsl:template>    <xsl:template match="@type">      <xsl:for-each select=".">      <span class="tag">          <xsl:value-of select="."/>      </span>      </xsl:for-each>  </xsl:template>     

But what I get is more like this:

  <span class="tag">flowers color</span>  Here is something concerning flowers and color.     

What am I doing wrong, and how can I get these attribute values to separate?

No comments:

Post a Comment