Welcome to the homepage for DemiLink, an open-source software project hosted on SourceForge.

The code for this project is developed and maintained by an administrator, but is public domain and therefore free to be used by anyone for any purpose. You may download, install, run and/or modify this code in any way you like without restriction.

What is DemiLink?

DemiLink is a data abstraction layer. In this regard, its purpose is stand between users and sources of data, allowing information to be accessed without needing to know exactly how it is retrieved.

DemiLink is also a data manipulation framework. It's designed so that each query for data may in turn call other queries, allowing complex transformations to be achieved through a series of simpler, more generic ones.

Why use DemiLink?

Centralizing data access and manipulation becomes more beneficial as system scale and complexity increase, so DemiLink is designed to be easily extended when needs grow. New queries, query types and data sources can all be added without any modifications to the main processing code. In addition, a common interface is used for the input and output of all queries, allowing pre-existing requests to be chained to together when new needs arise.

The following examples show how the program's basic functionality might be used.

Example 1 (Abstraction)

Consider a company that uses a database to store names and prices of widgets, where the details for a particular item can be retrieved with the SQL statement "select name, price from widgets_table where id = $id".

The simplest way for a process to access this information would be to explicitly store this SQL in code and connect directly to the database for each price query, assigning the $id variable as appropriate for each widget. Other processes could be developed in the same fashion, though this could lead to maintenance headaches in the future since any change in the SQL would require each process to be updated individually.

Using DemiLink as a data abstraction layer can help alleviate this problem by centralizing the storage of data retrieval logic into a common service. This logic can then be made available to downstream processes by associating the static portion of the query with a unique name and allowing any dynamic inputs to be controlled with parameters.

In this example, a process might retrieve query results by calling DemiLink's main function with the name-value array "query=PriceQuery,id=1" as an argument string. DemiLink would then load the SQL associated with PriceQuery, replace the $id variable with the value 1, connect to a database referred to in the query's definition, execute the formulated SQL string and return the results.

Example 2 (Manipulation)

The default format for query results is an XML string. Many other output formats may be realized, however, by making use of DemiLink's data manipulation functions. One such function returns the output of an XSL transformation, with the source XML and XSL components generated by other DemiLink queries.

In the case of our widgets query, processes that prefer to have receive CSV-formatted results could request DemiLink to perform an XSL transformation on the output of PriceQuery, using a standard CSV-generating XSL document read from a file. From DemiLink's perspective this entails the execution of three queries, but with a single external request.


DemiLink's source code can be downloaded from its project page on SourceForge.

The program is written in PHP, so you will also need to install a PHP package if it is not already available on your system.

An additional module is included in the DemiLink source to act as a gateway for requests made via http. To use this functionality, you will need a PHP-compatible web server such as Apache.

Installation and configuration

To install DemiLink, simply unzip the contents of the distribution file into any directory on your system.

You will then need to create a file named "productMetadata.xml" in the /cfg directory that will tell the program where to look for information. An example is provided in the same directory, and can generally be used as a starter configuration after the following node have been updated:

After setting up the configuration, the only thing that needs to be present for the program to be of use is query definitions. Just what these contain will depend on individual needs, but a simple example of an SQL query is provided in the /examples directory.

Other requirements

DemiLink makes use of PHP's XSL extension, which is not enabled under PHP's default configuration. To enable it, simply add or uncomment the line "extension=php_xsl.dll" in your installation's php.ini file.

IF you wish to use the http gateway, it may be possible to configure your web server to allow requests to be expressed as virtual pages, i.e. in "http://MyServer:MyPort/DemiLink/My/Query/Path/MyQueryName?paramater1=value1¶meter2=value2" format. One way to do this with Apache is to set up a instance of the webserver with DemiLink's directory as the document root, then use an .htaccess file in the directory to instruct mod_rewrite to redirect requests. An example file with a sample rewrite rule demonstrating this is in included in the /examples directory.


To contact the project administrator, please use the links on the project page.

SourceForge.net Logo