validationnamespacesxml-namespacesxlinkdocbook-5

How to declare the xlink namespace to validate a Docbook 5 link?


Might I use xl:

<?xml version="1.0"?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0">
    ...
</article>

or do I have to use xlink:

<?xml version="1.0"?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
    ...
</article>

?


Solution

  • Xml validation and namespaces usually set the question in the context of XML Schema (XSD) specification, but the question may be answered in Document Type Definition (DTD) specification context.

    Validating against docbook.dtd

    If you validate against docbook.dtd you must use xmlns:xlink as answered here, but first carefully consider why you should have to use Document Type Declaration and namespaces because XML Schemas are the Successors of DTDs and while XSDs support namespaces DTDs don't support them.

    Validating against docbook.xsd

    If you validate against docbook.xsd you may use whatever you like, but the reserved three-letter sequence x, m, l, in any case combination. For example the following test.xml, straight taken from the DocBook V5.0 - The Transition Guide validates with success:

    $ ls
    docbook.xsd  test.xml  xlink.xsd  xml.xsd
    $ xmllint --schema docbook.xsd test.xml 
    <?xml version="1.0"?>
    <article xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0">
        <title>Test</title>
        <section>
            <title>LS command</title>
            <para xml:id="ls">
                This command is a synonym for <command linkend="dir">DIR</command> command.
            </para>
            <para xml:id="dir">
                This command is a synonym for <command linkend="ls">LS</command> command.
            </para>
            <para>
                <application xl:href="http://www.gnu.org/software/emacs/">Emacs</application>
            </para>
        </section>
    </article>
    test.xml validates
    $