First performance is not always a problem, so let's not assume it could be. Generally, if the XML is typed in (as opposed to generated from various data bases and such) you can safely assume that neither speed nor memory usage will cause you much trouble.
Whether the definitions should be right in the text or not... I guess in this case it models the way the notes are written, which seems to make sense. Later this creation-oriented XML can then be re-purposed and the definitions extracted, maybe keeping only links to them remaining in the text. In any case there will still be links in the text that could only be found by the inefficient //link XPath expression ;--). That's what you get when working with documents, which are not as "informationally organized" as data!
Really, you have to spend your computer's CPU cycles doing something (besides displaying windows all over your desktop and ads for Pair Networks in the browser ;--). So you might as well use them for something useful that makes taking notes easier in this case.
Finally, if you use XML::Twig, or any stream module for what matters, processing those def elements is actually not a huge hit performance wise, its just something else that happens during parsing.
|