Building up a library of server extensions helps to avoid the duplicate development of server extension functions and facilitates software reuse. The most systematic approach to the construction of such a library is to use a multi-level strategy.
On the server level
On this level, we define the server extension functions that are common to all databases on the server. These are functions that, for example, extend basic functionality or implement common corporate functionality.
Typically, these functions are grouped into packages that contain functions with related functionality. For example, we create one package for the support of XML Schema datatypes; we create another package to add more functionality to X-Query and XQuery 4; and we create another package for triggers.
In Tamino, server extensions are always installed into particular databases. Therefore, we install these common server level extensions into each database on the server.
We should use short names for these server extensions because on this
level most server extensions will extend the query functions and it is awkward
to type long name prefixes in queries. (See below for the possibility to rename
server extension functions.) In the section Queries we called the server
extension for the XML Schema datatypes xsd
and the corresponding
package tamino.SXS.xsd.
A typical example are the functions dtComp()
and
current()
in the package tamino.SXS.xsd
. These
functions are of general interest because they extend the functionality of
X-Query to the new date and time datatypes introduced with XML Schema.
Additional functions are shown in the section More examples.
On the database level
On the level of a single database, we define the server extension functions that are common to all collections within the database. Again, we should give relatively short names to the server extension and use the following naming pattern for the package names: tamino.SXS.{database}.{extension}.
On the collection level
Here we define the server extension functions that are common to all document types within a particular collection. We should aim to implement these extensions in a single package. We can then use the collection name as the name of the server extension. The package name should follow the pattern: tamino.SXS.{database}.{collection}
On the document type level
Server extensions on the document type level contain the server
extension functions that are specific to that particular document type. Again,
we should aim to implement these extensions in a single package. We use the
following naming pattern for the server extension:
{collection}_{doctype}
and name the package according to the following pattern: tamino.SXS.{database}.{collection}.{doctype} .
Tip:
Individual server extensions functions can be renamed with the help of
the Tamino Manager. If, for example,
xsd.dtComp
should be inconvenient for queries, we can assign a
different external name to this function, for example
compare-date
.