Op 30 dec 2010, om 04:28 heeft Charles F. Munat het volgende geschreven:
This is an interesting idea, if a bit complex.
Mark's idea does not seem too complex to me, I think it depends on the environment you're working in. I use a similar trick, storing the XQueries in XSLT templates and calling these when needed. For example:
<xsl:template name="auth"> declare function {...}; </xsl:template>
and then when compiling the query using XSLT:
<query> declare namespace ... ; <xsl:call-template name="auth"/> </query>
and then I send it off to the XML database (eXist or BaseX) using HTTP. Using Cocoon this is very easy and it gives me a lot of control and no maintenance costs (compared to managing stored queries f.i). There are drawbacks of course, not the least of which is that oXygen doesn't recognize my XQueries stored inside a XSLT stylesheet and doesn't do syntax highlighting etc.
As was said earlier, I wouldn't worry too much about creating large XQueries, the compiler is fast and as time goes by and the dataset grows most time will be spent executing the query. OTOH, sometimes every millisecond counts.
Huib.