How to realize cross reference

It sounds like these IDs would better be stored at the document level, rather than with decorations. See for example this thread for some related discussion.