如何使用可解析的基本引用调用 xpath document()

发布于 2024-10-03 00:46:19 字数 443 浏览 0 评论 0原文

我有一个 xml 文件,其中包含另一个 xml 文件的名称:

在我的样式表中,我检测到 @href 并通过 document() 函数打开文档 document

(@href)

应该 使用“Base URI of the计算第一个参数的字符串的节点”

document(@href,.)

应该 使用“当前节点的基本 URI”的基础调用我的 URIResolver.resolve(fname,base)

然而,在实践中,Xalan/J

文档(@href)

是空白的

文档(@href,.)

给出了我的应用程序的当前目录

如何设置基数以便我的 URIResolver 可以找到该文件?

I have an xml file which contains the name of another xml file:

within my stylesheet, I detect @href and open the document via the document() function

document(@href)

should call my URIResolver.resolve(fname,base) with base of the "Base URI of the node from which the the string of the first argument is calculated"

document(@href,.)

should call my URIResolver.resolve(fname,base) with base of the "Base URI of the current node"

However in practice with Xalan/J

document(@href)

is blank

and

document(@href,.)

is giving current directory of my application

How do I set base so that my URIResolver can find the file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似狗非友 2024-10-10 00:46:19

请注意,这

document(@href)

与此相同

document(string(@href),@href)

,因此也可能与

document(string(@href),.)

From http://www.w3.org /TR/xslt#document

当文档函数恰好有
一个论点,并且该论点是
节点集,那么结果就是
union,对于参数中的每个节点
节点集,调用的结果
文档功能与第一个
参数是的字符串值
节点,第二个参数是
以该节点为唯一的节点集
会员。

进而

基本 URI(参见 [3.2 基本 URI])
第二个参数中的节点
文档中第一个节点集
order 用作基本 URI
将相对 URI 解析为
绝对URI

但这:

document(string(@href))

将使用样式表 URI 作为解析器。因为:

当第一个参数
文档函数不是节点集,
第一个参数被转换为
字符串就像调用字符串一样
功能。该字符串被视为
URI 参考。

进而

如果省略第二个参数,
那么它默认为中的节点
样式表包含
包含调用的表达式
文档功能。

关于问题

我如何设置基础以便我的
URIResolver 可以找到该文件吗?

答案:使用第二种形式和@xml:base

Do note that this

document(@href)

It's equal to this

document(string(@href),@href)

and so maybe also to

document(string(@href),.)

From http://www.w3.org/TR/xslt#document:

When the document function has exactly
one argument and the argument is a
node-set, then the result is the
union, for each node in the argument
node-set, of the result of calling the
document function with the first
argument being the string-value of the
node, and the second argument being a
node-set with the node as its only
member.

And then

The base URI (see [3.2 Base URI]) of
the node in the second argument
node-set that is first in document
order is used as the base URI for
resolving the relative URI into an
absolute URI

But this:

document(string(@href))

Will use the stylesheet URI as resolver. Because:

When the first argument to the
document function is not a node-set,
the first argument is converted to a
string as if by a call to the string
function. This string is treated as a
URI reference.

And then

If the second argument is omitted,
then it defaults to the node in the
stylesheet that contains the
expression that includes the call to
the document function.

About the question

How do I set base so that my
URIResolver can find the file?

Answer: use the second form and @xml:base

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文