Using Schemas | XML Data Type | Teradata Vantage - 17.10 - Using Schemas - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - XML Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1140-171K
Language
English (United States)

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;