Using Schemas - Teradata Vantage NewSQL Engine - 16.20

Teradata Vantageā„¢ XML Data Type

prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1140-162K

The CREATESCHEMABASEDXML and ISSCHEMAVALID methods accept a schema as an argument. For XML schemas that are composed of a single schema document (the schema document does not include or import another schema document), you can pass the schema document as an XML type value to the method. For XML schemas that are made up of more than one document, you must pass the consolidated schema document as an XML type value to the method.

You can store the schema or consolidated schema document in a table and use it in a query that performs schema validation through a join as follows:

SELECT customerID, customerXML.ISSCHEMAVALID(schematab.schemacontent, 'Customer', '')
FROM customer, schematab
WHERE schematab.schemaid = 'customerschema.xsd';

If you want to perform multiple validations per row, you can use subqueries of the following form:

SELECT x.xmlcol1.isschemavalid(s1.schemacontent, '', ''),
   x.xmlcol2.isschemavalid(s2.schemacontent, '', '')
FROM xmldata x,
   (select st.schemacontent
    from schematab st
    where st.schemaid = 'myFirstSchema.xsd') s1,
   (select st.schemacontent
    from schematab st
    where st.schemaid = 'mySecondSchema.xsd') s2;