gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 08:46:33 24 4
gpt4 key购买 nike

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

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

文档(@href)

应该使用“计算第一个参数的字符串的节点的基本 URI”的基数调用我的 URIResolver.resolve(fname,base)

文档(@href,.)

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

但是在 Xalan/J 的实践中

文档(@href)

为空

文档(@href,.)

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

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

最佳答案

请注意这一点

document(@href)

等于这个

document(string(@href),@href)

也许也可以

document(string(@href),.)

来自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.

然后

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

但是这个:

document(string(@href))

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

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.

然后

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.

关于问题

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

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

关于java - 如何使用可解析的基本引用调用 xpath document(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4199407/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com