How to transform this XML into HTML using XSLT..PART-2?
Following is the XML piece of code - 

    <groups>
      <group i=1>
        <member t="P.M" c="Y">ABC</member>
        <member t="P.L">PQR</member>
        <member t="M">XYZ</member>
      </group>
      <group i=2>
        <member t="M" c="Y">ABC</member>
        <member t="M">PQR</member>	
      </group>
      <group i=3>
        <member t="P.L" c="Y">ABC</member>
        <member t="M">PQR</member>	
        <member t="M">XYZ</member>	
      </group>
      <group i=4>
        <member t="M">ABC</member>
        <member t="M" c="Y">PQR</member>	
      </group>
      <group i=5>
        <member t="M">ABC</member>
        <member t="M" c="Y">PQR</member>	
        <member t="M" c="Y">XYZ</member>	
      </group>
      <group i=6>
        <member t="M" dec="Y">ABC</member>
      </group>

    </groups>


Desired HTML output using **XSLT 1.0** - 


    <U>ABC</U>, P.M, PQR, P.L and XYZ, M
    <U>ABC</U> and PQR, MM
    <U>ABC</U>, P.L, PQR and XYZ, MM
    ABC and <U>PQR</U>, MM
    ABC, <U>PQR</U> and <U>XYZ</U>, MM
    <U>ABC</U>, M


The **partial** XSLT solution for the above output is -

    <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
    <xsl:output method='html' media-type='text/html'/>
    <xsl:template match="/">
      <html>
      <body>
  	<xsl:apply-templates/>
      </body>
      </html>
    </xsl:template>

    <xsl:template match="group">
        <p>
          <xsl:apply-templates select="@*|node()"/>
        </p>
    </xsl:template>

    <xsl:template match="member">
       <xsl:choose>
         <xsl:when test='@c = "Y"'>
           <u><xsl:value-of select="."/></u>, <xsl:value-of select='@t'/>
         </xsl:when>
         <xsl:otherwise>
           <b><xsl:value-of select="."/></b>, <xsl:value-of select='@t'/>
         </xsl:otherwise>
       </xsl:choose>
    </xsl:template>

    <xsl:template match="member[following-sibling::member]">
      <xsl:choose>
        <xsl:when test='@c = "Y"'>
          <u><xsl:value-of select="."/></u>, <xsl:value-of select='@t'/>
          <xsl:text> and </xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <b><xsl:value-of select="."/></b>, <xsl:value-of select='@t'/>
          <xsl:text> and </xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>

    <xsl:template match="member[following-sibling::member[following-sibling::member]]">
      <xsl:choose>
        <xsl:when test='@c = "Y"'>
          <u><xsl:value-of select="."/></u>, <xsl:value-of select='@t'/>
          <xsl:text>, </xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <b><xsl:value-of select="."/></b>, <xsl:value-of select='@t'/>
          <xsl:text>, </xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
    </xsl:stylesheet>


The above XSLT is giving the output in correct format as required, but if the `<member>`
are of same type then how to add this type at the end..?



How to transform this XML into HTML using XSLT..PART-2?
===

Following is the XML piece of code - 

    <groups>
      <group i=1>
        <member t="P.M" c="Y">ABC</member>
        <member t="P.L">PQR</member>
        <member t="M">XYZ</member>
      </group>
      <group i=2>
        <member t="M" c="Y">ABC</member>
        <member t="M">PQR</member>	
      </group>
      <group i=3>
        <member t="P.L" c="Y">ABC</member>
        <member t="M">PQR</member>	
        <member t="M">XYZ</member>	
      </group>
      <group i=4>
        <member t="M">ABC</member>
        <member t="M" c="Y">PQR</member>	
      </group>
      <group i=5>
        <member t="M">ABC</member>
        <member t="M" c="Y">PQR</member>	
        <member t="M" c="Y">XYZ</member>	
      </group>
      <group i=6>
        <member t="M" dec="Y">ABC</member>
      </group>

    </groups>


Desired HTML output using **XSLT 1.0** - 


    <U>ABC</U>, P.M, PQR, P.L and XYZ, M
    <U>ABC</U> and PQR, MM
    <U>ABC</U>, P.L, PQR and XYZ, MM
    ABC and <U>PQR</U>, MM
    ABC, <U>PQR</U> and <U>XYZ</U>, MM
    <U>ABC</U>, M


The **partial** XSLT solution for the above output is -

    <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
    <xsl:output method='html' media-type='text/html'/>
    <xsl:template match="/">
      <html>
      <body>
  	<xsl:apply-templates/>
      </body>
      </html>
    </xsl:template>

    <xsl:template match="group">
        <p>
          <xsl:apply-templates select="@*|node()"/>
        </p>
    </xsl:template>

    <xsl:template match="member">
       <xsl:choose>
         <xsl:when test='@c = "Y"'>
           <u><xsl:value-of select="."/></u>, <xsl:value-of select='@t'/>
         </xsl:when>
         <xsl:otherwise>
           <b><xsl:value-of select="."/></b>, <xsl:value-of select='@t'/>
         </xsl:otherwise>
       </xsl:choose>
    </xsl:template>

    <xsl:template match="member[following-sibling::member]">
      <xsl:choose>
        <xsl:when test='@c = "Y"'>
          <u><xsl:value-of select="."/></u>, <xsl:value-of select='@t'/>
          <xsl:text> and </xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <b><xsl:value-of select="."/></b>, <xsl:value-of select='@t'/>
          <xsl:text> and </xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>

    <xsl:template match="member[following-sibling::member[following-sibling::member]]">
      <xsl:choose>
        <xsl:when test='@c = "Y"'>
          <u><xsl:value-of select="."/></u>, <xsl:value-of select='@t'/>
          <xsl:text>, </xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <b><xsl:value-of select="."/></b>, <xsl:value-of select='@t'/>
          <xsl:text>, </xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
    </xsl:stylesheet>


The above XSLT is giving the output in correct format as required, but if the `<member>`
are of same type then how to add this type at the end..?


