lemminx icon indicating copy to clipboard operation
lemminx copied to clipboard

Code Action for MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN?

Open oblitum opened this issue 5 years ago • 5 comments

See https://github.com/eclipse/lemminx/issues/781#issuecomment-644081346 for code action issue.

Here the original issue:

I'm configuring a font.conf file, which should follow fonts.dtd.

I'm getting this error coming from fonts.dtd (it's a system file not authored by me) when editing my fonts.conf file:

Error [xml MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN] A '(' character or an element type is required in the declaration of element type "reset-dirs".

The error points to this line in fonts.dtd:

<!--
    Reset the list of fonts directories
-->
<!ELEMENT reset-dirs >

I noticed that all other elements in the file are like <!ELEMENT remap-dir (#PCDATA)>, so indeed this reset-dirs doesn't have any paren, but is it really a syntax error?

oblitum avatar Jun 11 '20 19:06 oblitum

This error comes from Xerces and according to the BNF specification of element declaration https://www.w3.org/TR/2008/REC-xml-20081126/#NT-elementdecl you can see that content spec https://www.w3.org/TR/2008/REC-xml-20081126/#NT-contentspec is

  • 'EMPTY'
  • or 'ANY'
  • or Mixed , children which starts with '('.

I suppose the proper fix is

<!ELEMENT reset-dirs EMPTY >

angelozerr avatar Jun 15 '20 08:06 angelozerr

Hmm, OK, thanks. Sorry for the noise, I should have checked that.

oblitum avatar Jun 15 '20 11:06 oblitum

I think a code action (quickfix) which provides:

  • EMPTY
  • ANY
  • (#PCDATA)
  • (another existing element)

could help you to fix easily the problem.

@oblitum what do you think about that?

angelozerr avatar Jun 15 '20 11:06 angelozerr

Yeah, that would be nice to have when authoring a DTD, but in my case I'd simply dismiss the suggestion because I actually want to leave the system file unchanged. To really fix it I'd need to report the problem to whoever produces this file.

oblitum avatar Jun 15 '20 12:06 oblitum

FYI, late /etc/fonts/fonts.dtd on my system has been updated to what I suspect is correct (as you mentioned):

<!--
    Reset the list of fonts directories
-->
<!ELEMENT reset-dirs EMPTY>

oblitum avatar Jun 25 '20 19:06 oblitum