The XML is detailed below. I have got round it by using count(//FORECASTDETAIL).
I have a similar issue with position()
I have some code like: concat('NEWQUANTITY_',position()). This is within a <xsl:for-each select="FORECASTDETAIL">. The position gives me the values with FORECASTDETAIL within the MONTH, but I need the position in the whole doc. E.g. If I have 5 FORECASTDETAIL in a MONTH then position returns, 1 -5, but it also returns 1-5 for the next month. I need it to go 6-10, 11-15, etc until it gets to the last FORECASTDETAIL in the document.
Hope that makes sense.
Thanks for your help
<?xml version="1.0"?>
<FORECAST xmlns="">
<DATAFOUND>TRUE</DATAFOUND>
<ITEM>
<SHIPTO>5011899</SHIPTO>
<ITEMNO>19010</ITEMNO>
<ITEMDESCRIPTION>AAAAAAA</ITEMDESCRIPTION>
<CustProdCode>Cust Prod Code</CustProdCode>
<ITEMSTATUS>S</ITEMSTATUS>
<PalletBuild>Pallets</PalletBuild>
<ProductionTag>SCA</ProductionTag>
<WebImagePath>
<MONTH>
<FORECASTYEAR>2005</FORECASTYEAR>
<FORECASTMONTH>2</FORECASTMONTH>
<FORECASTDETAIL>
<FORECASTWEEK>A</FORECASTWEEK>
<UPDATEABLE>FALSE</UPDATEABLE>
<FORECASTQUANTITY>0</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-10-01</ForecastDate>
</FORECASTDETAIL>
<FORECASTDETAIL>
<FORECASTWEEK>B</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>0</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-10-01</ForecastDate>
</FORECASTDETAIL>
<FORECASTDETAIL>
<FORECASTWEEK>C</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>0</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-10-01</ForecastDate>
</FORECASTDETAIL>
<FORECASTDETAIL>
<FORECASTWEEK>D</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>0</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-10-01</ForecastDate>
</FORECASTDETAIL>
<FORECASTDETAIL>
<FORECASTWEEK>E</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>0</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-10-01</ForecastDate>
</FORECASTDETAIL>
</MONTH>
<MONTH>
<FORECASTYEAR>2005</FORECASTYEAR>
<FORECASTMONTH>3</FORECASTMONTH>
<FORECASTDETAIL>
<FORECASTWEEK>A</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>0</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-10-01</ForecastDate>
</FORECASTDETAIL>
<FORECASTDETAIL>
<FORECASTWEEK>B</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>120</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-03-08</ForecastDate>
</FORECASTDETAIL>
<FORECASTDETAIL>
<FORECASTWEEK>C</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>60</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-03-15</ForecastDate>
</FORECASTDETAIL>
<FORECASTDETAIL>
<FORECASTWEEK>D</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>0</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-10-01</ForecastDate>
</FORECASTDETAIL>
<FORECASTDETAIL>
<FORECASTWEEK>E</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>0</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-10-01</ForecastDate>
</FORECASTDETAIL>
</MONTH>
<MONTH>
<FORECASTYEAR>2005</FORECASTYEAR>
<FORECASTMONTH>4</FORECASTMONTH>
<FORECASTDETAIL>
<FORECASTWEEK>A</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>0</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-10-01</ForecastDate>
</FORECASTDETAIL>
<FORECASTDETAIL>
<FORECASTWEEK>B</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>160</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-04-05</ForecastDate>
</FORECASTDETAIL>
<FORECASTDETAIL>
<FORECASTWEEK>C</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>0</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-10-01</ForecastDate>
</FORECASTDETAIL>
<FORECASTDETAIL>
<FORECASTWEEK>D</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>0</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-10-01</ForecastDate>
</FORECASTDETAIL>
<FORECASTDETAIL>
<FORECASTWEEK>E</FORECASTWEEK>
<UPDATEABLE>TRUE</UPDATEABLE>
<FORECASTQUANTITY>0</FORECASTQUANTITY>
<NewQuantity>0</NewQuantity>
<ForecastDate>2005-10-01</ForecastDate>
</FORECASTDETAIL>
</MONTH>
</ITEM>
</FORECAST>