I have an XML File.
Although this is not simple, I think you are making it much more complicated than it needs to be. Try the following stylesheet (not tested very thoroughly):
XSLT 1.0
- newid_answer
- newid_number
Note: when you are in the context of a node-set created by the exslt:node-set() function, you cannot use a key() to lookup data in the source XML document, unless you switch the context to the source document first.