XSLT Document()函数导致Saxon错误/属性字符串不能用作文件路径 [英] XSLT Document() Function results in Saxon Error/ Attribute-String cant be used as Filepath

查看:102
本文介绍了XSLT Document()函数导致Saxon错误/属性字符串不能用作文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本信息是我的元素具有ID

Basic Information is I have a Element with an ID

我想在document()函数中使用ID属性来提取-element的内容

I want to use the ID-Attribute within the document()-Function to extract the content of the -element

我在这里有两个问题:

1)我的撒克逊处理器无法解决任何问题!我在文档功能内提供的文件路径

1) my saxon Processor wont resolve any fixed! Filepath I provide within de Document Function

->结果:FODC0005文档被标记为不可用:文件路径

-->RESULT: FODC0005 Document has been marked not available: Filepath

问题:为什么?

到目前为止,这是我的代码:

This is my code so far:

<xsl:template match="pmentry"><xsl:apply-templates/></xsl:template>

<xsl:template match="refdm"><xsl:apply-templates/></xsl:template>

<xsl:element name="datamodule">

<xsl:element name="DMC">DMC-<xsl:value-of select="modelic"/>-<xsl:value-of select="sdc"/>-<xsl:value-of select="chapnum"/>-<xsl:value-of select="section"/><xsl:value-of select="subsect"/>-<xsl:value-of select="subject"/>-<xsl:value-of select="discode"/><xsl:value-of select="discodev"/>-<xsl:value-of select="incode"/><xsl:value-of select="incodev"/>-<xsl:value-of select="itemloc"/>
</xsl:element>

<xsl:element name="CSH">
<xsl:attribute name="ID">DMC-<xsl:value-of select="modelic"/>-<xsl:value-of select="sdc"/>-<xsl:value-of select="chapnum"/>-<xsl:value-of select="section"/><xsl:value-of select="subsect"/>-<xsl:value-of select="subject"/>-<xsl:value-of select="discode"/><xsl:value-of select="discodev"/>-<xsl:value-of select="incode"/><xsl:value-of select="incodev"/>-<xsl:value-of select="itemloc"/></xsl:attribute>

<xsl:value-of  select="document(concat('../XML/',@ID,'.xml'))/dmodule/idstatus/status/remarks"/>
</xsl:element>


</xsl:element>

</xsl:template>

2)我的第二个问题是,我不知道如何使用ID作为文件名

2) My second Problem is, I couldn't figure out how to use my ID as the Filename

如果有人给了小费或其他东西,我真的不知道该怎么做.

If anyone has a tip or something i'm really clueless how to do it.

预先感谢

3 document()-函数已用于测试Saxon从何处开始搜索文档

the 3 document()-Function have been for testing where Saxon starts searching the doc

所以我正在使用以下文件夹设置:

So I'm Working in the following Folder setup:

文件夹游乐场:XSLT和XML子文件夹

Folder Playground: Subfolder XSLT and XML

批处理文件与文件夹位于同一级别

The Batch File is on the same Level as the Folders

 java -jar XSLT/saxon9he.jar -s:FLARE_Publicationmodul.xml -o:XSLT/remark_list.xml  -xsl:XSLT/read_remarks_part1.xsl 

现在我的计划是生成此XML文件:

now my Plan is to generate this XML-File:

<?xml version="1.0" encoding="utf-8"?>
<list>
<datamodule>
<DMC>DMC-S1000DBIKExsd-AAA-01-00-0000-00A-001A-A</DMC>
<CSH ID="DMC-S1000DBIKExsd-AAA-01-00-0000-00A-001A-A"> Content of the Remarks Element</CSH>
</datamodule>

<datamodule>
<DMC>DMC-S1000DBIKExsd-AAA-D00-00-00-00AA-941A-D</DMC>
<CSH ID="DMC-S1000DBIKExsd-AAA-D00-00-00-00AA-941A-D"> Content of the Remarks Element</CSH>
</datamodule>

...

</list>

因此,concat路径应该看起来像这样:

So the concat path should simply look like this:

../XML/DMC-S1000DBIKExsd-AAA-D00-00-00-00AA-941A-D.xml

../XML/DMC-S1000DBIKExsd-AAA-D00-00-00-00AA-941A-D.xml

路径应该正确. Saxon在控制台中打印它们,但是@ID信息丢失,或者如果我提供了固定路径(如(../XML/1.xml)),他将检查Folder,但找不到文件.

The Path should be right. Saxon prints them in th console, but the @ID information is missing, or if i supply a fixed path like (../XML/1.xml) he checks the Folder but dosent find a file.

是否可能需要在Saxon9he中启用文档功能?

Is it possible I have to enable the document Function in Saxon9he?

还是有其他解决方案可以从其他文件中提取元素内容?

Or is there an other solution to extract Element Content from other Files?

感谢您的帮助

推荐答案

在两种情况下,文档(更确切地说是URI)被标记为不可用":

A document (more precisely, a URI) is "marked as unavailable" under two circumstances:

(1)您调用提供该URI的doc-available(),答案为假

(1) you call doc-available() supplying that URI, and the answer is false

(2),您调用提供该URI的doc()或document(),就会发生错误.

(2) you call doc() or document() supplying that URI, and an error occurs.

在情况(2)中,通常会在第一次尝试访问URI时看到原始失败,因此,除非您使用try/catch来抑制该错误,否则这种情况不太可能发生.您的样式表使用doc-available()吗?

In case (2), you will normally see the original failure on the first attempt to access the URI, so unless you have used try/catch to suppress the error, this is unlikely. Does your stylesheet use doc-available()?

您的实验似乎表明您尚未完全弄清如何解析相对URI. document()的规则是:

Your experiments seem to suggest that you haven't quite worked out how relative URIs get resolved. The rule for document() is:

  • 如果提供节点,例如document(@ID),则将@ID中的相对URI相对于找到该节点的元素的基本URI进行解析(即,通常,转换的原始文档)

  • If you supply a node, for example document(@ID) then the relative URI in @ID is resolved against the base URI of the element where the node was found (that is, typically, the URI of the source document of the transformation)

如果提供字符串,例如concat(@ID,'.xml'),则相对URI将根据样式表的基本URI进行解析.

If you supply a string, for example concat(@ID, '.xml'), then the relative URI is resolved against the base URI of the stylesheet.

例如,您可以通过输出base-uri(.)来检查源文档的基本URI.并且您可以使用static-base-uri()检查样式表的基本URI.有时会因为基本URI未知而出现问题.例如,如果转换的输入是作为DOM提供的,则会发生这种情况.

You can check the base URI of the source document by outputting base-uri(.), for example; and you can check the base URI of the stylesheet using static-base-uri(). Problems sometimes arise because the base URI isn't known; this can happen for example if the input to the transformation is supplied as a DOM.

我希望这可以帮助您前进.如果您仍然有问题,我们将需要知道

I hope this helps you to move forward. If you still have problems, we will need to know

(a)document()的参数是什么

(a) what the argument to document() was

(b)源文档和样式表的基本URI是什么

(b) what the base URI of the source document and stylesheet were

(c)您希望读取的文件的完整路径是什么

(c) what is the full path of the file you expect to be reading

这篇关于XSLT Document()函数导致Saxon错误/属性字符串不能用作文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