1 Reply Latest reply on Feb 20, 2014 11:58 AM by odie_63

    Validating XML against XSD when there are more than one XSD.




      I need to validate a XML against a set of XSDs.

      I'm aware that, when there is a single XSD to compare, it is possible to compare using xmlDoc.schemaValidate() with xmlDoc and xmlSchema .


      But in my case there are more than one XSDs against which i need to compare the XML.


      My main XSD has the statement as mentioned below.

      <xs:import namespace="http://www.w3.org/1999/xxxx" schemaLocation="xxxx.xsd"/>

      <xs:import namespace="http://www.w3.org/1999/02/yyyy" schemaLocation="yyyy.xsd"/>


      I'm not sure how to handle this situation.


      Please, help me out !!




        • 1. Re: Validating XML against XSD when there are more than one XSD.

          Hi Vicky,


          This situation is no different, you just have to validate against the main schema.

          But, in order to use XMLType's schemaValidate method, you have to register the schema in the database (via DBMS_XMLSCHEMA API).

          If the main schema contains imports then those referenced schemas have to be registered too.


          To sum up : register all 3 schemas in their order of dependency, then you'll be able to validate your XML against the main XSD.



            schemaURL       => <schema url goes here> e.g. 'xxxx.xsd'

          , schemaDoc       => <schema content goes here>

          , local           => true

          , genTypes        => false

          , genTables       => false

          , enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE

          ) ;