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

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

Merged
merged 1 commit into from
Sep 16, 2016

Conversation

lambdafu
Copy link
Contributor

This is worth a 🤦 ...

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
Copy link
Contributor Author

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
Copy link
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
Labels
None yet
Projects
None yet
2 participants