首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >嵌套样式表的SaxonJS转换导致XError: URI解析失败

嵌套样式表的SaxonJS转换导致XError: URI解析失败
EN

Stack Overflow用户
提问于 2022-09-06 22:13:38
回答 1查看 95关注 0票数 0

我试图使用引用其他xsl样式表的样式表来转换XML。我使用命令行上的xslt3将主样式表编译成一个.sef.json文件,但是当我将.sef.json与.transform()一起使用时,我会得到一个失败的URI解析错误。

我把变换称为:

代码语言:javascript
复制
SaxonJS.transform({
            stylesheetInternal: splXslJS,
            sourceText: input,
            destination: 'serialized'
        }, "async")

fhirXslJS是从这个XSL编译的:

代码语言:javascript
复制
<?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>

导致错误的行是引用的SPL-Common.xsl中的<xsl:param name="indexingDocumentTypes" select="document('indexing-doc-types.xml')/*"/>

代码语言:javascript
复制
<?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>

(这个文件中有更多的内容,但不要认为这是必要的)

这就是我遇到的错误: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

其他可能相关的情况:

这是一个运行在火狐xslt3 -xsl:spl.xsl -export:spl.sef.json --t --nogo --ns:##html5

  • sourceText

  • Node模块“saxon”上的React应用程序:"^2.4.0",

  • 编译的spl.xsl是一个XML字符串,用户输入

  • ,我也尝试过用relocate:on和also编译,但是这不能工作H 218f 219

感谢你的帮助!

EN

回答 1

Stack Overflow用户

发布于 2022-09-07 15:26:04

这很有趣。当然,URI解析不应该失败。(您收到了关于r is not a constructor的奇怪消息,这无疑是一个SaxonJS错误:谢谢!)

当你尝试重新定位时,你说它“不起作用”,它是否以同样的方式失败了?

我个人不太熟悉如何将模块的Node.JS版本打包到浏览器中(这就是它要做的!?)如果您可以尝试加载浏览器版本的SaxonJS而不是Node.js包,这可能会说明情况。

我理解这将是一个很大的要求,但如果你能把它缩小到一个小的测试用例,我可以重现,这将使它更容易确定下来。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73628259

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档