问题
I have two different XML files (IzPack installation to be exact) which a common part. Naturally, I would like to keep this common part in one (external) file and to include it into two XML installation files.
I cannot make it work as it appears that XInclude can only include files with XML elements. To illustrate the example, here is some code:
File 1:
<packs>
<pack name="1">
...
</pack>
<pack name="2">
...
</pack>
<packs>
File 2:
<packs>
<pack name="1">
...
</pack>
<pack name="2">
...
</pack>
<pack name="3">
...
</pack>
<packs>
I would like the included file to contain only
<pack name="1">
...
</pack>
<pack name="2">
...
</pack>
But it looks like it's impossible. What am I missing ?
Update: The Xinclude code looks like:
<packs>
<xi:include xmlns:xi="w3.org/2001/XInclude"; href="browserPacks.xml" parse="text"/>
回答1:
How does your xinclude
look like? Have you tried parse=text
:
<xi:include href="common.xml" parse="text"
xmlns:xi="http://www.w3.org/2001/XInclude"/>
So with this, you should be able to have your file1 look like this:
<packs>
<xi:include href="common.xml" parse="text"
xmlns:xi="http://www.w3.org/2001/XInclude"/>
<packs>
and your file2 like this:
<packs>
<xi:include href="common.xml" parse="text"
xmlns:xi="http://www.w3.org/2001/XInclude"/>
<pack name="3">
....
</pack>
<packs>
来源:https://stackoverflow.com/questions/1973545/xml-xinclude-and-two-elements-with-the-same-name