Is there an equivalent to console.log or xsl:message in XQuery or BaseX ?
I know I could use the basex file: module to write to a file, but is there anything that works with the logging system to direct output according to the context ?
— Steve Majewski
Hi Steve,
You can use fn:trace to output the argument, which will itself be passed on unchanged, to standard error (or to the info view, if you use the GUI). If you want to swallow the output value, you can use the BaseX-specific function prof:dump. In web applications, you can output values to the database logs via admin:write-log.
Hope this helps Christian
Majewski, Steven Dennis (sdm7g) sdm7g@virginia.edu schrieb am Sa., 10. Aug. 2019, 16:42:
Is there an equivalent to console.log or xsl:message in XQuery or BaseX ?
I know I could use the basex file: module to write to a file, but is there anything that works with the logging system to direct output according to the context ?
— Steve Majewski
Thanks! That was what I was looking for: admin:write-log().
I’m building a dispatcher in RESTXQ to fetch a document and run one or more XSLT:transforms depending on the document type ( first by namespace, and if no namespace, falling thru to root element ), and for debugging and testing, I’ld like to log a message from the dispatcher before it calls the transform functions.
Also: I may need to change the output type depending on the dispatch. If I declare the output with %output:method, it is fixed for that function. Is there a function to change output method dynamically ? Or is the solution to use a redirect from the dispatch function to another function with a specific output declared?
— Steve.
On Aug 10, 2019, at 10:48 AM, Christian Grün christian.gruen@gmail.com wrote:
Hi Steve,
You can use fn:trace to output the argument, which will itself be passed on unchanged, to standard error (or to the info view, if you use the GUI). If you want to swallow the output value, you can use the BaseX-specific function prof:dump. In web applications, you can output values to the database logs via admin:write-log.
Hope this helps Christian
Majewski, Steven Dennis (sdm7g) <sdm7g@virginia.edu mailto:sdm7g@virginia.edu> schrieb am Sa., 10. Aug. 2019, 16:42: Is there an equivalent to console.log or xsl:message in XQuery or BaseX ?
I know I could use the basex file: module to write to a file, but is there anything that works with the logging system to direct output according to the context ?
— Steve Majewski
Is there a function to change output method dynamically ?
Yes, that’s possible: You can use web:response-header in order to assign a dynamic Content-Type header [1]. The chapter on Content Negotiation [2] may be relevant to you as well, if you want to use a single URL path but multiple RESTXQ functions for it.
[1] http://docs.basex.org/wiki/Web_Module#web:response-header [2] http://docs.basex.org/wiki/RESTXQ#Content_Negotiation
basex-talk@mailman.uni-konstanz.de