title: How to validate XML variable against XSD in PostGreSQL
body: <p>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:</p>
  
  <pre><code>CREATE XML SCHEMA COLLECTION [MySchema] AS N'&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"&gt; 
  &lt;xsd:element name="MyRootElement"&gt; 
  &lt;xsd:complexType&gt; &lt;xsd:complexContent&gt; &lt;xsd:restriction base="xsd:anyType"&gt; &lt;xsd:sequence&gt; &lt;xsd:element name="Child1" minOccurs="0"&gt; &lt;xsd:complexType&gt; &lt;xsd:complexContent&gt; &lt;xsd:restriction base="xsd:anyType"&gt; &lt;xsd:sequence&gt;
      .
      .
  </code></pre>
  
  <p>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?</p>
  
  <p>I read that <a href="http://www.postgresql.org/docs/9.0/static/datatype-xml.html" rel="noreferrer">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</a></p>