ropensci/xslt

R studio crashes when there is a syntax error in xsl file

Closed this issue · 5 comments

Hello!
Thank you for this package. It is very useful but I find it difficult to work with as it causes R studio to crash.

Steps to reproduce:

  1. have a file with XML data to be transformed as a valid XML document
  2. have a file with an XSL stylesheet as a valid XML document but with errors in XSL calls. Some examples:
  • <xsl:call-template name='{$name}'/> (invalid QName)
  • xsl:if</xsl:if> (test attribute missing)
  1. Apply transformation to the data with xslt::xml_xslt(data file,xslt file).

The relevant error message will be displayed (like those provided in brackets in examples) but a few seconds later the R studio will crash.
image

PS If the XSL file is an invalid XML then when opening the file with xml2::read_xml(filename):

  • the error message will be displayed
  • the xml2 package will lock the file (the file can't be modified anymore)
  • xml2 call seems to keep running in the background despite aborting the process
  • ultimately after a few minutes/more calls like this the R studio will crash as well unless you manually reset the R session before.

R Studio version: 4.1.0
xml2 version: 1.3.3
xslt version: 1.4.3
(all installed packages are updated to the most recent version)

Sys.info():

  • sysname: "Windows"
  • release: "10 x64"
  • version: "build 19044"
  • machine: "x86-64"

Can you please attach an example of an xml/xsl file and the R code that I can use to reproduce the crash?

Example files are attached.
While preparing the example I realized that the problem exists if the xsl:output method is set to 'text'. Without this declaration, the call behaves properly...
test.zip

Thanks, I can reproduce the crash on Windows (not on macos, strangely). I'll look into it.

Thanks this is fixed now. You now get a proper R error if there is a problem with the xslt, instead of a crash.

You can download the new version from: https://ropensci.r-universe.dev/xslt

Thank you for the super-fast response and the fix! It's working even better now :-)
I need to reach out to xml2 team to fix a similar issue with their package