Register XML schema using dbms_xmlschema in Oracle The requirement is to register XML schema from XSD files in Oracle 11gR2. I am using the following code:

DECLARE

BEGIN
  DBMS_XMLSCHEMA.registerSchema(
    SCHEMAURL =&gt; 'http://[...]/spin-catalog-to-bpm.xsd',
    SCHEMADOC =&gt; bfilename ('/home/joe','spin-catalog-to-bpm.xsd'),
    CSID =&gt; nls_charset_id('AL32UTF8'));
END;
/


The file spin-catalog-to-bpm.xsd is under /home/joe but when I try to register it, it gives me this error:

DECLARE
*
ERROR at line 1:
ORA-22285: non-existent directory or file for FILEOPEN operation
ORA-06512: at "SYS.DBMS_LOB", line 805
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 131
ORA-06512: at line 3
You firstly need to create and Oracle directory.

As a user with the relevant permissions:

CREATE OR REPLACE DIRECTORY HOMEJOE AS '/home/joe';


Grant permission to the user that needs to use DBMS_XMLSCHEMA.registerSchema:

GRANT READ, WRITE ON DIRECTORY HOMEJOE TO YOURUSER;


Then register the schema, using the newly created directory:

DECLARE
BEGIN
  DBMS_XMLSCHEMA.registerSchema(
    SCHEMAURL =&gt; 'http://[...]/spin-catalog-to-bpm.xsd',
    SCHEMADOC =&gt; bfilename ('HOMEJOE','spin-catalog-to-bpm.xsd'),
    CSID =&gt; nls_charset_id('AL32UTF8'));
END;
/