XPath 2.0 / XQuery Build System

This file describes the XPath 2.0 / XQuery 1.0 grammar tests and build system. The files in this directory are a subset of the XPath 2.0 / XQuery 1.0 editorial build system.

The Grammar

The grammar is described by the same XML grammar file for XPath 2.0, XQuery 1.0. The tokens and productions that differ between the grammars are specified with a conditional "if" attribute. The main languages described by the XML grammar are XPath 2.0 and XQuery 2.0, however, other sublanguages are also defined, such as the XQuery 1.0 Formal Semantics Core Language, XSLT 2.0 patterns, and XPath 1.0.

This XML grammar file is transformed via XSLT to produce JavaCC/JTree parsers, LALR parsers (coming soon... -editor), and BNF descriptions that are either standalone or used in the XPath 2.0 and XQuery 1.0 W3C specifications.

JJTree Parsers

You can run the JJTree parsers (xpath.jar, xquery.jar, and pathx1.jar) on the command line, and they will produce a dump of the abstract syntax tree produced by JJTree.  You can either pass in one or more expressions as command line parameters, or have it prompt you for each expression.  Examples:

E:\xqed>java -jar xpath.jar
Type Expression:
foo+2*3
|FLWRExpr
|   QuantifiedExpr
|      IfExpr
|         InstanceofExpr
|            AdditiveExpr +
|               UnaryExpr
|                  PathExpr
|                     StepExpr
|                        AbbreviatedForwardStep
|                           NodeTest
|                              NameTest
|                                 QName foo
|                        Predicates
|               MultiplicativeExpr *
|                  UnaryExpr
|                     PathExpr
|                        StepExpr
|                           IntegerLiteral 2
|                           Predicates
|                  UnaryExpr
|                     PathExpr
|                        StepExpr
|                           IntegerLiteral 3
|                           Predicates

You can exit out of the prompt loop simply by hitting the return key without typing an expression.

In addition to the command line utility, applet pages are also included that let you do the same thing. The pages are called xpathApplet.html and xqueryApplet.html.

Files

Build related files

readme.htmlThis file.
build.batThe ANT batch file for easy ant execution from DOS.
build.xmlThe ANT build file. You'll need JAXP 1.1 complient XML parser and XSLT processor installed to use this.

Grammar related files

xpath-grammar.xmlThe grammar definition for at least XPath 2.0, and XQuery 1.0, in XML.
javacc.xslStylesheet to produce the JavaCC grammar that produces xpath.jar and xquery.jar.
jjtree.xslImports javacc.xsl, produces JJTree parser that spits a diagnostic syntax tree to the console.
SimpleNode.javaForms the base for the JJTree abstract syntax tree.  This file will be copied to the ${spec}-src directories.
Test.javaSimple test class for running the -major tests.  This file will be copied to the ${spec}-src directories.
xpath-manifest.txtNeeded to build xpath.jar.
xquery-manifest.txtNeeded to build pathx1.jar.
pathx1-manifest.txtNeeded to build pathx1.jar.

Test related files

use-cases.xquerytest file used for test-xquery-major target.
pathx1-tests.xmlXPath1 tests file used for test-pathx1-major target. Both xpath.jar and xquery.jar should be able to run these tests, in addition to pathx1.jar.

Specification related files

These files are related to the W3C specifications:

xmlspec-v21.dtd --> The document type definition defined for W3C XML specification files.

XPathXQuery.xml, introduction.xml, expressions.xml, query-prolog.xml, ebnf.xml--> XQuery 1.0 and XPath 2.0 Proposal in XML form.
xmlspec-v21.dtd --> Heavily hacked DTD, partly to make it go through XMetal.
xmlspec.xsl --> Basic XML spec XSL.

The build file (build.xml)

Build.xml is the build file for use with Ant (http://jakarta.apache.org/ant).

The full distribution comes with the the ant, and JAXP 1.1 complient XML parser and XSLT processor, as well as JavaCC.  Build.bat has the paths to these jars built in, so you shouldn't have to do anything special.

Build properties and targets

To get a description of the properties and targets, do:

build -projecthelp

Keep in find that build.xml is used with the full editorial build system, so there are some targets that will not work with this subset build.

Properties (first value given is the default):
 

Property nameProperty valuesDescription
specxquery|xpath|pathx1Specifies the desired grammar subset formany targets.
debugfalse|trueTurns debugging trace on for the parsers.

You can set a property from the command line via -Dpropname=propvalue.

Keep in mind that you can use multiple targets.
Example:

build jars test