lemminx
lemminx copied to clipboard
Code Action for MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN?
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?
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 >
Hmm, OK, thanks. Sorry for the noise, I should have checked that.
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?
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.
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>