A computerized system and method for transforming (formatting or
aggregating) the results of a query into a hierarchical information
stream, such as an eXtensible Markup Language (XML) data stream is
disclosed. A database server receives a query and generates a rowset. A
rowset processor, using the mode specified in the query, processes the
rowset and query to generate the XML data stream. For the "auto1" mode,
the rowset processor transforms a rowset into an XML data stream using
primary-foreign key information specified in the query to determine
nesting. For the "auto2" mode, the rowset processor transforms a rowset
into an XML data stream using table ordering information included in the
query to determine nesting. For the "explicit" mode, the rowset processor
transforms a rowset into an XML data stream using the explicit
organizational information specified in the query. In one embodiment, it
is easier for a developer to compose expressions to generate nested
hierarchical structures than previous formulations and simpler semantics
are provided without implicit hierarchy inference. The syntax of an
embodiment of the hierarchical formatting function includes optional
arguments including a name option, a root option, map option, namespace
options and a null option.