console.log ?
Saturday, 10 August 2019 · 4 messages
MS
Majewski, Steven Dennis (sdm7g)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
CG
Christian Grün10 Aug 2019 16:48 #
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 at virginia.edu> schrieb am Sa., 10. Aug. 2019, 16:42:Quoted text · Majewski, Steven Dennis (sdm7g) · 10 lines
> 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 > > >
MS
Majewski, Steven Dennis (sdm7g)10 Aug 2019 18:06 #
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.Quoted text · Christian Grün · 19 lines
> On Aug 10, 2019, at 10:48 AM, Christian Grün <christian.gruen at 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 at virginia.edu <mailto:sdm7g at 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 > >
CG
Christian Grün10 Aug 2019 19:59 #
Quoted text · Majewski, Steven Dennis (sdm7g) · 3 lines
> > 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_NegotiationWritten for BaseX 9.2. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery