Reusing Content
THESE PAGES ARE STILL UNDER CONSTRUCTION AND DO NOT NECESSARELY REFLECT THE CURRENT VERSION OF TÓPICO
While reusing small content snippets is great for inline content, larger content blocks can also be reused through a subset of the XInclude standard.
Using XInclude syntax to reuse XML content chunks
To get the basics on how to use XInclude, follow the Include referenced content tutorial.
You can add also a "fallback" element to the "include" node and Tópico will use it if it cannot find the file or the target element. Only XHTML tags are allowed in the "fallback" element.
Please note that when your add a "fallback" element to an XInclude, the blank page turns to a red flag
. To edit the "include" tag you then need to select it from the tag list.
Using XInclude with an XPath pattern
You can also include an element by referencing it with an XPath pattern. As an example, to include the whole body of another topic/page, you could use "//xhtml:body" as the xpointer attribute value.
XInclude and XPointer support in Tópico
Tópico only supports a small subset of the XInclude/XPointer specifications. Although this level of support is extremely limited, it's possibly the most useful for simple publishing scenarios.
Here's what's supported:
- The href attribute of the xinclude element can (must) point to any XML file;
- The xpointer attribute can contain the id of the target element (shorthand form);
- The xpointer attribute can contain an XPath statement to the target element;
No other scheme is currently supported for the xpointer attribute.
Inserting a predefined content chunk
By editing the file "insert.xml" that's found in the root of the collection, you can define various content that can be inserted with the
button. This file has a simple structure that borrows a lot from the XStandard styles.xml files.Here's how the site map XInclude is defined in this file:
<tag> <name> <en>Include Site Map</en> <fr>Include Site Map</fr> </name> <elt>include</elt> <attr> <name>class</name> <value>sitemap</value> </attr> <attr> <name>href</name> <value>ul.sitemap.en.xml</value> </attr> <attr> <name>xpointer</name> <value>sitemap</value> </attr> <attr> <name>xmlns</name> <value>http://www.w3.org/2001/XInclude</value> </attr> <content/> </tag>
The above tag definition, which has an English and French label, creates an "include" element with three attributes:
- href with a value of ul.sitemap.xml
- xpointer with a value of sitemap (the id of the top ul element)
- xmlns with a value of http://www.w3.org/2001/XInclude (the namespace URI for XInclude)
No content is created within this element since the "content" node under the tag is empty.
If you ever find yourself including a complex block of markup repeatedly, you might want to consider creating a custom tag that would appear when you click the
button. You can define a different set of custom tags for each collection you create.THESE PAGES ARE STILL UNDER CONSTRUCTION AND DO NOT NECESSARELY REFLECT THE CURRENT VERSION OF TÓPICO