Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Error: Unexpected close tag Line: 3 Column: 6 Char: > #48

Closed
jgrodskiy-donlen opened this issue Feb 16, 2016 · 19 comments
Closed

Error: Unexpected close tag Line: 3 Column: 6 Char: > #48

jgrodskiy-donlen opened this issue Feb 16, 2016 · 19 comments
Labels

Comments

@jgrodskiy-donlen
Copy link
Contributor

  1. Just attempted to use with test xml/xsd

test_xml.zip

Atom Version: 1.5.3
System: Microsoft Windows 8.1 Enterprise
Thrown From: linter-xmllint package, v1.3.2

Stack Trace

Uncaught Error: Unexpected close tag
Line: 3
Column: 6
Char: >

At events.js:141


Error: Unexpected close tag
Line: 3
Column: 6
Char: >
    at error (atom\packages\linter-xmllint\node_modules\sax\lib\sax.js:666:10)
    at strictFail (atom\packages\linter-xmllint\node_modules\sax\lib\sax.js:692:7)
    at closeTag (atom\packages\linter-xmllint\node_modules\sax\lib\sax.js:885:9)
    at Object.write (atom\packages\linter-xmllint\node_modules\sax\lib\sax.js:1444:13)
    at SAXStream.write atom\packages\linter-xmllint\node_modules\sax\lib\sax.js:238:18)
    at ReadableString.ondata (_stream_readable.js:525:20)
    at emitOne (events.js:77:13)
    at ReadableString.emit (events.js:169:7)
    at ReadableString.Readable.read (_stream_readable.js:360:10)
    at flow (_stream_readable.js:733:26)
    at resume_ (_stream_readable.js:713:3)
    at doNTCallback2 (node.js:441:9)
    at process._tickCallback (node.js:355:17)
@dirk-thomas
Copy link
Member

I have tried to open you xml file with the same version and I get one marker with:

Opening and ending tag mismatch: cat line 3 and zoo at line 4 column 7

That looks like the expected output to me. Since the xml file is not wellformed the linter should / does not even trigger the sax parser (

validateIfWellFormed = (messages) ->
if messages.length
return messages
return linter.checkValid textEditor
). So I am not sure how you got the stacktrace.

Can you please run the following commands on your command line and post the output:

xmllint --version
xmllint --noout test.xml

@jgrodskiy-donlen
Copy link
Contributor Author

So I get a crash the moment i start typing a tag and no validation.

xmllint: using libxml version 20903
   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib
D:\tmp\schema_crap>xmllint --noout test.xml
test.xml:4: parser error : Opening and ending tag mismatch: cat line 3 and zoo
</zoo>
      ^
test.xml:5: parser error : Premature end of data in tag zoo line 2

ezgif-1899626102

@dirk-thomas
Copy link
Member

Your xmllint reports correctly that the file is not well formed. After that I doesn't run sax (which would fail to parse the text as it does for you). I can't reproduce the problem - it behaves correctly without a stacktrace showing an error marker in the document with the message from xmllint.

I don't have any better idea then the following to troubleshoot:

  • can you post the content of ~/.atom/packages/linter-xmllint/lib/init.coffee (e.g. in a gist)
  • can you try to uninstall and reinstall linter-xmllint

@jgrodskiy-donlen
Copy link
Contributor Author

Here is the gist before I re-installed. https://gist.github.com/jgrodskiy-donlen/9c2c377557cec97dc68f

I re-installed the linter package and the linter-xmlint package. Issue still persists.

If you need some additional information, I can try doing some local investigation but no knowledge of coffeescript

@dirk-thomas
Copy link
Member

Yeah, since I can't reproduce it but it happens repeatably on your machine it would be great to try some debugging. My guess is that despite xmllint working correctly for you no messages are being extracted (which means no problem is detected) and then the sax parser is started and fails on the not wellformed input.

Please add the following debug statements (you can easily uninstall / reinstall the package afterwards):

  • before line 68 insert

    console.log 'content = "' + output + '"'

  • before line 71 insert

    console.log 'messages.length = ' + messages.length

