XQuery/Naming Conventions
Guidelines for wikibook authors
editOur goal is to allow many people to contribute examples but allow our readers a consistent user experience. In that light we would like all of our authors to use some of the following standards.
This book has a strong focus on learning some aspect of XQuery via examples. Our hope is to have a large collection of small sample XQuery programs. Each program should have the minimal code to demonstrate some aspect of XQuery. Although most of our users use eXist, we hope the examples can be used with MarkLogic, BaseX and other XQuery systems.
Make sure you use the source tags to surround your code. If it is XML code use the lang="xml" attribute.
<syntaxhighlight lang="xml"> ...xml code here... </syntaxhighlight>
If it is XQuery code use the lang="xquery" attribute.
<syntaxhighlight lang="xquery"> ...xml code here... </syntaxhighlight>
Try to keep the examples as simple as you can to demonstrate the core concepts of your examples.
Sample XQuery File
editxquery version "1.0";
let $message := 'Hello World!'
return
<results>
<message>{$message}</message>
</results>
Each XQuery file should begin with the word xquery and the version number.
xquery version "1.0";
Complex XQueries should have comments using the XQuery comments
xquery version "1.0";
(: This is a comment :)
File Name Conventions
editPlease use three space characters to indent your XQuery and XML examples. Do not use tabs. We use three characters because we use PDF output of these books and the printed pages have limited width.
Please do not exceed 70 characters per line. This helps formatting for printed versions of this Wikibook.
For XQuery scripts are stored inside the database please use the .xq suffix.
If you are running on a system that MUST be compatible with the three-letter Microsoft DOS file name extension please use the .xql file suffix.
For XQuery modules please use the suffix .xqm.
For each module that has unit tests use the suffix -test.xq.