I have a non trivial set of XSLT code in a library where I have ended up (quite understandly) with some cyclic and/or multiple includes of the same file.
So...
`Warning at xsl:stylesheet on line 10 column 63 of value.xslt: SXWN9019 Stylesheet module file:.....value.xslt is included or imported more than once. This is permitted, but may lead to errors or unexpected behavior
Error at xsl:function on line 59 column 54 of value.xslt: XTSE0770 Function value:getValue#1 is declared twice - see .../value.xslt#59 .... `
I've only recently done this (to simplify the structure of the code) and, it breaks.
Having investigated this my understand that this is valid in some contexts (as the error message indicates), but doesn't really work, (as the error message indicates)...which is a tad confusing, I assume there is some scenario where this does work, but I'm breaking the rules.
How do I do this? (this is common issue in other languages, I remember using #defines in .h files in C, and F#, for example, doesn't allow cycles, but has quite sophisticated ways to wriggle around the issue).
(SaxonHE12-4J\saxon-he-12.4.jar)
due to feedback from Martin Honnen, I've changed all includes for import.
This works, but I still get the warning, which is worrying, what can go wrong?
Basically, including a module twice isn't in itself an error, but if the module contains any named components such as functions, variables, or named templates, then it's likely to lead to an error because you can't have two named components with the same name.
The answer to the question "how do I do this" is that you don't need to, because everything you include is available globally throughout the stylesheet.
It can be a problem if you're trying to include code that you don't want to change, but if that's not a constraint, the simplest solution is to move all includes to the top level. Alternatively, learn about xsl:import
-- but that can bring its own set of problems.