I\'m new to xslt and trying to process below XML using XSLT :
F<
Since XSLT variables are immutable, I'm unable perform below operation.
I don't see what variables, immutable or not, have to do with it. This is just straightforward XSLT:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:template match="/xml">
<xsl:for-each select="characters">
<word>
<value>
<xsl:for-each select="char">
<xsl:value-of select="."/>
</xsl:for-each>
</value>
<coordinates>
<xsl:value-of select="char[1]/@a"/>
<xsl:text> </xsl:text>
<xsl:value-of select="char[1]/@b"/>
<xsl:text> </xsl:text>
<xsl:value-of select="char[last()]/@y"/>
<xsl:text> </xsl:text>
<xsl:value-of select="char[last()]/@z"/>
</coordinates>
<avgWeight>
<xsl:value-of select="sum(characters/char/@weight) div count(characters/char) "/>
</avgWeight>
</word>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>