Skip to content

Instantly share code, notes, and snippets.

@joewiz
Last active October 2, 2017 08:45
Show Gist options
  • Save joewiz/b53612a8b7744b8d1d24d2028770a79d to your computer and use it in GitHub Desktop.
Save joewiz/b53612a8b7744b8d1d24d2028770a79d to your computer and use it in GitHub Desktop.
Notes on factors that influence whitespace in XQuery, with a focus on eXist 3.x

Notes in preparation for a blog post or article.

Factors

Takeaways

  • Be explicit and conscious of whitespace in source documents, especially in mixed content
  • If using in-memory nodes, be conscious of boundary-space default setting, strip
  • Be conscious of default indent settings. If boundary-space strip and serializer indent=yes this can make a document appear as if it has whitespace, when it really doesn't
  • indent=yes can introduce whitespace; saving a document back into the database can result in extra whitespace

Remaining questions

  • Does indent=no ever completely strip whitespace where it was, or does it just collapse whitespace to a single character?
  • Does indent=yes ever insert whitespace where there wasn't any, or does it just expand existing whitespace?
  • What role does the indexer's whitespace settings (suppress-whitespace=leading|trailing|both|none or preserve-whitespace-mixed-content=yes|no) play? Under what scenarios does it affect the results of a query?
  • What role does the parser play? Presumably none, except for resolving entities?
@welblaud
Copy link

welblaud commented Oct 2, 2017

In the case of eXide, it also helps to set indent=no in eXide/modules/load.xql. With this it seems eXide perseveres everything as intended (and indented :) ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment