| | # Overview |
| | |
| | -Relational XPath Map (RXM) is a terse database query language that |
| | -produces structured documents using a [BNF Converter](http://bnfc.digitalgrammars.com/). |
| | +Relational XPath Map (**rxm**) is a simple, terse database query language |
| | +that produces structured documents. |
| | + |
| | +The syntax examples show how to produce an XML document, but the same |
| | +mapping could produce any structured format (e.g., JSON, YAML, or TOML). |
| | + |
| | +# Syntax |
| | + |
| | +This section describes the **rxm** language syntax. The syntax entails a map |
| | +and a where clause. |
| | + |
| | +## Map |
| | + |
| | +The element mapping consists primarily of a database entity on the left |
| | +and a simple XPath expression on the right. |
| | |
| | ``` |
| | -root > people, # "root" is a keyword |
| | +root > people, # "root" keyword starts the document |
| | person > person, # maps a node to table context |
| | .first_name > first, # maps a node to column |
| | .last_name > name/last, # maps an ancestor node to a column |
| | .age > @age, # @ maps an attribute to table node |
| | account.person_id > person.person_id, # performs an inner join |
| | account > account, # context is now "account" node |
| | .id > @id, |
| | -^, # return to previous context |
| | +^, # pop stack to previous context |
| | address > address, |
| | .*; # * globs all columns. ; is WHERE |
| | ``` |
| | |
| | -# Namespaces |
| | +This would produce a document structure similar to the following: |
| | |
| | ``` |
| | -root > people(html, http://www.w3.org/TR/html4/), |
| | -person > html:person, |
| | - |
| | -person.id > people:id( people, http://www.people.com ), |
| | +<people> |
| | + <person age="42"> |
| | + <first>Charles</first> |
| | + <name> |
| | + <last>Goldfarb</last> |
| | + </name> |
| | + <account id="123"/> |
| | + <address> |
| | + <street>123 Query Lane</street> |
| | + <city>San Francisco</city> |
| | + </address> |
| | + </person> |
| | +</people> |
| | ``` |
| | |
| | -# Where clause |
| | +Note: Multiple stack pops (`^`) are allowed per line. If a pop would otherwise |
| | +exceed the root context, the context remains at the root. |
| | + |
| | +## Where |
| | |
| | ``` |
 |
| | account.id <= 42 # numeric less than or equal to comparison |
| | account.id >= 42 # numeric greater than or equal to comparison |
| | +``` |
| | + |
| | +## Namespace |
| | + |
| | +``` |
| | +root > people(html, http://www.w3.org/TR/html4/), |
| | +person > html:person, |
| | + |
| | +person.id > people:id( people, http://www.people.com ), |
| | ``` |
| | + |
| | +# Requirements |
| | + |
| | +The software requirements include: |
| | + |
| | +* [Java 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) |
| | +* [BNF Converter](http://bnfc.digitalgrammars.com/) (see the [BNFC documentation](https://bnfc.readthedocs.org/en/latest/lbnf.html) for details) |
| | + |
| | +# Rationale |
| | + |
| | +The reasons to create **rxm** include: |
| | + |
| | +* Decouple SQL statements from document output format. |
| | +* Eliminate repetitious code. |
| | +* Provide a database-agnostic mechanism to generate structured documents |
| | +(currently based on SQL/XML). |
| | +* Few databases are fully compliant with SQL/XML:2006. |
| | +* XQuery has limited open-source implementations for major RDBMS software. |
| | + |
| | +# Addendum |
| | + |
| | +It might be possible to reuse maps for bidirectional data loading in addition |
| | +to data extraction. |
| | |
| | |