question about XML and DTD

Hi,

Got stuck with this.

I have a xml file which contains entities like "pound", "hellip" since these are non standard entities, xmllint fails to validate the XML file.

So, I created a DTD file with the external entities in place, once the DTD is provided as internal DTD to the XML file, the validation is smooth.

How do I achieve the same result with the DTD as an external one ?

I wont be unable to use internal DTD as I can't change the source file.

Is there any way to pass DTD as argument to xmllint and make the validation smoother ?

I tried with the options of xmllint and other web links but still fighting.

Could you please throw upon some light on this ?

Thanks

Di you try xmllint --dtdattr <filename> to load external DTD files? For external DTD files to work they still have to declared inside your xml file:

<!DOCTYPE mydtd SYSTEM "mydtd.dtd">

Right? Are you not allowed to add this?

hi jim,

thanks for the reply

if the DTD is included in the source file
and with either of the xmllint commands

xmllint --noout --loaddtd file.xml

or

xmllint --noout --dtdattr file.xml

it works perfectly as expected

but in either of the case, source file needs to be modified which is not possible in my case

So, is there any other way to use the dtd in the command line ( as an external dtd ) and not to alter the source file

I must be missing something --dtdattr <external DTD resource file>
does not work? Kinda like telling xmllint to use what amounts to an externally defined schema?

No way you can create a temp file with the DTD inlined? You will know exactly what you added, so if it validates, the original was valid, too.

(Workaround zone here. More properly, if there is no way to persuade xmllint to read an external DTD then it's really time to find, or write, a tool which can do that.)

thanks for the reply era.

I had the approach you proposed already :slight_smile:

But the sad truth is I won't be able to create temp file as well.

Am just searching for a solution where I the source file would be untouched, no temp files created and if possible to pass the external dtd as an argument to xmllint.

thanks for the reply ! :slight_smile: