--
connect &METADATAOWNER/&METADATAPASSWORD@&TNSALIAS
--
set echo on
--
-- Load a copy of the Image Metadata XML Schema that will be valid when opened from an external tools such as XMLSPY.
--
declare
  res boolean;

  targetDocumentPath varchar2(256) := :SCHEMA_LOCATION;
  targetDocument xmlType;
  http_port number(8);

begin

  targetDocument := xdbUriType(targetDocumentPath).getXML();
   
  HTTP_PORT := dbms_xdb.gethttpPort();
    
  select updateXML
         (
           targetDocument,
           '/xs:schema/xs:import[@namespace="http://xmlns.oracle.com/ord/meta/exif"]/@schemaLocation',
           'http://' || '&SERVER' || ':' || HTTP_PORT || '/sys/schemas/PUBLIC/xmlns.oracle.com/ord/meta/exif',
           'xmlns:xs="http://www.w3.org/2001/XMLSchema"'
         )
    into targetDocument
    from dual;

  dbms_xdb.deleteResource(targetDocumentPath);
  res := dbms_xdb.createResource(targetDocumentPath,targetDocument);
  dbms_xdb.changeOwner(targetDocumentPath,:METADATAOWNER,FALSE);
  commit;
end;
/
disconnect
--

