I am trying to transform XML basing on XSLT in Ruby/Nokogiri.
doc = Nokogiri::XML(File.read('some_file.xml'))
xslt = Nokogiri::XSLT(File.read('some_transformer.xslt'))
puts xslt.transform(doc)
but it fails:
I/O warning : failed to load external entity “dateDifference.xsl”
RuntimeError: compilation error: element stylesheet
xsl:exclude-result-prefixes : undefined namespace exsl compilation
error: element import xsl:import : unable to load dateDifference.xsl
probably, it is caused by using of external entities on my some_transform.xslt file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:res="rate.fidelio.6.0" xmlns:inv="rtav.fidelio.4.0" xmlns:aravr="ravr.fidelio.2.0" xmlns:aravl="ravl.fidelio.2.0" xmlns:exslt="http://exslt.org/common" xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="res inv aravr aravl date exsl">
<xsl:import href="dateDifference.xsl" />
...
</xsl:stylesheet>
Is there any way to fix it?
The error is exactly as per the error message:
The XSLT processor complains that there is no
"exsl"namespace prefix declared, but it is listed in theexclude-result-prefixesattribute.Correct this in the following way:
For the second problem:
This message means that there is no file named
dateDifference.xslin the same directory where the current XSLT file resides (or that the file is there but it is syntactically invalid, or that permissions are required to access the file, … or, …)