Fix xslt error parsing so filename and line numbers show. #206

Merged
merged 1 commit into from Sep 16, 2016

Conversation

Projects
None yet
2 participants
@lambdafu
Contributor

lambdafu commented Sep 15, 2016

This is worth a :facepalm: ...

Before:

<string>:0:0:ERROR:XSLT:ERR_OK: compilation error, element 'foo'
<string>:0:0:ERROR:XSLT:ERR_OK: xsltStylePreCompute: unknown xsl:foo
<string>:0:0:ERROR:XSLT:ERR_OK: compilation error, element 'foo'
<string>:0:0:ERROR:XSLT:ERR_OK: xsltParseStylesheetTop: unknown foo element

After:

errtest.xml:3:0:ERROR:XSLT:ERR_OK: compilation error, element 'foo'
<string>:0:0:ERROR:XSLT:ERR_OK: xsltStylePreCompute: unknown xsl:foo
errtest.xml:3:0:ERROR:XSLT:ERR_OK: compilation error, element 'foo'
<string>:0:0:ERROR:XSLT:ERR_OK: xsltParseStylesheetTop: unknown foo element

We can't do better, as the second line in the two errors embellishes the first line and does not duplicate the file/line info.

Example:

from io import BytesIO
from lxml import etree
style = etree.parse("errtest.xml")
try:
    etree.XSLT(style)
except etree.XSLTParseError as e:
    print e.error_log
@lambdafu

This comment has been minimized.

Show comment
Hide comment
@lambdafu

lambdafu Sep 15, 2016

Contributor

Oh, here is the xslt:

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:foo />
</xsl:stylesheet>

It's really the same from the test case that's already there (but which only checks for presence of ERROR:XSLT).

Contributor

lambdafu commented Sep 15, 2016

Oh, here is the xslt:

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:foo />
</xsl:stylesheet>

It's really the same from the test case that's already there (but which only checks for presence of ERROR:XSLT).

@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Sep 16, 2016

Member

Ah, beautiful. Thanks!

Member

scoder commented Sep 16, 2016

Ah, beautiful. Thanks!

@scoder scoder merged commit 9113dc1 into lxml:master Sep 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment