xsltlibxslt

xsltproc gives warning: "failed to load external entity" and error "xsl:include : unable to load .." for xsl:include to HTTPS URL


I have a local stylesheet like the following, i.e. it has an xsl:include with a href attribute pointing to a https URL:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:include href="https://martin-honnen.github.io/xslt/foo-transform-module.xsl"/>

<xsl:template match="@* | node()">
    <xsl:copy>
        <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>

For me on three different systems xsltproc fails to process the local stylesheet (with e.g. xsltproc xslt-test1.xsl sample1.xml), giving me the a warning and an error:

warning: failed to load external entity "https://martin-honnen.github.io/xslt/foo-transform-module.xsl"
compilation error: file xslt-test1.xsl line 3 element include
xsl:include : unable to load https://martin-honnen.github.io/xslt/foo-transform-module.xsl

Other XSLT processors seem to be able to find and load the included stylesheet and output e.g.

<root>
  <transformed-foo>foo 1</transformed-foo>
  <bar>bar 1</bar>
</root>

for an input sample1.xml like

<root>
  <foo>foo 1</foo>
  <bar>bar 1</bar>
</root>

I have looked through the options of xsltproc but I only find an option --nonet to disallow loading external entities, I don't see any default that would explain why the HTTPS access fails.

Can anyone reproduce this problem or, if not, tell me which setting I need so that xsltproc loads the included XSLT module?


Solution

  • It appears, that according to https://gitlab.gnome.org/GNOME/libxml2/-/blob/master/README.md, there are various build options for libxml/libxslt whether to include modules, one of them being --with-http HTTP support (off) where I assume off indicates that the default setting is to not include HTTP support.

    I think that explains it, all the installations I tried (xsltproc package under various WSL Ubuntu Linux editions) have probably been built with that default setting and therefore without HTTP support.