Stag - Structured Tag Library

The Stag project currently consists of two perl modules, both of which are available from CPAN or sourceforge:


This perl module is for querying and manipulating complex data as recursively nested tag/value pairs (Structured tags or Simple Tree aggreggates). Procedural and object-oriented modes are supported. Tags can be accessed by autogenerated accessor methods.

XML is a hierarchical data format, so this module can be used as an XML parser/writer. Other hierarchical formats are supported, including lisp S-Expressions (i.e. SXML) and indented-text.

Construction of parsers, transformers and writers is simplified with structured tag events, similar to and compatible with SAX.

As well as being a useful module for perl developers, this module also comes with a number of useful scripts for manipulating stag data.

At this time there is only a perl implementation, Data::Stag, but C and Lisp implementations are planned.


This module is for conversion between relational representations and hierarchical tag-value pairs, i.e. Stag trees, or XML.

Querying: SQL query results are automatically decomposed into the relations used in the query, and a hierarchical structure is inferred. This allows you to go from multi-table joins to deeply nested hierarchical representations that capture the foreign key data in the database.

This modules also allows you to create SQL templates - a powerful way of reusing complex SQL statements.

Storage: Stag trees can be stored in a relational database with a minimum of metadata. There are also scripts to help with construction of ad-hoc normalised relational databases from XML sources.


Data::Stag and DBIx::DBStag Perl module documentation on CPAN
Script Docs Stag script documentation (these scripts come with the Stag and DBStag distributions)
UBIQ Query Interface A demo of DBStag for mapping query results to hierarchical tag-value data. This interface provides WWW access to a number of bioinformatics databases (Gene Ontology, Ensembl, Chado, BioSQL, GadFly). Templates can be selected, or you can feed in your own SQL.
Stag project page on Sourceforge Here you can find the Stag CVS repository, mail lists, etc
DBStag Tutorial Brief tutorial on basic DBStag usage for biological databases. (slightly out of date - some aspects of DBStag may have changed)
DBIx::DBStag::Cookbook DBStag cookbook - shows how to generate a normalised relational db from an XML source (the CIA world factbook), create your own SQL templates and build a WWW query interface
DBIx::DBStag::SQLTemplate The POD manpage describing SQL templates - a powerful way of reusing complex SQL statements
Stag Poster DBStag poster from Genome Informatics 2003 at Cold Spring Harbor Laboratory (large image)
Example Stag Templates Some example Stag SQL templates for the Gene Ontology Database Logo
chris mungall
Last modified: Tue Apr 20 17:14:18 PDT 2004