4

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 Answers 2

6

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.

1
  • This perfect. Thank you. Nov 12, 2020 at 16:44
2

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.

1
  • Thanks for the additional info, @arkadianriver. This really helped me Sep 5 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.