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 almost 12 years ago. Updated about 11 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>
Actions #1

Updated by Michael Kay about 11 years ago

  • Status changed from In Progress to Resolved

Resolving this for the moment by adding documentation of various workarounds. At some stage it might be better to extend the API to allow a base URI for the stylesheet to be specified directly.

Actions #2

Updated by O'Neil Delpratt about 11 years ago

  • Status changed from Resolved to Closed
  • Sprint/Milestone set to Release 1.1
  • % Done changed from 0 to 100
  • Fixed in version set to 1.1

Bug fixed for Saxon-CE version 1.1 release

Please register to edit this issue

Also available in: Atom PDF