Skip to Main Content

SQL & PL/SQL

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!

Validate XML with XSD

EtbinOct 12 2010 — edited Oct 13 2010
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
with the partitioning, real application clusters, olap, data mining
and Real Application Testing options

Working with relational tables containing clob type columns (no XMLDB available) I'm not able to set up a simple validation example as below (supposed to return 1 confirming a successful validation).
declare 
  xmldoc xmltype;
  sb_xml xmltype;
  valid_ number;
  xmlxsd varchar2(4000) := q'~<?xml version="1.0" ?>
                              <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
                              <xs:element name="greeting" type="xs:string" />
                              </xs:schema>~';
  xmlxml varchar2(32767) := q'~<?xml version="1.0" ?><greeting>"HELLO !"</greeting>~';
begin 
  xmldoc := xmltype(xmlxml);
  sb_xml := xmldoc.createschemabasedxml();
  valid_ := sb_xml.isschemavalid(xmlxsd);
  dbms_output.put_line('IsSchemaValid (0=false,1=true): ' || to_char(valid_));
end;
Thanks in advance for any kind of help provided

Etbin
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 10 2010
Added on Oct 12 2010
4 comments
539 views