Database Reference
In-Depth Information
Table 1. XML publishing functions of SQL/XML
XMLELEMENT Creates an XML element. The XMLELEMENT function has the element name
as first parameter, the attribute list, i.e. an XMLATTRIBUTES function call,
as an optional second parameter and the content as a list of optional further
parameters.
XMLATTRIBUTES Creates XML attributes. The XMLATTRIBUTES function has a list of
attributes as parameters, where the first part of each attribute is the column
name from where to read the attribute value and the second part is the attribute
name.
XMLFOREST
Creates a forest of XML. The XMLFOREST function has a list of its contents
as parameters, where the first part of each content is the content definition and
the second part is the label of the tag by which the content is surrounded.
XMLCONCAT
Combines a list of individual XML values to create a single value containing
an XML forest. The XMLCONCAT function has a list of its contents as
parameters and yields one result row per tuple to which it is applied.
XMLAGG
Combines a collection of rows, each containing a single XML value, to create
a single value containing an XML forest. The XMLAGG function has a call to
an XML publishing function as first parameter and an 'order by' clause that
defines the order of its content as optional second parameter. The XMLAGG
function call results in a single result row containing the whole forest.
Table 2. SQL/XML query and query result of our example
(1) SELECT
(2) XMLFOREST(
(3) XMLAGG(
(4) XMLELEMENT(NAME nation,
(5) XMLATTRIBUTES(
(6) n.N_NAME AS name),
(7) (SELECT XMLAGG(
(8) XMLELEMENT(
(9) NAME customer,
(10) c.C_NAME)
(11) ORDER BY c.C_NAME
(12) )FROM CUSTOMER c
(13) WHERE c.C_NATIONKEY =
(14) n.N_NATIONKEY)
(15) )ORDER BY n.N_NATIONKEY
(16) ) AS costumers
(17) )
(18) FROM NATION n
(19) WHERE n.N_NATIONKEY < 5
<costumers>
<nation name="Germany">
<customer>C#007</customer>
<customer>C#013</customer>
</nation>
<nation name="France">
<customer>C#042</customer>
</nation>
<nation name="USA"></nation>
<nation name="Spain">
<customer>C#023</customer>
<customer>C#101</customer>
</nation>
</costumers>
2.2 This Paper's Example
The XMLFOREST function call creates the customers element and the XMLAGG
function call nested inside aggregates the result of the query that is the parameter of
XMLAGG into an XML forest in the order given by the order by clause. The XMLE-
LEMENT and XMLATTRIBUTE function calls generate an XML element or an
XML attribute respectively with the given name and the specified content.
2.3 The Basic Idea
In order to generate compressed XML directly from an SQL/XML query and
the contents of a relational database, we extend the idea behind the compression
technique of XSDS [1] as follows. While XSDS removes those XML nodes, the
Search WWH ::




Custom Search