Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust range error for internal DTD declaration #225

Closed
angelozerr opened this issue Nov 14, 2018 · 8 comments
Closed

Adjust range error for internal DTD declaration #225

angelozerr opened this issue Nov 14, 2018 · 8 comments
Assignees
Labels
bug Something isn't working DTD validation
Milestone

Comments

@angelozerr
Copy link
Contributor

angelozerr commented Nov 14, 2018

When internal DTD declaration is done with bad syntax, error is not well adjusted:

image

To fix this issue we need that XMLDocument is able to parse DTD declaration (here <!Element).

UPDATE
Implemented Error Codes:

Refer here for more info on each code.

  • AttNameRequiredInAttDef,
  • AttTypeRequiredInAttDef,
  • AttlistDeclUnterminated,
  • ElementDeclUnterminated,
  • EntityDeclUnterminated,
  • ExternalIDorPublicIDRequired,
  • IDInvalidWithNamespaces,
  • IDREFInvalidWithNamespaces,
  • IDREFSInvalid,
  • LessthanInAttValue,
  • MSG_ATTRIBUTE_NOT_DECLARED,
  • MSG_ATTRIBUTE_VALUE_NOT_IN_LIST,
  • MSG_CONTENT_INCOMPLETE,
  • MSG_CONTENT_INVALID,
  • MSG_ELEMENT_NOT_DECLARED,
  • MSG_ELEMENT_TYPE_REQUIRED_IN_ATTLISTDECL,
  • MSG_ELEMENT_TYPE_REQUIRED_IN_ELEMENTDECL,
  • MSG_ELEMENT_WITH_ID_REQUIRED,
  • MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL,
  • MSG_FIXED_ATTVALUE_INVALID,
  • MSG_MARKUP_NOT_RECOGNIZED_IN_DTD,
  • MSG_NOTATION_NAME_REQUIRED_IN_NOTATIONDECL,
  • MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN,
  • MSG_REQUIRED_ATTRIBUTE_NOT_SPECIFIED,
  • MSG_SPACE_REQUIRED_AFTER_NOTATION_NAME_IN_NOTATIONDECL,
  • NotationDeclUnterminated,
  • OpenQuoteExpected,
  • OpenQuoteMissingInDecl,
  • QuoteRequiredInPublicID,
  • QuoteRequiredInSystemID
  • SpaceRequiredAfterSYSTEM,
@fbricon
Copy link
Contributor

fbricon commented Dec 5, 2018

@angelozerr what's the status on this one?

@angelozerr
Copy link
Contributor Author

angelozerr commented Dec 5, 2018

It starts working with malformed <!ELEMENT. I need to support malformed <!ATTRLIST and <!ENTITY too.

But I think I'll find more unsupported errors. My proposition is to support malformed <!ATTRLIST and <!ENTITY and close this issue for now. We will open a new one if we find another unsupported error.

@fbricon
Copy link
Contributor

fbricon commented Dec 5, 2018

