I want to wrap <text> in separate <p> having @align attribute. For more clarification please see the below example.
Source
<p>
<text>Check</text>
<text>Check2</text>
<text align="center">Final</text>
<text align="right">Final Check</text>
</p>
XSLT Code:
<xsl:template match="p">
<xsl:choose>
<xsl:when test="child::text/@align">
<xsl:element name="p">
<xsl:attribute name="align">
<xsl:value-of select="child::text/@align"/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:template>
My Output
<p align="center right">
<text>Check</text>
<text>Check2</text>
<text>Final</text>
<text>Final Check</text>
</p>
Expected Output
<p>
<text>Check</text>
<text>Check2</text>
</p>
<p align="center">
<text>Final</text>
</p>
<p align="right">
<text>Final Check</text>
</p>