I am trying to port an MS SQL script to execute in PostGreSQL. It uses an XML schema collection script that is defined as follows:
CREATE XML SCHEMA COLLECTION [MySchema] AS N'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="MyRootElement">
<xsd:complexType> <xsd:complexContent> <xsd:restriction base="xsd:anyType"> <xsd:sequence> <xsd:element name="Child1" minOccurs="0"> <xsd:complexType> <xsd:complexContent> <xsd:restriction base="xsd:anyType"> <xsd:sequence>
.
.
Can I convert this XML schema type for use in PostGreSQL? So I can use the definition for stored procedure xml-type input parameter validation. If not, how do I ensure that the input parameter has the required schema?
I read that The xml type does not validate input values against a document type declaration (DTD), even when the input value specifies a DTD. There is also currently no built-in support for validating against other XML schema languages such as XML Schema
I would write a custom function (in PL/Perl or PL/Python perhaps) that does the required validation, and hook that to the column using a check constraint.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With