Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Validating XML stored in CLOB without exceptions for malformed XML

978225Dec 20 2013 — edited Dec 29 2013

Hello,

I have a CLOB column that should contain an XML which conforms to a registered XSD schema. However, there might also be cases, in which the CLOB content violates the XSD or is not even wellformed XML at all.  Now I am trying to find a way to either

  • identify all records, for which the CLOB contains well-formed XML that validates against my schema (find all "good" records) , or
  • find all the other records (those with either no XML at all, malformed XML, or XML that does not validate against the XSD) (find all "exceptions")

The problem is that all XML-validation methods I know of (e.g. isXmlValid or XmlType.isSchemaValid)  require an XmlType instance, and that records, for which no proper XmlType can be constructed from the CLOB, because the CLOB does not contain well-formed XML, will cause an exception, rather than just returning false or NULL or something else I could filter out.

Is there a way to do something like

SELECT * FROM MYTABLE where <MY_XML_COL is wellformed XML> and <MY_XML_COL validates against 'blabla.xsd'>

without getting an ORA-31011 or whatever other kind of exception as soon as there is a row that does not contain proper XML?


Thank you...

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 26 2014
Added on Dec 20 2013
13 comments
8,030 views