How to use db directory in XMLDOM subset type

54 views Asked by At

As i define note.dtd file in note_dtd_path and point it as &note_dtd_path with SYSTEM identifier, i can get the results what i want

SQL>

define note_dtd_path = "/home/oracle21c/SQL/note.dtd";

declare
    doc dbms_xmldom.DOMDocument;
    dt dbms_xmldom.DOMDOCUMENTTYPE;
    n dbms_xmldom.DOMNode;
begin
    doc := dbms_xmldom.newDomDocument('<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "&note_dtd_path">
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body></body>
</note>
');

    dt := dbms_xmldom.getDoctype(doc);
    dbms_output.put_line ('docType name : ' || dbms_xmldom.getname(dt));
    n := dbms_xmldom.makeNode(dt);
    dbms_output.put_line('systemID : ' || dbms_xmldom.getsystemid(dt));
    dbms_xmldom.freeDocument(doc);
end;
/

docType name : note systemID : /home/oracle21c/SQL/note.dtd

PSM completed.



But, as i created directory in SQLPLUS tool and tried to point the file in right direction, it failed.

SQL> create or replace directory DIR288571 as "/home/oracle21c/SQL"; grant read, write on directory DIR288571 to tibero;

declare
    doc dbms_xmldom.DOMDocument;
    dt dbms_xmldom.DOMDOCUMENTTYPE;
    n dbms_xmldom.DOMNode;
begin
    doc := dbms_xmldom.newDomDocument('<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "$DIR288571/note.dtd">
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body></body>
</note>
');

    dt := dbms_xmldom.getDoctype(doc);
    dbms_output.put_line ('docType name : ' || dbms_xmldom.getname(dt));
    n := dbms_xmldom.makeNode(dt);
    dbms_output.put_line('systemID : ' || dbms_xmldom.getsystemid(dt));
    dbms_xmldom.freeDocument(doc);
end;
/

**declare * ERROR at line 1:your text ORA-31001: Invalid resource handle or path name "/$DIR288571/note.dtd"

ORA-06512: at "XDB.DBMS_XMLDOM", line 4703 ORA-06512: at "XDB.DBMS_XMLDOM", line 4721 ORA-06512: at line 16 **

** is there any good method that i can get same results like using define options on the top by using create directory option `**

0

There are 0 answers