Changes

Jump to navigation Jump to search
1,115 bytes added ,  17:16, 17 December 2012
m
Inserted Hans' explanation from mailing list.
* If no attribute is specified, {{code|href}} is assumed.
* If the file is empty or not found, the inclusion tag is replaced with nothing.
* Inclusion is recursive: if there are inclusion tags in the external tree you merge pull in itself contains inclusion tags, then they , in turn are acted on, too.If you do not want recursive inclusion, you must use the {{code|xml.include))}} command directly, like so:  \ctxlxml{include("main","include","filename|href",false)} % false means no recursion
== Example ==
 
Here is an example how to use {{cmd|xmlinclude}} to combine several xml files into one document. The xml files represent single chapters of a book project. Their structure is:
<xmlcode>
<examplechapter title="Chapter 1"> <chaptercontent>text 1</ Text of chapter> <chapter>text 2</chaptercontent></examplechapter>
</xmlcode>
 
Then, one master file combines all these into one structure via the xi:include element [http://www.w3.org/TR/2003/WD-xinclude-20031110/]:
 
<xmlcode>
<document>
<xi:include href="chapter_1.xml"/>
<xi:include href="chapter_2.xml"/>
</document>
</xmlcode>
 
And finally, you process this with a master tex file:
<texcode>
\startxmlsetups xml:setups \xmlinclude{#1}{xi:include}{href} \xmlsetsetup{#1}{document|chapter}{xml:*}\stopxmlsetups \xmlregistersetup{xml:setups} \startxmlsetups xml:document \xmlflush{#1}\stopxmlsetups \startxmlsetups xml:chapter \startchapter[title=\xmlatt{#1}{title}] \xmlall{#1}{content} \stopchapter\stopxmlsetups \starttext  \xmlprocessfile{main}{master...xml}{} \stoptext
</texcode>
gardener
112

edits

Navigation menu