INRIA
[Up]
Warning

Work in progress

This version may be updated without notice.

RDBMS Specification (SQL)

A RDBMS (SQL) module for Active Tags

Working Draft 29 march 2006

Editor
Philippe Poulard  <Philippe.Poulard@sophia.inria.fr>

Copyright © INRIA

Abstract

This specification describes an RDBMS optional module for Active Tags. This RDBMS module provides tags, attributes, functions, properties, and data types related to applications that have to access to relational database management systems with SQL.

Requirement levels

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Note that for reasons of style, these words are not capitalized in this document.

Active Tags specifications

The following specifications are part of the Active Tags technologies.

Table of contents

1 The RDBMS module

1.1 Performing SQL queries
1.2 Producing straightly the expected XML structure
2 RDBMS module reference
2.1 Elements
2.2 Foreign attributes
2.3 Predefined properties
2.4 Extended XPath functions
2.5 Data types

Appendix

A Glossary
B Related Active Tags specifications
C Lists

C.1 Examples list
C.2 Figures list
D Active Schema for the RDBMS module


1 The RDBMS module

This Active Tags module has been designed to provide basic RDBMS support.

1.1 Performing SQL queries

This module is somewhat very simple to use :

SQL queries accept prepared SQL statements, which parameters are set with entries found in the context after performing the subactions.

Performing a SELECT query

This example perform a connection to a MySQL RDBMS through JDBC with a driver which is a Java class.

    <rdbms:connect driver="com.mysql.jdbc.Driver" name="sql" password="{ $sys:env/password }"
url="jdbc:mysql://localhost:3306/employees" user="{ $sys:env/user }"/> <rdbms:select connection="{ $sql }" name="result-set" query="SELECT EMPLOYEES WHERE ID = ?"> <xcl:param value="{ $employee-id }"/> </rdbms:select>
Performing an UPDATE query
    <rdbms:update connection="{ $sql }" name="result-count"
query="UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?"> <xcl:param value="{ $employee-salary }"/> <xcl:param value="{ $employee-id }"/> </rdbms:update>
[TODO: An example with Active Update for rows that have been modified.]

1.2 Producing straightly the expected XML structure

Unlike any proprietary technique of database vendors, Active Tags allows to produce directly any XML structure without the help of XSLT. Active Tags offers very flexible means for designing arbitrary complex XML structures. Active Tags allows actually :

SQL to XML

In this example, an SQL result is browsed in order to build an XML document.

    <rdbms:connect driver="..." name="sql" password="..." url="..." user="..."/>
    <rdbms:select connection="{ $sql }" name="orders" query="SELECT * FROM orders WHERE id= ? ">
        <xcl:param value="{ $sys:env/order-id }"/>
    </rdbms:select>
    <xcl:document name="xml">
        <order id="{ $sys:env/order-id }">
            <xcl:for-each name="group" select="{ xcl:group( $orders, currency ) }">
                <xcl:element name="{ currency }">
                    <xcl:for-each select="{ $group }">
                        <item part-number="{ pn }" quantity="{ qty }">
                            { price }
                            <xcl:text>{ string( product ) }</xcl:text>
                        </item>
                    </xcl:for-each>
                </xcl:element>
            </xcl:for-each>
        </order>
    </xcl:document>

The snippet code above produces the $xml property, which content might be the following XML document (xml:document) :

<order id="1234">
    <dollar>
        <item part-number="321" price="138.95" quantity="1">Lawnmower</item>
        <item part-number="654" price="29.99" quantity="2">Baby Monitor</item>
    </dollar>
    <euro>
        <item part-number="987" price="11.27" quantity="3">Roquefort Cheese</item>
    </euro>
</order>

(notice that for readability, whitespaces has been stripped and replaced by a smart indentation)


2 RDBMS module reference

RDBMS namespace URI : http://www.inria.fr/xml/active-tags/rdbms
Usual prefix : rdbms
Elements Foreign attributes Predefined properties Data types
<rdbms:connect>
<rdbms:disconnect>
<rdbms:select>
<rdbms:update>
<rdbms:commit>
<rdbms:rollback>
@rdbms:version
$rdbms:null
rdbms:connection
rdbms:x-row

Must be an adt:expression that computes an object of the type expected.
Must be a hard-coded value (litteral)
Can be either a hard-coded value or an adt:expression
This material may be missing
Denotes a value to use by default
Allows a read operation.
Allows a write operation.
Allows a rename operation.
Allows an update operation.
Allows a delete operation.

2.1 Elements

<rdbms:connect>

Create a connection to a database.

The connection created, a rdbms:connection, is set to a property.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
bothnameoptionalxs:QName

The name of the connection.

hard-codedscopeoptional The scope of the property to create.
xs:stringlocaldefault valueLocal.
globalGlobal.
sharedShared.
hard-codeddriverxs:string

The driver to use. Implementation dependant.

runtimeurlxs:string

The URL to connect to. Depends on the driver.

bothuserxs:string

The user with which making the connection.

bothpasswordxs:string

The password of the user with which making the connection.

[TODO: content definition]

<rdbms:disconnect>

Disconnect from a connection.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
runtimeconnectionrdbms:connection

The connection to disconnect.

[TODO: content definition]

<rdbms:select>

Perform a single SQL query. The result of the query is set to a property.

runtime phase

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
bothnameoptionalxs:QName

The name of the result set property.

hard-codedscopeoptional The scope of the property to create.
xs:stringlocaldefault valueLocal.
globalGlobal.
sharedShared.
runtimeconnectionrdbms:connection

The connection to submit the query.

hard-codedqueryxs:string

The query to submit.

[TODO: content definition]

<rdbms:update>

Perform a single SQL update query. The numbers of record affected by the query is set to a property.

runtime phase

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
bothnameoptionalxs:QName

The name of the property that hold the number of rows affected by the query.

hard-codedscopeoptional The scope of the property to create.
xs:stringlocaldefault valueLocal.
globalGlobal.
sharedShared.
runtimeconnectionrdbms:connection

The connection to submit the query.

hard-codedqueryxs:string

The query to submit.

[TODO: content definition]

<rdbms:commit>

Commit pending SQL updates.
Attributes runtime | hard-coded | both
NameTypeValue optional | default value
runtimeconnectionrdbms:connection

The connection to commit.

[TODO: content definition]

<rdbms:rollback>

Rollback pending SQL updates.
Attributes runtime | hard-coded | both
NameTypeValue optional | default value
runtimeconnectionrdbms:connection

The connection to rollback.

[TODO: content definition]

2.2 Foreign attributes

@rdbms:version

The version of the RDBMS module to use. This attribute should be encountered before any RDBMS element, but it takes precedence on the element inside which it is hosted.

2.3 Predefined properties

$rdbms:null

$rdbms refers to null values in the database.

2.4 Extended XPath functions

No XPath functions are defined by this module.

2.5 Data types

rdbms:connection type

Represents a connection to the data base.


rdbms:x-row type

Represents a row of a result set of a query.

Operation read | write | rename | update | delete
TypeValueComment
type()
xs:QNamerdbms:x-rowThis type
child::
readadt:list Each item has a name and a value of the type supplied by the underlying implementation.

Appendix

A Glossary

B Related Active Tags specifications

This list is not exhaustive; it is a list of common modules usable by an engine that implements the Active Tags specifications that implementors may use. Additional modules are welcome.

C Lists

C.1 Examples list

C.2 Figures list