Hans, Thanks for this. It's almost what I need. I truly appreciate the effort, and it does give me some ideas about things to try. However, if I change your example buffer slightly (for clarity) to this: <text> <div type='a'> arab <ref target="#N01"> foo </ref> arab <ref target="#N02"> bar </ref> </div> <div type='b'> english <ref target="#N01"> eggs </ref> english <ref target="#N02"> ham </ref> </div> <div type='c'> <note xml:id="N01"> note text ONE</note> <note xml:id="N02"> note text TWO</note> </div> </text> your code runs and gives me this: [div a] arab [footnote1] arab [footnote2] [div a] [div b] english [note1 eggs ] english [note2 ham ] [div b] ____ 1 foo 2 bar but what I'm trying for is this: [div a] arab [ foo1 ] arab [ bar2 ] [div a] [div b] english [ eggs1 ] english [ ham2 ] [div b] ____ 1 note text ONE 2 note text TWO