是否可以在 XInclude 标签中使用通配符?
恐怕这是不可能的,但也没有发现任何地方说不可能。
我想使用通配符在 XML 文档中包含一组文件。像这样:
<?xml version="1.0" encoding="utf-8"?>
<mydocument>
<!-- ... -->
<xi:include href="*include.xml"/>
</mydocument>
我知道这不起作用,但我认为它清楚地表达了我的意图。有办法实现这一点吗?
编辑:
我尝试使用xpointer
属性,但无法使其工作。
I'm afraid it's not possible, but haven't found anywhere it is said to be impossible either.
I'd like to include a set of files within a XML document using wildcards. Like this:
<?xml version="1.0" encoding="utf-8"?>
<mydocument>
<!-- ... -->
<xi:include href="*include.xml"/>
</mydocument>
I know it doesn't work, but I think it clearly expresses my intentions. Is there a way to achieve this?
Edit:
I tried to use xpointer
attribute, but couldn't make it work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不。
href
表示 URI,这些没有通配符的概念。否则,可以通过诸如
href="http://www.google.com/*"
之类的内容来镜像 Google 主页。提示:文件系统也没有任何通配符的概念。 贝壳可以。当他们解析路径并看到
*
时,他们会为您完成填写空白的繁重工作。底层文件系统永远看不到星号。No. The
href
denotes a URI, and these do not have a concept of wildcards.Otherwise it would be possible to mirror the Google homepage by saying something like
href="http://www.google.com/*"
.Hint: File systems do also not have any concept of wildcards. Shells do. They do the heavy lifting of filling in the blanks for you when they parse a path and see a
*
. The underlying file system never gets to see the asterisk.有一个快速选项
覆盖 XmlResolver 来创建通配符感知解析器:
需要做很多事情来注意通配符是否适用此外
,BaseURI 可能很棘手,因为假设源 XML 来自
file://c:/ myXMLRepository/myXML.xml
包含 *inc.xml
现在基本 URI 是 file//c:/temp/tmpA0.tmp
。
。
祝你好运,
编辑:
还有另一种方法可以覆盖
,但还会带来其他问题...因为绝对 URI 并不总是有效,并且 XInclusionReader 会尝试并验证它。
There is a quick option
Override XmlResolver to create a Wildcard Aware Resolver:
There is a lot to do to notice if Wildcards are applicable at all
Additionally, the BaseURI can be tricky because lets say the Source XML is from
file://c:/myXMLRepository/myXML.xml
includes *inc.xml
now the base URI is file//c:/temp/tmpA0.tmp
.
.
wish you best of luck,
EDIT:
Theres another way to override
but there are other problem imposed by that... because the Absolute URI will not always be valid, and the XIncludingReader try and verify it.
@Tomalek 绝对就在这里。有多种方法可以完成您想要做的事情,但 XInclude 不是正确的答案。您将需要某种可以为您处理通配符扩展的工具。
您几乎可以肯定可以使用 Norm Walsh 的 XProc 实现 - calabash 之类的东西来做到这一点,但您需要推出自己的等效工具以某种方式包含。
@Tomalek is absolutely right here. There are ways to do what you trying to do but XInclude is not the right answer. You are going to need some sort of tool that can handle wildcard expansion for you.
You can almost certainly do this with something like Norm Walsh's XProc implementation - calabash but you would need to roll your own equivalent to XInclude in some way.