From Wiki
Jump to navigation Jump to search



{...} xmldata, usually main
{...} pattern that matches tags that stand for 'include external file'. Default: include
{...} names of attribute containing URL of file to include, separated by pipes. Default: href


\xmlinclude{main}{include}{filename|href|name} merges XML trees in external files into the tree called main. External files are merged in at every include tag; which file to merge in is determined by looking at the filename attribute; if that is absent the href and name attributes are tried in order.

Further behaviour:

  • If no attribute is specified, 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 pull in, then they, in turn are acted on, too. If you do not want recursive inclusion, you must use the xml.include)) command directly, like so:
\ctxlxml{include("main","include","filename|href",false)} % false means no recursion


Here is an example how to use \xmlinclude to combine several xml files into one document. The xml files represent single chapters of a book project. Their structure is:

<chapter title="Chapter 1">
    Text of chapter

Then, one master file combines all these into one structure via the xi:include element [1]:

  <xi:include href="chapter_1.xml"/>
  <xi:include href="chapter_2.xml"/>

And finally, you process this with a master tex file:

\startxmlsetups xml:setups


\startxmlsetups xml:document

\startxmlsetups xml:chapter




See also

Help from ConTeXt-Mailinglist/Forum

All issues with: