Is it possible to implement "if else, if else" in xsl? for example I have data:
<document>
<line>
<name>MAR111</name>
<value>1</value>
</line>
<line>
<name>MAR111</name>
<value>3</value>
</line>
<line>
<name>MEA111</name>
<value>1</value>
</line>
<line>
<name>MPR111</name>
<value>1</value>
</line>
<line>
<name>MEA111</name>
<value>4</value>
</line>
<line>
<name>MPR111</name>
<value>2</value>
</line>
</document>
I need to get three document templates with three names:
<document>
<MAR>
<name>MAR111</name>
<number>1</number>
<number>4</number>
</MAR>
</document>
<document>
<MEA>
<name>MEA111</name>
<number>1</number>
<number>4</number>
</MEA>
</document>
<document>
<MPR>
<name>MPR111</name>
<number>1</number>
<number>2</number>
</MPR>
</document>
I try to use "choose, when" on apply template, but maybe there is a better way:
<xsl:template match="/">
<xsl:choose>
<xsl:when test="/document/line/name='MEA111'">
<xsl:apply-templates mode="MEA" select="/document"/>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="/document/line/name='MPR111'">
<xsl:apply-templates mode="MPR" select="/document"/>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="/document/line/name='MAR111'">
<xsl:apply-templates mode="MAR" select="/document"/>
</xsl:when>
</xsl:choose>
</xsl:template>