Q: selectively extracting a value from xsl:for I have the basic query i have the given xml  as shown below..
<?xml version="1.0" encoding="UTF-8"?>
<Report xmlns:fpml="http://www.fpml.org/FpML-5/confirmation" xmlns="http://www.eurexchange.com/EurexIRSFullInventoryReport" name="CB202 Full Inventory Report">
  <reportNameGrp>
    <CM>
      <acctTypGrp name="A9">
        <ProductType name="Swap">
        </ProductType>
      </acctTypGrp>
      <acctTypGrp name="P">
        <ProductType name="Swap">
        </ProductType>
        <ProductType name="FRA">
        </ProductType>
      </acctTypGrp>
    </CM>
  </reportNameGrp>
</Report>

the xslt that i have devloped is like this..
<xsl:stylesheet version="1.0" xmlns:fpml="http://www.fpml.org/FpML-5/confirmation"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:eur="http://www.eurexchange.com/EurexIRSFullInventoryReport" xmlns:java="http://xml.apache.org/xslt/java"
    exclude-result-prefixes="java">
<xsl:template match="/eur:Report">
    <Eurexflows>
   <xsl:call-template name="EurexreportNameGrp_block">
    <xsl:with-param name="CMaccounttypeGroup"   select="/eur:Report/eur:reportNameGrp/eur:CM/eur:acctTypGrp" />
    </xsl:call-template>
    </Eurexflows>
  </xsl:template>

   <xsl:template name="EurexreportNameGrp_block">
    <xsl:param name="CMaccounttypeGroup" />
    <xsl:for-each select="$CMaccounttypeGroup">
      <EurexMessageObject>
     <name>
        <xsl:value-of select="@name" />
     </name>
     <ProductType>
    <!--  <xsl:value-of select="$CMaccounttypeGroup/eur:ProductType/@name" /> -->
     <xsl:call-template name="producttypes_template">
     <xsl:with-param name="TradeHeaderVarr" select="$CMaccounttypeGroup/eur:ProductType" />
     </xsl:call-template>
     </ProductType>
      <!-- <nameforproduct>
     <xsl:value-of select="$CMaccounttypeGroup/eur:ProductType/@name" />
     <xsl:call-template name="product_template">
     <xsl:with-param name="TradeHeaderVarr" select="$CMaccounttypeGroup" />
     </xsl:call-template>
     </nameforproduct> -->
     </EurexMessageObject>
</xsl:for-each>
</xsl:template>



<xsl:template name="producttypes_template">
   <xsl:param name="TradeHeaderVarr" />
   <xsl:for-each select="$TradeHeaderVarr">
   <xsl:value-of select="eur:ProductType" />

   </xsl:for-each>   
   </xsl:template>

</xsl:stylesheet>

I want my final xml after transformation should be like this as shown below and in which there are two enetries of p
`

<EurexMessageObject>

    <name>A1</name>

    <ProductType> swap
    </ProductType>
</EurexMessageObject>
<EurexMessageObject>
    <name>A2</name>
    <ProductType> swap
    </ProductType>
</EurexMessageObject>
<EurexMessageObject>
    <name>A3</name>
    <ProductType> swap
    </ProductType>
</EurexMessageObject>
<EurexMessageObject>
    <name>A4</name>
    <ProductType> swap
    </ProductType>
</EurexMessageObject>
<EurexMessageObject>
    <name>A5</name>
    <ProductType> swap
    </ProductType>
</EurexMessageObject>
<EurexMessageObject>
    <name>A6</name>
    <ProductType> swap
    </ProductType>
</EurexMessageObject>
<EurexMessageObject>
    <name>A7</name>
    <ProductType> swap
    </ProductType>
</EurexMessageObject>
<EurexMessageObject>
    <name>A8</name>
    <ProductType> swap
    </ProductType>
</EurexMessageObject>
<EurexMessageObject>
    <name>A9</name>
    <ProductType> swap
    </ProductType>
</EurexMessageObject>
<EurexMessageObject>
    <name>P</name>
    <ProductType> swap
    </ProductType>
</EurexMessageObject>
<EurexMessageObject>
    <name>P</name>
    <ProductType>fra
    </ProductType>
</EurexMessageObject>


`
Please advise what changes need to be done in xsl in order to achieve final xml as shown above      

A: Here's how you can do this rather concisely:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
                xmlns:eur="http://www.eurexchange.com/EurexIRSFullInventoryReport">
  <xsl:output method="text" />

  <xsl:template match="eur:ProductType">
    <xsl:variable name="acctTyp" select="../@name" />
    <xsl:value-of select="concat($acctTyp, 
                                 substring('    ', string-length($acctTyp)), 
                                 @name, '&#xA;')" />
  </xsl:template>
  <xsl:template match="text()" />

</xsl:stylesheet>

When run on your sample input, the result is:
A9   Swap
P    Swap
P    FRA

The following is an XSLT to produce the XML format you showed above:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
                xmlns:eur="http://www.eurexchange.com/EurexIRSFullInventoryReport"
                exclude-result-prefixes="eur">
  <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />

  <xsl:template match="/*">
    <Eurexflows>
      <xsl:apply-templates
        select="eur:reportNameGrp/eur:CM/eur:acctTypGrp/eur:ProductType" />
    </Eurexflows>
  </xsl:template>

  <xsl:template match="eur:ProductType">
    <EurexMessageObject>
      <name>
        <xsl:value-of select="../@name" />
      </name>
      <ProductType>
        <xsl:value-of select="@name"/>
      </ProductType>
    </EurexMessageObject>
  </xsl:template>

</xsl:stylesheet>

When run on your sample XML, the result is:
<Eurexflows>
  <EurexMessageObject>
    <name>A9</name>
    <ProductType>Swap</ProductType>
  </EurexMessageObject>
  <EurexMessageObject>
    <name>P</name>
    <ProductType>Swap</ProductType>
  </EurexMessageObject>
  <EurexMessageObject>
    <name>P</name>
    <ProductType>FRA</ProductType>
  </EurexMessageObject>
</Eurexflows>


A: Try this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fpml="http://www.fpml.org/FpML-5/confirmation">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="*:CM">
    <xsl:for-each select="*:acctTypGrp/*:ProductType">
        <xsl:value-of select="../@name"/>
        <xsl:value-of select="substring('    ', string-length(../@name))"/>
        <xsl:value-of select="@name"/>
        <xsl:text>&#10;</xsl:text>
    </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

