Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/rxm.git

Modules.

AuthorDave Jarvis <email>
Date2015-02-09 14:50:26 GMT-0800
Commit6d081e92a750736b94dde60706f5c9792f320050
Parentf13f899
README.md
This implementation provides a Java API for building SQL statements
-that produce XML documents based on **rxm**.
+that produce XML documents based on **rxm**. The examples below do not
+show how to obtain a database connection, which the [JDBC documentation](http://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html) describes.
-## Example
+## Basic
-The following example shows how to use the **rxm** Java API to query the
-database and generate an XML document:
+Use the **rxm** Java API to generate an XML document as follows:
```
import com.whitemagicsoftware.rxm.RelationMap;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
+public class QueryTest {
+ public static void main( String args[] ) throws Exception {
+ RelationMap rxm = new RelationMap(
+ "root > people," +
+ "person > person," +
+ ".*,"
+ );
+
+ System.out.println( rxm.toXML( getConnection() ) );
+ }
+}
+```
+
+## Modules
+
+The **rxm** API allows the definition of modules, such as:
+
+```
+import com.whitemagicsoftware.rxm.RelationMap;
public class QueryTest {
public static void main( String args[] ) throws Exception {
- String sql = RelationMap.toSQL(
+ RelationMap rxm = new RelationMap();
+ rxm.module( "people",
"root > people," +
"person > person," +
".*,"
);
- PreparedStatement statement = getConnection().prepareStatement( sql );
- ResultSet results = statement.executeQuery();
+ rxm.setQuery( "import 'people'," );
- if( results.first() ) {
- System.out.println( results.getString( 0 ) );
- }
+ System.out.println( rxm.toXML( getConnection() ) );
}
}
```
-
-See the [JDBC documentation](http://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html) for details to obtain a database connection.
# Requirements
Delta27 lines added, 14 lines removed, 13-line increase