Q: XSLT1.0 with grouping or XPath My Source File xml as follows:
<root>
     <bp>
         <id>999</id>
         <role>FL01</role>
         <comp/>
     </bp>
     <bp>
         <id>999</id>
         <role>FL00</role>
         <comp>123</comp>
     </bp>
     <bp>
        <id>999</id>
        <role>FL02</role>
        <comp>456</comp>
    </bp>
    <bp>
         <id>888</id>
         <role>FL01</role>
         <comp/>
     </bp>
     <bp>
         <id>888</id>
         <role>FL00</role>
         <comp>123</comp>
     </bp>
     <bp>
        <id>888</id>
        <role>FL02</role>
        <comp>456</comp>
    </bp>
</root>

I need to make final result as follows. It will split base on the <comp> and <id>. however, the <bp> without value <comp> the <role> require to add into each split. 
 <root>
     <bp>
            <id>999</id>
            <comp>123</role>
            <role>FL01</role>
             <role>FL00</role>
        </bp>
    <bp>
            <id>999</id>
            <comp>456</role>
            <role>FL01</role>
             <role>FL02</role>
        </bp>
    <bp>
            <id>888</id>
            <comp>123</role>
            <role>FL01</role>
             <role>FL00</role>
        </bp>
    <bp>
            <id>888</id>
            <comp>456</role>
            <role>FL01</role>
             <role>FL02</role>
        </bp>
    </root>

Many thanks for any help.

A: Edit 1: updated answer to reflect new requrements
(Note that I'm assuming you have your <bp> elements wrapped in a root-level element.)
If the order of each <bp>'s children isn't important, this XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  <xsl:output method="xml" omit-xml-declaration="no" indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:key name="kBpByCompAndId" match="bp" use="concat(comp, '+', id)"/>

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

  <xsl:template match="/*">
    <root>
      <xsl:apply-templates
        select="*[normalize-space(comp)][
          generate-id() = generate-id(
            key('kBpByCompAndId', concat(comp, '+', id))[1]
          )
        ]"/>
    </root>
  </xsl:template>

  <xsl:template match="bp">
    <bp>
      <xsl:apply-templates
        select="*|key('kBpByCompAndId', concat('+', id))/role"/>
    </bp>
  </xsl:template>

</xsl:stylesheet>

...will produce a functionally equivalent result:
<?xml version="1.0"?>
<root>
  <bp>
    <role>FL01</role>
    <id>999</id>
    <role>FL00</role>
    <comp>123</comp>
  </bp>
  <bp>
    <role>FL01</role>
    <id>999</id>
    <role>FL02</role>
    <comp>456</comp>
  </bp>
  <bp>
    <role>FL01</role>
    <id>888</id>
    <role>FL00</role>
    <comp>123</comp>
  </bp>
  <bp>
    <role>FL01</role>
    <id>888</id>
    <role>FL02</role>
    <comp>456</comp>
  </bp>
</root>

For reference, this XSLT makes use of a grouping technique called Muenchian Grouping; since you are new to XSLT, this is a great technique to put in your toolkit.
