XML Error
Hello I am using Intellij IDEA 9.0.2 on 32-bit Linux to write a book using Docbook. I have a few inspection settings turned on for XML/XSLT.
This file causes an error:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5CR1/docbookx.dtd">
<preface id="Preface" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Preface</title>
<para>
TODO
</para>
</preface>
The error points to the preface root element and is "Cannot find the declaration of element preface." Why is this? It's declared right there.
Thanks for any advice.
请先登录再写评论。
Hi Tony,
You declared that root element belongs to the 'http://www.w3.org/2001/XInclude' namespace but didn't provide a way to validate its contents, that's the reason why IDEA complains about that.
Corresponding inspection responsible for that - 'File does not pass external validation'.
Feel free to disable it for that file or change xml content in order to be able to validate it.
Regards, Denis
Thanks Denis for your response. What exactly do you mean by "provide a way to validate its contents"?
Welcome.
I was talking about defining xsd specification within the *.xml and ask IDEA where to find it - Referencing DTD or Schema.
Thanks Denis. I have already tried "Fetch External Resource" and also mapping it locally. The error occurs after having done this. I expect it's because of the way docbook's DTD works.
Hi Tony,
Try to configure XML Schema instead of DTD for your document. Just checked that it's available for both DocBook 4.5 and 5.0:
Regards, Denis
To make it work, you need to download all *.mod files from
http://www.docbook.org/xml/4.5/
In fact, IDEA should do it for you when you choose "Fetch external resource"
fix. Please check it.