Вот решение XSLT 3, которое использует отдельный режим для рекурсивного проталкивания каждого атрибута через шаблон для достижения вложения:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
version="3.0">
<xsl:mode on-no-match="shallow-copy"/>
<xsl:output method="html" html-version="5"/>
<xsl:template match="s">
<p>
<xsl:apply-templates select="." mode="att"/>
</p>
</xsl:template>
<xsl:template match="s" mode="att">
<xsl:param name="attributes" select="@*"/>
<xsl:apply-templates select="if (head($attributes)) then head($attributes) else node()" mode="att">
<xsl:with-param name="attributes" select="$attributes"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="@bold[. = 'true']" mode="att">
<xsl:param name="attributes"/>
<b>
<xsl:apply-templates select=".." mode="att">
<xsl:with-param name="attributes" select="tail($attributes)"/>
</xsl:apply-templates>
</b>
</xsl:template>
<xsl:template match="@italic[. = 'true']" mode="att">
<xsl:param name="attributes"/>
<i>
<xsl:apply-templates select=".." mode="att">
<xsl:with-param name="attributes" select="tail($attributes)"/>
</xsl:apply-templates>
</i>
</xsl:template>
<xsl:template match="@color" mode="att">
<xsl:param name="attributes"/>
<span style="color: {.};">
<xsl:apply-templates select=".." mode="att">
<xsl:with-param name="attributes" select="tail($attributes)"/>
</xsl:apply-templates>
</span>
</xsl:template>
</xsl:stylesheet>
https://xsltfiddle.liberty -development.net / 3NzcBuc /0
Его транслитерация XSLT 1 будет
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:output method="html" indent="yes" version="5.0" doctype-system="about:legacy-doctype"/>
<xsl:template match="s">
<p>
<xsl:apply-templates select="." mode="att"/>
</p>
</xsl:template>
<xsl:template match="s" mode="att">
<xsl:param name="attributes" select="@*"/>
<xsl:choose>
<xsl:when test="$attributes">
<xsl:apply-templates select="$attributes[1]" mode="att">
<xsl:with-param name="attributes" select="$attributes"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@bold[. = 'true']" mode="att">
<xsl:param name="attributes"/>
<b>
<xsl:apply-templates select=".." mode="att">
<xsl:with-param name="attributes" select="$attributes[position() > 1]"/>
</xsl:apply-templates>
</b>
</xsl:template>
<xsl:template match="@italic[. = 'true']" mode="att">
<xsl:param name="attributes"/>
<i>
<xsl:apply-templates select=".." mode="att">
<xsl:with-param name="attributes" select="$attributes[position() > 1]"/>
</xsl:apply-templates>
</i>
</xsl:template>
<xsl:template match="@color" mode="att">
<xsl:param name="attributes"/>
<span style="color: {.};">
<xsl:apply-templates select=".." mode="att">
<xsl:with-param name="attributes" select="$attributes[position() > 1]"/>
</xsl:apply-templates>
</span>
</xsl:template>
</xsl:stylesheet>
https://xsltfiddle.liberty -development.net / 3NzcBuc / 1