That is a sample not specific enough to define the need in case where ABn node have both text content and an ID attribute. I make an assumption that it will be treated as that in the previous requirement, namely, it is treated the same disregarded the existence of ID attribute. However, if the text content of ABn is empty and that it exists an ID attribute, it will be treated differently, displaying the ID in the path and its value in the resultant text content of the mapping element.
I can show you this last time the full detail of how it can be done. (The path will exhibit @ID rather than plain ID, if you understand what path means in the xpath language.) The only changes appear in the template with match (see below), the rest can be kept the same.
With that much of the details full of instructive hints, I would leave you to sort any other requirements out yourself for your own good.
Edit:
Upon reviewing, I decide to make two amendments to it.
1) Obviously a typo missing a slash in select="'/@ID'".
2) Take out the parent::*
test so that the script would extend its scope of applicability allowing only BODY tag then nothing else (ie only root level).