Home » Developer & Programmer » JDeveloper, Java & XML » problem in XML validation using External DTD in Oracle 9i.
problem in XML validation using External DTD in Oracle 9i. [message #91930] Fri, 03 October 2003 13:08
Navin Prabhu
Messages: 2
Registered: October 2003
Junior Member
Hi,
I am having a problem using the xmltype dataype on a piece of code I am working on.

Gist of what I am trying to implement.

I will receive a DTD from a third party vendor. This third party vendor has an XML B2B Gateway. Any time my application wants to publish something to this B2B gateway it will create an XML document and insert it into an Oracle table that has an XMLType column. A Java process will read this table and publish the XML event on the B2B gateway.
Prior to inserting the XML event into the oracle table mentioned above, I am trying to use Oracles' internal functionality to validate the XML. However, if I use SYSTEM instead of PUBLIC in the DOCTYPE tag, oracle is unable to find the DTD for validation.

here is a sample script to recreate the problem.

PLEASE DO A VIEW SOURCE ON THIS PAGE IF YOU WANT TO SEE THE ACTUAL XML EVENTS AND THE DTD.
Create table xmltest
( UniqueID number,
xmlinfotxt SYS.xmltype );

insert into xmltest
( UniqueID,
XMLInfoTxt
)
values
(1,
XMLTYPE('<!DOCTYPE TESTEVENT SYSTEM " " "TESTEVENT.dtd" ><TESTEVENT><EVENTNAME>evTestDTD</EVENTNAME></TESTEVENT>')
)

The DTD is as follows :

<!ELEMENT TESTEVENT (EVENTNAME)>
<!ELEMENT EVENTNAME (#PCDATA)>

( Save the above two lines in a file names TESTEVENT.dtd. If you are using an UNIX filesystem or using a web server / app server on your windows machine then the names can be case sensitive )

SQL> Create table xmltest
( UniqueID number,
xmlinfotxt SYS.xmltype );
2 3
Table created.

SQL> insert into xmltest
( UniqueID,
XMLInfoTxt
)
values
(1,
XMLTYPE('<!DOCTYPE TESTEVENT SYSTEM " " "TESTEVENT.dtd" ><TESTEVENT><EVENTNAME)
)
2 3 4 5 6 7 8 9 ;
XMLTYPE('<!DOCTYPE TESTEVENT SYSTEM " " "TESTEVENT.dtd" ><TESTEVENT><EVENTNAME)
*
ERROR at line 7:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00247: invalid Document Type Declaration (DTD)
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 0
ORA-06512: at line 1

As you can see in the error above, the parser is not able to find the DTD.
I also tried to replace the TESTEVENT.dtd with the absolute filepath as follows :

insert into xmltest
( UniqueID,
XMLInfoTxt
)
values
(1,
XMLTYPE('<!DOCTYPE TESTEVENT SYSTEM " " "file:///tmp/TESTEVENT.dtd" ><TESTEVENT><EVENTNAME>evTestDTD</EVENTNAME></TESTEVENT>')
)

The above insert statement also gives the same error displayed above.

I was able to make this work by using PUBLIC domain instead of SYSTEM. As follows :

insert into xmltest
( UniqueID,
XMLInfoTxt
)
values
(1,
XMLTYPE('<!DOCTYPE TESTEVENT PUBLIC " " "http://localhost/TESTEVENT.dtd" ><TESTEVENT><EVENTNAME>evTestDTD</EVENTNAME></TESTEVENT>')
)

( I have TOMCAT running locally on my PC. I placed the dtd in the DOC ROOT. )

My specific questions are :

If I want to use SYSTEM for the DTD validation , is there a specific directory in Oracle where I should place the DTD so that oracle can pick up the DTD and validate it against the XML event I am trying to insert into the table.

Is there some global variable or environment variable to be set so that I can make Oracle look at a specific location for the DTD when it needs to validate the XML event being inserted into the xmltype column.

Any help or insight will be greatly appreciated.

Regards,
Navin
Previous Topic: xslt
Next Topic: how to give the db2 keyword NEXT VALUE, in the prepared statement
Goto Forum:
  


Current Time: Thu Mar 28 14:54:23 CDT 2024