Database Reference
In-Depth Information
we can use a construction kit that provides a schema template for each SQL/XML
function. The nested structure of the functions within the SQL/XML query determines
the nested structure of the schema elements.
Fig. 1 shows the XML schema generated for the SQL/XML query of Table 2.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="costumers">
<xsd:complexType>
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="nation">
<xsd:complexType>
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="customer" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string“ use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Fig. 1. Schema derived from the query of Table 2
For each call of the XMLELEMENT function, we generate an <xsd:element>-
element with the given name within the schema. If the XMLELEMENT function does
not define any element content, i.e., it defines an empty element, the <xsd:element>-
element has an empty <xsd:complexType>-element as single child node. If the con-
tent of the XMLELEMENT is the value of a database column, i.e., the content is a
text node, the <xsd:element>-element is empty and contains an attribute
type=”TYPE”, where TYPE is e.g. xsd:string or xsd:int, depending on the data type of
the given database column. Finally, if the XMLELEMENT function has a more com-
plex content CC as third parameter (e.g. other XML elements or attributes), the
<xsd:element>-element contains an <xsd:complexType>-element as child node that
itself contains data that follow an XML schema fragment that corresponds to CC.
For each parameter of an XMLATTRIBUTES function that itself is contained in
the second parameter of an XMLELEMENT function EL, we generate an
<xsd:attribute>-element with the given name and the attribute use=”required” and
embed it into the complexType that is the child node of the <xsd:element>-element
within the schema that corresponds to EL.
Similarly, for each call of the XMLFOREST function with parameters p1, …, pn,
we generate an <xsd:sequence>-element that contains an <xsd:element>-element with
the name label(pi) for each of the parameters pi, where label(p) represents the label
part of the parameter p of the XMLFOREST function.
For each call of the XMLCONCAT function, we generate an <xsd:sequence>-ele-
ment, the content of which corresponds to the content of the XMLCONCAT function.
For each call of the XMLAGG function, we generate an <xsd:sequence>-element
that has an attribute minOccurs=”0” and an attribute maxOccurs=”unbounded” and
that contains the content that corresponds to the content of the XMLAGG function.
Finally, for each embedded SQL/XML query that does not contain a call to an
XMLAGG function, we create an <xsd:sequence>-element that has attributes minOc-
curs=”0” and maxOccurs=”1”, as each SQL/XML query either returns an empty
Search WWH ::




Custom Search