3

I am using VS Code and the "XML Language Support by Red Hat". I am pointing to the catalog file inside the DITA OT directory dita-ot-3.3.3\catalog-dita.xml. My DITA file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "http://docs.oasis-open.org/dita/v1.1/OS/dtd/task.dtd">
<task>
    <title>Running the converter</title>
    <steps>
        <step>
            <cmd>Run the following command:</cmd>
        </step>
    </steps>
</task>

But I get errors like:

Element type "task" must be declared.xml(MSG_ELEMENT_NOT_DECLARED)

So it's reading something, but it's not working correctly. Am I using the wrong catalog file? Is my document declaration wrong?

An aside: I have Oxygen XML Editor and I can use that if I need advanced functions. I am looking to use VS Code for occasional small edits while I'm coding without having to launch Oxygen.

2 Answers2

5

Edit settings.json to validate against DTD using catalog file as follows:

Editing setting.json

You must set "xml.catalogs","xml.javahome", "xml.validation.resolveExternalEntities" respectively.

Then you can get the succeeded validation result:

Validation result

By the way, your DITA file is originally not valid against DITA DTD.

Toshihiko Makita
  • 1,294
  • 1
  • 8
  • 15
1

Toshihiko san's answer is spot on, thanks for that! But I found that in 2023, with DITA 4.0.2 at least, I wasn't able to use Intellisense code completion in any topic type because of the following error on the root element:

The parser has encountered more than "64,000" entity expansions in this document; this is the limit imposed by the application.

enter image description here

To fix this, I needed to increase the entity expansion limit¹ as an added JVM option in the VS Code settings (just doubling 64000 seemed to do the trick):

"xml.server.vmargs": "-Djdk.xml.entityExpansionLimit=128000"

For completeness, here are all the entries I needed for the Red Hat XML VS Code extension to work with DITA (that I know of so far):

enter image description here


¹ Note as to why the 64,000 entity limit was imposed.