Andres Olarte wrote:
I want to use Xinclude to have "shared" parts of my documentation,
fragments that are stored once but shown in multiple places. I know
that you can do this with Xinclude, according to a previous post, but
I'm lost as to how to actually do it in Forrest. I'm really, not very
experienced with advanced XML. Does anybody has a simple example?
You need to the xinclude namespace to the document:
<document xmlns:xi="http://www.w3.org/2001/XInclude">
Then you add the XIinclude instruction at the relevant point in your
document. The href can be any legal URL.
<xi:include href="cocoon://index.xml"/>
The problem with this is that it includes the whole document, including
the header, whcih you probably don't want. To include a part of the
document you can add an XPointer part to your URL:
<xi:include href="cocoon://index.xml#xpointer(//body/*)"/>
or
<xi:include
href="cocoon://index.xml#xpointer(//body/[EMAIL PROTECTED]'overview'])"/>
So a complete example would be (note this is a n old document using
document v1.2 schema, there is no technical reason for this, it can be
any supported schema):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.2//EN"
"document-v12.dtd">
<document xmlns:xi="http://www.w3.org/2001/XInclude">
<header>
<title>ECommerce - Session 1 - Introduction and Networking
BasicsComplete Notes</title>
</header>
<body>
<section>
<title>Course Outline</title>
<xi:include href="cocoon://index.xml#xpointer(//body/*)"/>
<xi:include href="cocoon://description.xml#xpointer(//body/*)"/>
<xi:include href="cocoon://objectives.xml#xpointer(//body/*)"/>
<xi:include href="cocoon://methodology.xml#xpointer(//body/*)"/>
<xi:include href="cocoon://evaluation.xml#xpointer(//body/*)"/>
<xi:include href="cocoon://resources.xml#xpointer(//body/*)"/>
<xi:include href="cocoon://schedule.xml#xpointer(//body/*)"/>
<xi:include href="cocoon://coursework.xml#xpointer(//body/*)"/>
</section>
<!-- and so on -->
</body>
</document>
Ross