Set strip whitespace mode

Friday, 15 September 2023 · 2 messages
HR
Hans-Juergen Rennau15 Sep 2023 18:31 #
Dear BaseX folks, question: what is the recommended way of ensuring that an application calling BaseX via command-line (basex ...) uses a certain strip whitespace mode (true or false), if the application is deployed on servers with different BaseX versions? Option -w cannot naively be used, as it toggles the strip whitespace mode, so the effect depends on the version. I have not found out how to determine the version of BaseX reliably, using XQuery or a command. So how can a script decide whether or not to use -w? Thank you for help. Kind regards,Hans-Jürgen
CG
Christian Grün15 Sep 2023 19:11 #
Hi Hans-Jürgen,
Quoted text · Hans-Juergen Rennau · 1 line
> question: what is the recommended way of ensuring that an application
calling BaseX via command-line (basex ...) uses a certain strip whitespace mode (true or false), if the application is deployed on servers with different BaseX versions? Option -w cannot naively be used, as it toggles the strip whitespace mode, so the effect depends on the version. Sounds challenging. You can set the STRIPWS option to an explicit value… basex -c"SET STRIPWS false" query.xq ... …but this will fail as the comparable BaseX 9 option was called CHOP. You could use XQuery to retrieve the version number…
  data(db:system()//version)
…or to check if a specific option is supported: try { prof:void(db:option('chop')), '!' } catch * { '?' } In general, I would recommend updating to the latest version whenever possible… Hope this helps, Christian

⚡Generated with XQuery