[xsd-users] Re: xinclude
Boris Kolpackov
boris at codesynthesis.com
Wed Nov 9 10:54:32 EST 2005
Frederic,
frederic heem <frederic.heem at telsey.it> writes:
> I would like to use Xinclude inside an xml instance file, is it
> possible to do it with xsd ?
xsd does not provide any special handling for XInclude so you
will have to handle it yourself. One approach to this problem
is to define a 'choice' between an in-line element content
and an inclusion from a separate instance document:
<complexType name="Foo">
...
</complexType>
<complexType name="Bar">
<choice>
<element name="foo" type="Foo"/>
<element name="include-foo" type="anyURI"/>
</choice>
</complexType>
<element name="foo" type="Foo"/>
<element name="bar" type="Bar"/>
Having this structure, in your application you can handle
include-foo by parsing the separate instance document and
using the result to "fix" the tree, e.g.,
Bar& bar = ...
if (bar.include_foo ())
{
// Parse the included document.
//
auto_ptr<Foo> f (foo (*bar.include_foo ()));
// Copy the result into the original tree.
//
bar.foo (f);
}
This way the rest of your application logic does not have to worry
about the inclusion and can just assume that foo is always set.
hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20051109/aff48b95/attachment.pgp
More information about the xsd-users
mailing list