Project

Profile

Help

Bug #1582

closed

When using a DOM object for the XSLT stylesheet with the JavaScript API relative xsl:import/include URIs are not resolved properly

Added by Philip Fearon over 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Sprint/Milestone:
Start date:
2012-07-12
Due date:
% Done:

100%

Estimated time:
Platforms:

Description

If the XML DOM is instatiated independently of Saxon-CE, the processor will attempt to resolve xsl:import and xsl:include URI values using the Saxonce location as the base-URI.

The workaround (which may not be suitable if integrating with existing frameworks) is either to use absolute URIs in the xsl:import/include href attributes or to use the Saxon.requestXML method to get a reference to the initial XSLT stylesheet.

The following HTML/JavaScript will reproduce the issue:

<!DOCTYPE html>
<html>
  <head>
    <title>http</title>
    <script type="text/javascript" language="javascript" src="../Saxonce/Saxonce.nocache.js"></script>
    <script type="text/javascript" language="javascript">
      getXslDom = function(url) {
      if (typeof XMLHttpRequest == "undefined") {
      XMLHttpRequest = function () {
      return new ActiveXObject("Msxml2.XMLHTTP.6.0");
      };
      }
      var req = new XMLHttpRequest();
      req.open("GET", url, false);
      req.send(null);
      var status = req.status;
      if (status == 200 || status == 0) {
      return req.responseXML;
      } else {
      throw "HTTP request for " + url + " failed with status code: " + status;
      }
      };
      onSaxonLoad = function() {
      proc = Saxon.run( {
      stylesheet:   getXslDom('http.xsl'),
      source:       'http.xml',
      logLevel:     'SEVERE'
      } );
      }
    </script>
  </head>
  <body>
    <h1>http</h1>
    <p>Auto-generated HTML template for Saxon-CE</p>
    <div id="main"></div>
  </body>
</html>

With the XSLT:

<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
>
  <xsl:include href="httpimp.xsl"/>
  <xsl:template name="main" match="/">
    <xsl:result-document href="#main" method="append-content">
      <ul>
        <xsl:apply-templates select="*"/>
      </ul>
    </xsl:result-document>
  </xsl:template>

</xsl:transform>

Please register to edit this issue

Also available in: Atom PDF