Name

xml_auto_dtd — returns an XML DTD for the result of a SQL query with a FOR XML clause

Synopsis

varchar xml_auto_dtd ( in query varchar ,
in root_element varchar );

Description

This function returns an XML DTD for the results of a SQL query with a FOR XML clause. The returned DTD will apply to the output generated by xml_auto with the query in question after wrapping it into the specified root element.

Parameters

query

valid SQL query

root_element

name of root element to wrap result into

Return Types

varchar of the resultant DTD

Errors

If the query argument is not a valid SQL statement, i.e. SQL compiler signals an error message, the function resignals the error.

Examples

Example24.508.Simple Use

SQL> select xml_auto_dtd ('  select "category"."CategoryID", "CategoryName",
    "ProductName", "ProductID"
    from "Demo".."Categories" "category", "Demo".."Products" as "product"
    where "product"."CategoryID" = "category"."CategoryID" for xml auto element', 'root');
callret
VARCHAR
_______________________________________________________________________________

<!-- dtd for output of the following SQL statement:
  select "category"."CategoryID", "CategoryName",
                "ProductName", "ProductID"
        from "Demo".."Categories" "category",

                "Demo".."Products" as "product"
        where "product"."CategoryID" = "category"."CategoryID"
        for xml auto element
-->

<!ELEMENT root (#PCDATA | category)* >
<!ELEMENT category (#PCDATA | CategoryID | CategoryName | product)* >
<!ELEMENT product (#PCDATA | ProductName | ProductID)* >
<!ATTLIST category   >
<!ATTLIST product    >
<!ELEMENT CategoryID (#PCDATA)>
<!ATTRLIST CategoryID        >
<!ELEMENT CategoryName (#PCDATA)>
<!ATTRLIST CategoryName      >
<!ELEMENT ProductName (#PCDATA)>
<!ATTRLIST ProductName       >
<!ELEMENT ProductID (#PCDATA)>
<!ATTRLIST ProductID >

1 Rows. -- 4 msec.