ropensci / xslt

Extension of xml2 package for xsl transformations
https://docs.ropensci.org/xslt
27 stars 1 forks source link

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

Closed jmendys closed 1 year ago

jmendys commented 1 year ago

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:
    • (invalid QName)
    • (test attribute missing)
  3. 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):

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():

jeroen commented 1 year ago

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

jmendys commented 1 year ago

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

jeroen commented 1 year ago

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

jeroen commented 1 year ago

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

jmendys commented 1 year ago

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