How to process remote XML files with XSLT

2019-06-02 09:10发布

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.

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

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.

So, can I process remote XML files with XSLT?

标签: xslt
1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-06-02 09:33

You can most certainly do this using the document function

example:

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

to test you can do

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

to see what the format is

reference

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

查看更多
登录 后发表回答