如何使用 XSLT 处理远程 XML 文件 [英] How to process remote XML files with XSLT

查看:24
本文介绍了如何使用 XSLT 处理远程 XML 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理远程 XML(仅通过向 XSLT 处理器提供 URL)并且我无法让它获取"额外的 XML 资源.我在这里阅读了类似的问题,但似乎没有一个适用于此.

I'm processing remote XML (by just providing URL to XSLT processor) and I can't make it "fetch" additional XML resources. I read similar questions here, but none of them seem like applicable here.

这是正在处理的远程 XML 的摘录:

Here is excerpt of remote XML that is being processed:

...
<item>
    <position>1</position>
    <rec id="05a59ca2"/>
</item>
<item>
    <position>2</position>
    <rec id="48e7c3f1"/>
</item>
...

现在这些 id 属性可用于引用远程 XML 源 (http://some-server/id),其中存储了有关每条记录的其他详细信息,我希望能够为了方便和简单,使用相同的 XSLT 处理它们,而不使用其他工具.

Now these id attributes can be used to refer remote XML source (http://some-server/id) where additional details about each record is stored, and I would like to be able to process them with same XSLT without using other tools, for convenience and simplicity.

那么,我可以使用 XSLT 处理远程 XML 文件吗?

So, can I process remote XML files with XSLT?

推荐答案

你当然可以使用文档功能来做到这一点

You can most certainly do this using the document function

示例:

<xsl:variable name="url" select="concat('http://mysite.com/',$id)" />
<xsl:variable name="IDmeta" select="document($url)"/>

测试你能做的

<xsl:copy-of select="$IDmeta"/>

看看是什么格式

参考

http://www.w3schools.com/xsl/func_document.asp

这篇关于如何使用 XSLT 处理远程 XML 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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