XML namespaces in editor

I am having trouble with the XML editor in IntelliJ.

I have the following (DocBook):

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">

<book>
    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Book_Info.xml" />
    ...
</book>


The editor complains that "'include' must be declared".  So I tried moving the XInclude namespace declaration to the root element:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">

<book xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:include href="Book_Info.xml" />
    ...
</book>


At which point the editor then complains that it "Cannot find the declaration of element 'book'".

How can I get the editor to understand this?


P.S. Total XML noob here, so it is qute likely I am just not declaring stuff correctly in the XML document itself...

3 comments
Comment actions Permalink

Both variants are valid (you can define xi namespace on either book or include element), however, you will need to define the default namespace on the root element as well.

The following works (the default namespace URL is arbitrary, I told IDEA to "Ignore External Resource"):

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">

<book xmlns="http://www.oasis-open.org/docbook/xml/4.5/">
    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Book_Info.xml"/>
    ...
</book>


Please also note the double quotes in DOCTYPE declaration.

0
Comment actions Permalink

Curiously, it looks like it is the forum software that strips double quotes from DOCTYPE.

0
Comment actions Permalink

This works in IntelliJ at least.  Other tools are warning about the namespace:

Element type for '{http://www.oasis-open.org/docbook/xml/4.5/}book' not found [book]

I guess this is specifically an odd quirk of DocBook (pre-5) as far as I understand.  :(

0

Please sign in to leave a comment.