klokop
klokop

Reputation: 2410

How do I tell xmllint to ignore 'entity' errors

I'm using xmllint as part of the linter settings in ALE (Asynchronous Lint Engine, plugin for Vim). The codebase I'm working on has a lot of HTML entities in XML. Not good, I know, but they're not harming anyone at the moment. So I'd like xmllint to not remind me everytime I open or save a file.

This is what xmllint says:

page.xml:54: parser error : Entity 'nbsp' not defined
    <Element label="&nbsp;" value="{__t.Delete}" action="{#delete}"/>
                          ^

Is there any way of telling xmllint (directly, or via ALE) to not give me entity errors?

Upvotes: -1

Views: 89

Answers (1)

LMC
LMC

Reputation: 12662

As a workaround, the --recover option could be added. The document will be parsed provided that no other errors appear but missing entities will be removed.

Given

<root>
  <Data>
    <colA>def&nbsp;</colA>
  </Data>
</root>

Result from xmllint --recover tmp2.xml

tmp2.xml:5: parser error : Entity 'nbsp' not defined
    <colA>def&nbsp;</colA>
                   ^
<?xml version="1.0"?>
<root>
  <Data>
    <colA>def</colA>
  </Data>
</root>

WARNING: entities will be lost if document is saved

Upvotes: 0

Related Questions