Answering myself here. This is the problem line:
result = stylesheet.apply(xml_doc, {:root => "ROOT", :back => "BACK"})
and this is the corrected line.
result = stylesheet.apply(xml_doc, {:root => "'ROOT'", :back => "'BACK'"})
Note that "ROOT" has become "'ROOT'". That is the word ROOT wrapped in 's and
then wrapped in "s