I'm not sure that I get what we are trying to achieve with main modules here:
My scheme is:

User comes in with one of:
  • http://host:port/menu?id=x in menu.xqm
  • http://host:port/topic?id=y in topic.xqm
Both menu.xqm and topic.xqm import a module with common functions (contentrefs.xqm) that resolve content references, for example: contentref:fill-with-product-name(content as node(), product as xs:string)

contentref:fill-with-product-name is the one that makes the node replacement (similar to the flower example). 

My 'scheme'-related question is:

Should contentrefs.xqm really be converted to a main module?