Clasificación XSLT: cómo ordenar los childnodes xml dentro de un nodo principal con un atributo

Lo que comenzó como algo simple ha resultado bastante problemático para el noob XSLT.

Intento ordenar childnodes / descendente pero, después de agregar un atributo a su nodo principal, recibo un error al depurar en VS2010:

"Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node has already been added."

Supongamos que tengo este XML simple:

<posts>
    <year value="2013">
        <post postid="10030" postmonth="1">
            <othernode></othernode>
            <othernode2></othernode2>
        </post>
        <post postid="10040" postmonth="2">
            <othernode></othernode>
            <othernode2></othernode2>
        </post>
        <post postid="10050" postmonth="3">
             <othernode></othernode>
             <othernode2></othernode2>
        </post>
    </year>
    <year value="2012">
        <post postid="10010" postmonth="1">
            <othernode></othernode>
            <othernode2></othernode2>
        </post>
        <post postid="10015" postmonth="2">
            <othernode></othernode>
            <othernode2></othernode2>
        </post>
        <post postid="10020" postmonth="3">
             <othernode></othernode>
             <othernode2></othernode2>
        </post>
    </year>
</posts>

Paso un XPATH a un xmldatasource para recuperar el relevante<year> nodo, por ejemplo 2013. Entonces necesito ordenar a su hijo<post> nodos descendiendo usando postid, entonces para<year value=2013>, postid = 10050 aparecería primero cuando se procesa.

Entonces, para ser claros: sólo me interesa clasificar dentro de uno.<year> nodo.

Antes de dividir los nodos en nodos separados (es decir, xml was / posts / post), el siguiente XSLT funcionó:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
    <xsl:strip-space elements="*"/>
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()">
                <xsl:sort select="@postid" data-type="text" order="descending"/>
            </xsl:apply-templates>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

Ahora el xmldatasource está vacío cuando se ejecuta debido al error anterior. Si paso ascendiendo en el orden, obviamente se devuelve el mismo xml (sin transformación)

Pregunta: cómo actualizar el XSLT anterior (o nuevo) para acomodar el atributo del nodo principal (<year value="">)? A través de la investigación, una respuesta decía "Necesito agregar creación de atributos antes de la creación de elementos". Esto tiene sentido al ver al depurador, los nodos se forman en orden de desc, pero a la etiqueta de año le falta su atributo. Pero realmente no tengo ni idea de XSLT. No puedo ver que sea demasiado complicado, pero simplemente no sé el idioma.

Cualquier ayuda, muy apreciada. Gracias

Respuestas a la pregunta(2)

Su respuesta a la pregunta