File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes problem with DTD external reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "problem with DTD external reference" Watch "problem with DTD external reference" New topic
Author

problem with DTD external reference

nagarjuna borra
Ranch Hand

Joined: Jan 14, 2012
Posts: 41
hi,

i have an xml file:

<?xml version="1.0"?>
<!DOCTYPE dipr [
<!ELEMENT dip (#PCDATA)>
<!ATTLIST dip id ID #IMPLIED>
]>
<dipr>
<dip id="101">1010</dip>
</dipr>

and getElementById works well with internal dtd .

but when i use external reference, getElementById is returning null.

here is the xml file and dtd file:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE dipr SYSTEM "file.dtd">
<dipr>
<dip id="101">1010</dip>
<dipr>

<!ELEMENT dipr (dip)>
<!ELEMENT dip (#PCDATA)>
<!ATTLIST dip id ID #IMPLIED>

what should i do to make it work???
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You should arrange things so that the parser can find your external DTD.
nagarjuna borra
Ranch Hand

Joined: Jan 14, 2012
Posts: 41
Paul Clapham wrote:You should arrange things so that the parser can find your external DTD.


did you mean the external DTD ??

i put it in the same directory as that of the xml file and html file(with js).
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

nagarjuna borra wrote:
Paul Clapham wrote:You should arrange things so that the parser can find your external DTD.


did you mean the external DTD ??


Yes, that's correct, when I said "external DTD" I did indeed mean "external DTD".

i put it in the same directory as that of the xml file and html file(with js).


I don't know what HTML and Javascript have to do with this, but if it's in the same directory as the XML file you posted, then that's the right place for it. The parser will know that it's in the same directory. Now make sure that the parser knows what directory the XML file is in, or else that it has a URL pointing to the XML file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with DTD external reference