tschoonj / xmimsim

Monte Carlo simulation of energy-dispersive X-ray fluorescence spectrometers
Other
32 stars 11 forks source link

XML DTD not available #32

Closed AndreWaehlisch closed 6 years ago

AndreWaehlisch commented 6 years ago

I am trying to read an xmsi file with my XML library but this fails, because it cannot verify the DTD file (http://www.xmi.ugent.be/xml/xmimsim-1.0.dtd). I get a 403 Forbidden error when I try to access it in my browser.

tschoonj commented 6 years ago

Hi Andre,

Easiest solution is to tell the XML library not to perform DTD validation. Which library and language are you using for this?

AndreWaehlisch commented 6 years ago

I am using IDL. It seems even with validation disabled the implementation tries to download the DTD and fails. I noticed there is a local DTD in .../share/xmimsim/xmimsim-1.0.dtd. Maybe this could become the default one.

tschoonj commented 6 years ago

Ok thanks. IDL's XML parser indeed does not allow validation to be switched off. You could use something like this using the DTD file on the system.

nlines = FILE_LINES('test.xmsi')
sarr = STRARR(nlines)
OPENR, unit, 'test.xmsi', /GET_LUN
READF, unit, sarr
FREE_LUN, unit
str = STRJOIN(sarr, '\n')
str.replace('http://www.xmi.UGent.be/xml/','/usr/local/share/xmimsim/') ; or something similar depending on where the DTD file is on your system
xml = OBJ_NEW('IDLffXMLDOMDocument', string=str)

Disclaimer: I don't have IDL on my system anymore so I cannot test this... Second disclaimer: My IDL is rusty 😄

AndreWaehlisch commented 6 years ago

Yes, replacing the URL with the file name works fine now. Thank you.

tschoonj commented 6 years ago

You're welcome.

Let me know if you need anything else