Use these Java applets to check your syntax online, or as the basis for your own XPath 2, XPath 3 (draft) or XQuery 1.0 or 3 implementation. They support XML Query, XPath 2, Full Text and Update and also the varions 3.0 drafts.
The applets are a tool for readers and parser implementers of XPath, XQuery, XSLT and other languages using or extending the XPath grammar. The results should not be used as an absolute reference, and may flag legal syntax or errors not intended by the drafts. However, the applets were generated by processing the XML representation of the grammar, which is also used to produce the EBNF productions in the XPath and XQuery specifiations. This parser is also used by the working groups to validate the integrity of the grammar. Implementers may wish to download the XPath/XQuery Parser Build, xgrammar_src.zip and xgrammar_libs.zip, if they are interested in the parser production, and more details of this process.
(* The extracted grammar used here doesn't duplicate the normative EBNF, but it should be equivalent.)