Restart atom, edit your xml file as before and then open View -> Developer -> Toggle Developer Tools and look in the console tab and share the two printed line. Thanks.

@jgrodskiy-donlen
Copy link
Contributor Author

Here it is.

So the crash happens on the '<' itselfs. After just putting that in and saving and running xmllint directly
test.xml:3: parser error : StartTag: invalid element name

image

@dirk-thomas
Copy link
Member

But what is the message count? Please make sure you put the debug message in the right line and be aware that the line numbers change when inserting the other message.

@jgrodskiy-donlen
Copy link
Contributor Author

Sorry, forgot to follow up.
It crashes in parseMessages

I see it go in to the method but not into the regex forEach. Here is what I added below to to mine.

parseMessages: (output) ->
    console.log "Insided parseMessages"
    console.log arguments;
    XRegExp ?= require('xregexp').XRegExp
    messages = []
    regex = XRegExp(
      '^(?<file>.+):' +
      '(?<line>\\d+): ' +
      '(?<type>.+) : ' +
      '(?<message>.+)[\\r?\\n]' +
      '(?<source_line>.*)[\\r?\\n]' +
      '(?<marker>.*)\\^$', 'm')
    XRegExp.forEach output, regex, (match, i) ->
      console.log "Inside XRegExp forEach"
      line = parseInt(match.line) - 1
      column = match.marker.length
      console.log "Line = " + line
      console.log "column = " + column
      messages.push({
        type: 'Error'
        text: match.message
        filePath: match.file
        range: [[line, column], [line, column]]
      })
    return messages

image

@jgrodskiy-donlen
Copy link
Contributor Author

This is what the regex object is to me

/^(.+):(\d+): (.+) : (.+)\r?\n\r?\n^$/m

Which looks nothing like the constructor to me...

@jgrodskiy-donlen
Copy link
Contributor Author

Actually,
I think my message format is different from what you are expecting and it is not matching it. The one that comes from xmllint directly looks correct.

@dirk-thomas
Copy link
Member

Can you please try to remove the brackets around the newline matching part([\\r?\\n]). So the regex looks like this:

regex = XRegExp(
      '^(?<file>.+):' +
      '(?<line>\\d+): ' +
      '(?<type>.+) : ' +
      '(?<message>.+)\\r?\\n' +
      '(?<source_line>.*)\\r?\\n' +
      '(?<marker>.*)\\^$', 'm')

@jgrodskiy-donlen
Copy link
Contributor Author

And that did it :-).

Should it be validating against the schema also? Or just basic xml syntax.

@dirk-thomas
Copy link
Member

As long as the content is not well conformed it can only check for that. Simply because it requires valid xml to perform validation. Once it is well conformed xml it will also run the validation against the dtd / xsd/ relax / schematron.

I created #49 with the patch described.

@jgrodskiy-donlen
Copy link
Contributor Author

Alright so going back to the schema I sent above.

If you put tags It becomes a well-formed but not valid by the provided xsd standards. (You will have to change the location of the schema possibly to test locally).

@dirk-thomas
Copy link
Member

The fix is available in the new released version 1.3.3. Thanks for helping to debug this on Windows.

@dirk-thomas
Copy link
Member

Using a relative location for the schema (e.g. xsi:noNamespaceSchemaLocation="test.xsd") should work fine.

@jgrodskiy-donlen
Copy link
Contributor Author

Hate to do this to you but it's not working for me :(

I can open another bug for this if you want and point me to the general area to debug and I can get you more info.

image

@dirk-thomas
Copy link
Member

I get a marker behind the opening tag saying:

Element 'cat': This element is not expected. Expected is ( animal ). (test.xsd)at line 3 col 7

Have you installed the new version? Can you please try to add debug messages in the code to trace if the xsd validation is triggered, what the output is and then why no messages are matched?

Some pointers to relevant locations are:

@dirk-thomas
Copy link
Member

Follow up: #50.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants