I am trying to transform XML using stylesheets that reference other xsl stylesheets. I compile the main stylesheet using xslt3 on the command line into a .sef.json file, but when I use that .sef.json with .transform(), I get a Failed URI resolution error.
I call transform as follows:
SaxonJS.transform({
stylesheetInternal: splXslJS,
sourceText: input,
destination: 'serialized'
}, "async")
fhirXslJS
is compiled from this XSL:
<?xml version="1.0" encoding="us-ascii"?>
<!--
The contents of this file are subject to the Health Level-7 Public
License Version 1.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the
License at http://www.hl7.org/HPL/hpl.txt.
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and
limitations under the License.
The Original Code is all this file.
The Initial Developer of the Original Code is Gunther Schadow.
Portions created by Initial Developer are Copyright (C) 2002-2004
Health Level Seven, Inc. All Rights Reserved.
Contributor(s): Steven Gitterman, Brian Keller
Revision: $Id: spl.xsl,v 1.52 2005/08/26 05:59:26 gschadow Exp $
Revision: $Id: spl-common.xsl,v 2.0 2006/08/18 04:11:00 sbsuggs Exp $
-->
<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:v3="urn:hl7-org:v3" exclude-result-prefixes="v3 xsl">
<xsl:import href="./spl-common.xsl"/>
<!-- Where to find JavaScript resources -->
<xsl:param name="resourcesdir">http://www.accessdata.fda.gov/spl/stylesheet/</xsl:param>
<!-- Whether to show the clickable XML, set to "/.." instead of "1" to turn off -->
<xsl:param name="show-subjects-xml" select="/.."/>
<!-- Whether to show the data elements in special tables etc., set to "/.." instead of "1" to turn off -->
<xsl:param name="show-data" select="1"/>
<!-- This is the CSS link put into the output -->
<xsl:param name="css">http://www.accessdata.fda.gov/spl/stylesheet/spl.css</xsl:param>
<!-- Whether to show section numbers, set to 1 to enable and "/.." to turn off-->
<xsl:param name="show-section-numbers" select="/.."/>
<!-- Whether to process mixins -->
<xsl:param name="process-mixins" select="true()"/>
<xsl:param name="core-base-url">http://www.accessdata.fda.gov/spl/core</xsl:param>
<xsl:output method="html" version="5.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
</xsl:transform>
The line causing the error is this <xsl:param name="indexingDocumentTypes" select="document('indexing-doc-types.xml')/*"/>
in referenced spl-common.xsl:
<?xml version="1.0" encoding="us-ascii"?>
<!--
The contents of this file are subject to the Health Level-7 Public
License Version 1.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the
License at http://www.hl7.org/HPL/hpl.txt.
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and
limitations under the License.
The Original Code is all this file.
The Initial Developer of the Original Code is Gunther Schadow.
Portions created by Initial Developer are Copyright (C) 2002-2013
Health Level Seven, Inc. All Rights Reserved.
Contributor(s): Steven Gitterman, Brian Keller, Brian Suggs
TODO: footnote styleCode Footnote, Endnote not yet obeyed
TODO: Implementation guide needs to define linkHtml styleCodes.
-->
<xsl:transform version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:v3="urn:hl7-org:v3"
xmlns:v="http://validator.pragmaticdata.com/result"
xmlns:str="http://exslt.org/strings"
xmlns:exsl="http://exslt.org/common"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exclude-result-prefixes="exsl msxsl v3 xsl xsi str v">
<xsl:import href="xml-verbatim.xsl"/>
<xsl:import href="mixin.xsl"/>
<xsl:import href="substance.xsl"/>
<xsl:import href="pesticide.xsl"/>
<xsl:param name="show-subjects-xml" select="1"/>
<xsl:param name="show-data" select="/.."/>
<xsl:param name="show-section-numbers" select="/.."/>
<xsl:param name="update-check-url-base" select="/.."/>
<xsl:param name="standardSections" select="document('plr-sections.xml')/*"/>
<xsl:param name="itemCodeSystems" select="document('item-code-systems.xml')/*"/>
<xsl:param name="disclaimers" select="document('disclaimers.xml')/*"/>
<xsl:param name="documentTypes" select="document('doc-types.xml')/*"/>
<xsl:param name="indexingDocumentTypes" select="document('indexing-doc-types.xml')/*"/>
<xsl:param name="root" select="/"/>
<xsl:param name="css" select="'./spl.css'"/>
<xsl:param name="process-mixins" select="/.."/>
<xsl:output method="html" version="5.0" encoding="UTF-8" indent="no" doctype-public="-"/>
<xsl:strip-space elements="*"/>
<!-- The indication secction variable contains the actual Indication Section node-->
<xsl:variable name="indicationSection" select="/v3:document/v3:component/v3:structuredBody/v3:component//v3:section [v3:code [descendant-or-self::* [(self::v3:code or self::v3:translation) and @codeSystem='2.16.840.1.113883.6.1' and @code='34067-9'] ] ]"/>
<xsl:variable name="indicationSectionCode">34067-9</xsl:variable>
<xsl:variable name="dosageAndAdministrationSectionCode">34068-7</xsl:variable>
<xsl:variable name="timeUnitsList">
<unitsMapping>
<unit UCUM="s" singular="second" plural="seconds"/>
<unit UCUM="min" singular="minute" plural="minutes"/>
<unit UCUM="h" singular="hour" plural="hours"/>
<unit UCUM="d" singular="day" plural="days"/>
<unit UCUM="wk" singular="week" plural="weeks"/>
<unit UCUM="mo" singular="month" plural="months"/>
<unit UCUM="a" singular="year" plural="years"/>
</unitsMapping>
</xsl:variable>
(much more in this file but don't think it's necessary)
This is the error I'm getting: XError:Failed URI resolution: href=./indexing-doc-types.xml base=file:///C:/Users/7J2197897/Desktop/FDA/SPL-FHIR-Demo/spl-fhir-demo/src/assets/HTML-View-Xform-SPL/spl-common.xsl -- TypeError: r is not a constructor; code:FODC0005
Other potentially relevant context:
- This is from a React app running on Firefox
- Node module "saxon-js": "^2.4.0",
- Compiled spl.xsl with
xslt3 -xsl:spl.xsl -export:spl.sef.json --t --nogo --ns:##html5
- sourceText is an XML string the user inputs
- I have also tried compiling with
relocate:on
and passing stylesheetBaseURI but that didn't work
Appreciate any help!