我有这些XML文件:
master.xml (which uses XInclude to include child1.xml and child2.xml)
child1.xml
child2.xml
child1.xml
和child2.xml
都包含带有一些文字的<section>
元素。
在XSLT转换中,我想添加<section>
元素来自的文件的名称,所以我得到类似的内容:
<section srcFile="child1.xml">Text from child 1.</section>
<section srcFile="child2.xml">Text from child 2.</section>
如何检索值child1.xml
和child2.xml
?
答案 0 :(得分:1)
除非您关闭该功能,否则所有XInclude处理器都应添加@xml:base属性 使用包含文件的URL。所以你不必做任何事情,它应该已经是:
<section xml:base="child1.xml">Text from child 1.</section>
<section xml:base="child2.xml">Text from child 2.</section>
(如果需要,可以使用XSLT将@xml:base attr转换为@srcFile。)
答案 1 :(得分:0)
我99%确定一旦处理了xi:include,就会有一个文档(和单个信息集),它不会让您确定文档的任何给定部分来自哪个URL。
我认为您需要将这些信息直接放在单独的文件中。话虽如此,您仍然可以尝试document-uri,但我认为所有节点都会返回相同的URI。