xml_create_tables_from_mapping_schema_decl takes a file containing mapping schema and returns a vector containing strings. Each string is a command to drop a table or a foreign key or to create table. All tables and fields are mentioned in the mapping schema. If a field type is not defined in the mapping schema, the VARCHAR type is used.
A vector containg strings
Let we have the following mapping schema in the catmp.xsd file
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship name="CategoryProduct"
parent="Demo.demo.Categories"
parent-key="CategoryID"
child="Demo.demo.Products"
child-key="CategoryID" />
</xsd:appinfo>
</xsd:annotation>
<xsd:element name="category" sql:relation="Demo.demo.Categories" type="CategoryType" />
<xsd:complexType name="CategoryType" >
<xsd:sequence>
<xsd:element name="product"
sql:relation="Demo.demo.Products"
sql:relationship="CategoryProduct" >
<xsd:complexType>
<xsd:attribute name="ProductName" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="CategoryID" type="xsd:integer" />
<xsd:attribute name="description" sql:field="Description" type="xsd:string" />
</xsd:complexType>
</xsd:schema>
the _result vector after the call
_result := xml_create_tables_from_mapping_schema_decl ( 'http://localhost.localdomain/xmlrepository', 'catmp.xsd', 'UTF-8', 'x-any');
will contain the following six strings
drop table "Demo"."demo"."Categories",
ALTER TABLE "Demo"."demo"."Products" DROP CONSTRAINT "Demo.demo.Products_Demo.demo.Categories_FK",
drop table "Demo"."demo"."Products",
create table "Demo"."demo"."Categories"
("Description" VARCHAR, "CategoryID" INTEGER, PRIMARY KEY ("CategoryID")),
create table "Demo"."demo"."Products" ("CategoryID" INTEGER, "ProductName" VARCHAR),
ALTER TABLE "Demo"."demo"."Products" ADD CONSTRAINT "Demo.demo.Products_Demo.demo.Categories_FK"
FOREIGN KEY ("CategoryID") REFERENCES "Demo"."demo"."Categories" ("CategoryID")