Cannot re-assign a value to XSLT variable, or can I exit from  

`<xsl:for-each` conditionally  

my XML

```
<R>
  <A id="a">  
    <S id="a111">1</S>  
    <S id="a222">2</S>
    <S id="a333">3
      <S id="a3331">3.1</S>
      <S id="a3332">3.2</S>
      <S id="a3333">3.3</S>  
    </S>
    <S id="a444">4</S>
    <S id="a555">5</S>
    <S id="a666">6</S>
  </A>
  <A id="x">
    <S id="x111">1</S>
    <S id="x222">2</S>
    <S id="x333">3
      <S id="x3331">3.1</S>
      <S id="x3332">3.2</S>
      <S id="x3333">3.3</S>
    </S>
    <S id="x444">4</S>
    <S id="x555">5</S>
    <S id="x666">6</S>
  </A>
</R>

```

my XSLT

```
     <select id ="S"  name="SList">
     <option>
       <xsl:attribute name="value"></xsl:attribute> Please Select S 
     </option>
     <xsl:for-each select="A[id='x']//S">

       <xsl:if test="'x3333'= @id">
         <xsl:variable name="currentS" select="true()"/>
       </xsl:if>
       <xsl:if test="'x3333'!= @id">
         <xsl:variable name="currentS" select="false()"/>
       </xsl:if>

       <xsl:if test="@currentS = false()">
         <option>
           <xsl:if test="@id = 'x3333'">
             <xsl:attribute name="selected">selected</xsl:attribute>
           </xsl:if>
           <xsl:attribute name="value">
             <xsl:value-of select="@id"/>
           </xsl:attribute>              
           <xsl:value-of select="Text"/>
         </option>
       </xsl:if>
     </xsl:for-each>

```

I'm trying to create a drop down list and I need to include `S` items in the list. I am passing the current position (current `S`, in this example `x3333`) and current id of `A`. I want to get only list of `S` elements within most recent `A` element.

In this example, since my current `S` is `x3333` and id of `A` is `x` I need only `x111`,`x222`,`x333`,`x3331`,`x3332` to be in the list. That means I need to eliminate these

```
  <S id="x444">4</S>,
  <S id="x555">5</S>,
  <S id="x666">6</S>, nodes

```

from this code `<xsl:for-each select="A[id='x']//S">` 

I'm getting the list of `S` elements in `A` where `id='x'`

Can someone suggest me a solution please?