I'm not sure what you're asking. Do you understand why your code is producing L = D + W (23) as the initial output? You've evaluated substring-after(@id,'E'), multiplied by 1 to turn it into a number, and the answer is 23. You say you want to output 18 here rather than 23, but I can't see where the 18 is supposed to come from.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference