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

Detect xslt transform errors #731

Merged

Conversation

Fitzsimmons
Copy link
Contributor

There's a scenario where you can end up with undetectable errors while transforming a document with XSLT. According to https://mail.gnome.org/archives/xslt/2004-March/msg00014.html , it's actually expected that the higher-level xsltApplyStylesheet function will fail to detect transformation errors. The reply suggests using the lower-level function call, but I think since we want to pick up the details of the error when it happens, we can piggyback on the fact that if the error string is populated, then an error must have occurred.

Justin Fitzsimmons added 5 commits July 19, 2012 16:30
Prior to this change, xml errors were leaking into stdout:
For example, for the new test from the previous commit, "xmlXPathCompiledEval: evaluation failed" was showing up amongst the test results. We're already detecting that something failed, and this message is not very detailed, so I'm suppressing it.
I had to mangle the test a little bit, because it looks like Java is capable of detecting the errors at instantiation, but libxslt detects them at first-use. So the block in the test needed to be expanded to cover both cases.

This commit also fixes a bug in the Java code where a ruby exception was being created but not thrown when the XSLT document creation failed.

In order to provide the user with actual useful feedback in Java, the NokogiriXsltErrorListener will need to be modified to record more than the last error message.
@Fitzsimmons
Copy link
Contributor Author

It looks like I was a bit hasty in declaring that the Java tests were green. I've since realized that the Java implementation does not support passing parameters into #transform and any stylesheet that relies on them will not be successfully instantiated in Java.

I added a happy-path test, reverted to the original unhappy-path test, and moved them both into the libxml-only block.

For what it's worth, the Java implementation will now fail with a Runtime error as soon as you try to use a stylesheet that relies on external params, instead of throwing a null pointer error the first time you try to use it.

@Fitzsimmons
Copy link
Contributor Author

Is there anything that needs to be done for this pull request to be accepted? It has been two weeks with no word...

@yokolet
Copy link
Member

yokolet commented Sep 1, 2012

Many thanks for looking at pure Java version as well.

@flavorjones e2acb32 looks good to me.

flavorjones added a commit that referenced this pull request Sep 4, 2012
@flavorjones flavorjones merged commit 0c6cf26 into sparklemotion:master Sep 4, 2012
@flavorjones
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants