I would like a portable solution to creating a multiply nested XML document using XInclude. I am using <xi:include href="foo.xml">
elements and taking the input from a stream. So far this fails (I am using XOM which has its own XIncluder) which reports it cannot find the base URL for the href
. I am wondering if this is a general problem (see XercesDOMParser and XIncludes ). If so are there general workarounds?
Asked
Active
Viewed 136 times
2

Community
- 1
- 1

peter.murray.rust
- 37,407
- 44
- 153
- 217
1 Answers
3
A relative URI like foo.xml
is useless without the context of a base URI with which to work out that e.g. if the base URI is http://example.net/bar/baz.xml
then the absolute URI of the resource is http://example.net/bar/foo.xml
.
This base URI can come from:
- The URI that the XML in question came from (clearly not applicable to a stream alone).
- A URI passed to a parser by mechanisms specific to it.
xml:base
- Means specific to a given XML application (not advisable, but sometimes necessary for compatibility with other formats, e.g. the
<base />
element in XHTML duplicatesxml:base
unnecessarily and with less flexibility, but is required for compatibility with HTML4.01 and earlier).

Jon Hanna
- 110,372
- 10
- 146
- 251