Dear all, My example employs xi:include elements to include other xml files. It is constituted by a main.xml file which includes another file (include1.xml) stored in a subfolder, called include1.
include1.xml, in turn, includes another xml file (include2.xml) stored in a subfolder of include1 which is called include2.
Overall, the example consists of four folder levels and only the last file, include4.xml, contains data.
This is the contents of the files: ./main.xml <?xml version="1.0" encoding="UTF-8" ?> <main xmlns:xi="http://www.w3.org/2001/XInclude"> <xi:include href="" /> </main > /include1/include1.xml <?xml version="1.0" encoding="UTF-8" ?> <level1 xmlns:xi="http://www.w3.org/2001/XInclude"> <xi:include href="" /> </level1 > ./include1/include2/include2.xml <?xml version="1.0" encoding="UTF-8" ?> <level2 xmlns:xi="http://www.w3.org/2001/XInclude"> <xi:include href="" /> </level2 > ./include1/include2/include3/include3.xml <?xml version="1.0" encoding="UTF-8" ?> <level3 xmlns:xi="http://www.w3.org/2001/XInclude"> <xi:include href="" /> </level3 > ./include1/include2/include3/include4/include4.xml <?xml version="1.0" encoding="UTF-8" ?> <level4 xmlns:xi="http://www.w3.org/2001/XInclude"> <data> 0 </data> <data> 1 </data> </level4 > When I process main.xml, I obtain the following result: <main xmlns:xi="http://www.w3.org/2001/XInclude"> <level1 xml:base="./include1/include1.xml"> <level2 xml:base="./include1/include2/include2.xml"> <level3 xml:base="./include2/include3/include3.xml"> <level4 xml:base="./include3/include4/include4.xml"> <data>0</data> <data>1</data> </level4> </level3> </level2> </level1> </main> The xml tree is correct, but I have doubts about the value of the attribute xml:base. In particular: - level1: I think that the value of xml:base ( i.e. ./include1/include1.xml) is correct. - level2: xml:base value is correct if its meaning is a path relative to the root file. Otherwise, if xml:base is supposed to store a path relative to the current file, then it should be ./include2/include2.xml. - level3: This seems to be not correct, neither as an absolute path, nor as a relative path. I think it should be ./include1/include2/include3/include3.xml as a path relative to the root file or ./include3/include3.xml as a path relative
to the current file. - level4: Same as level3. I also tried to execute a Xquery command http://www.xqueryfunctions.com/xq/fn_base-uri.html on the output. The result returned by base-uri(//level3) is: file:///C:/software/test_include/include1/include1/include2/include2/include3/include3.xml which I think is wrong, I think it should be: file:///C:/software/test_include/include1/include2/include3/include3.xml I thus suspect that either the implementation of how xi:include generates the value of xml:base or the implementation of base-uri function has a problem. My suspect is on xi:include. What do you think? |