Given this snippet:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Folks [
	<!ELEMENT Folks (Person*)>
	<!ELEMENT Person (Name,Email?)>
	<!ATTLIST Person Pin ID #REQUIRED>
	<!ATTLIST Person Friend IDREF #IMPLIED>
	<!ATTLIST Person Likes IDREFS #IMPLIED>
	<!ELEMENT Name (#PCDATA)>
	<!ELEMENT Email (#PCDATA)>
	]>
<Folks>
	<Person Pin="id1">
        <Name>Fred</Name>
        <Email>frfr</Email>
    </Person>
    <Person Pin="id2" Friend="" Likes="id1">
        <Name>Bob</Name>
    </Person>
</Folks>

The diagnostic on Likes has the wrong range:
screen shot 2018-12-05 at 2 32 18 pm

Attribute value "" of type IDREF must be an NCName when namespaces are enabled.

@fbricon
Copy link
Contributor

fbricon commented Dec 5, 2018

Same snippet, but with some random value in Friend:
screen shot 2018-12-05 at 2 34 19 pm

{
	"resource": "/Users/fbricon/Downloads/sample-resources/some.xml",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": "MSG_ELEMENT_WITH_ID_REQUIRED",
	"severity": 8,
	"message": "An element with the identifier \"vfg\" must appear in the document.",
	"source": "xml",
	"startLineNumber": 19,
	"startColumn": 9,
	"endLineNumber": 19,
	"endColumn": 9
}

@fbricon
Copy link
Contributor

fbricon commented Dec 5, 2018

Wrong attribute, underlines next attribute:
screen shot 2018-12-05 at 2 37 13 pm

{
	"resource": "/Users/fbricon/Downloads/sample-resources/some.xml",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": "MSG_ATTRIBUTE_NOT_DECLARED",
	"severity": 8,
	"message": "Attribute \"Frien\" must be declared for element type \"Person\".",
	"source": "xml",
	"startLineNumber": 16,
	"startColumn": 32,
	"endLineNumber": 16,
	"endColumn": 37
}

@fbricon
Copy link
Contributor

fbricon commented Dec 5, 2018

Unknown doctype node type:
screen shot 2018-12-05 at 2 39 44 pm

{
	"resource": "/Users/fbricon/Downloads/sample-resources/some.xml",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": "MSG_MARKUP_NOT_RECOGNIZED_IN_DTD",
	"severity": 8,
	"message": "The markup declarations contained or pointed to by the document type declaration must be well-formed.",
	"source": "xml",
	"startLineNumber": 3,
	"startColumn": 7,
	"endLineNumber": 3,
	"endColumn": 7
}

@NikolasKomonen
Copy link
Contributor

All above issues are addressed

NikolasKomonen added a commit to NikolasKomonen/lsp4xml that referenced this issue Jan 11, 2019
Fixes eclipse#225

Signed-off-by: Nikolas Komonen <nikolaskomonen@gmail.com>
NikolasKomonen added a commit to NikolasKomonen/lsp4xml that referenced this issue Jan 14, 2019
Fixes eclipse#225

Signed-off-by: Nikolas Komonen <nikolaskomonen@gmail.com>
NikolasKomonen added a commit to NikolasKomonen/lsp4xml that referenced this issue Jan 15, 2019
Fixes eclipse#225

Signed-off-by: Nikolas Komonen <nikolaskomonen@gmail.com>
NikolasKomonen added a commit to NikolasKomonen/lsp4xml that referenced this issue Jan 15, 2019
Fixes eclipse#225

Signed-off-by: Nikolas Komonen <nikolaskomonen@gmail.com>
NikolasKomonen added a commit to NikolasKomonen/lsp4xml that referenced this issue Jan 15, 2019
Fixes eclipse#225

Signed-off-by: Nikolas Komonen <nikolaskomonen@gmail.com>
@fbricon
Copy link
Contributor

fbricon commented Jan 17, 2019

wrong ranges for

  • MSG_ELEMENT_ALREADY_DECLARED (duplicate <!ELEMENT Email (#PCDATA)> )
  • wrong range for PEReferenceWithinMarkup, see:
<!DOCTYPE Folks [
  <!ENTITY % Folks "(%bar;)*">
]>

NikolasKomonen added a commit to NikolasKomonen/lsp4xml that referenced this issue Jan 18, 2019
Fixes eclipse#225

Signed-off-by: Nikolas Komonen <nikolaskomonen@gmail.com>
NikolasKomonen added a commit to NikolasKomonen/lsp4xml that referenced this issue Jan 21, 2019
Fixes eclipse#225

Signed-off-by: Nikolas Komonen <nikolaskomonen@gmail.com>
fbricon pushed a commit that referenced this issue Jan 21, 2019
Fixes #225

Signed-off-by: Nikolas Komonen <nikolaskomonen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working DTD validation
Projects
None yet
Development

No branches or pull requests

3 participants