If you want to write Java, then
you should write Java. But I warn you that DOM programs are ugly and brittle and hard to maintain when the requirements change.
XSLT is not Java, and it is not like Java. I don't know why you thought you need a list but that is not how you do things in XSLT. What you should do instead is to describe how and when you would create one of those <child> elements, based on the contents of the input file. Then you write XSLT code that does that.
Give that a try. Why do you have an element <child number="2"> and where does the data come from in the input document?