<xsl:variable name="formattedinput"> <!-- $testxml is your input document -->
<xsl:for-each select="tokenize($testxml/name, '\s')"> <!-- \s means space -->
<name><xsl:value-of select="."/></name>
</xsl:for-each>
<xsl:for-each select="tokenize($testxml/age, '\s')">
<age><xsl:value-of select="."/></age>
</xsl:for-each>
</xsl:variable> <!-- now you have a proper format of data (you can also use this with apply templates instead of for-each) -->
<xsl:for-each select="$formattedinput/name">
<xsl:variable name="currpos" select="position()"/>
<person>
<name><xsl:value-of select="."/></name>
<!-- get related age by position -->
<age><xsl:value-of select="$formattedinput/age[count(preceding::age) + 1 = $currpos]"/></age>
</person>
</xsl:for-each>
Это не даст вам точный вывод, но невозможно назвать узел как <name="name1"/>
. Я пробовал это нормально и с операцией <xsl:element>
.