Generating Content

THESE PAGES ARE STILL UNDER CONSTRUCTION AND DO NOT NECESSARELY REFLECT THE CURRENT VERSION OF TÓPICO

Content generation lets you add small content snippets during the publishing process. Although CSS 2.1 defines some generated content rules, the lack of support for this feature makes it unwidely used, while we wait for Microsoft to get it working in IE7 or IE8. Then you don't really have to care if you're using Tópico.

Generated content snippets types

Generated content snippets can be of two types:

  • Text
  • XPath

These two modes correspond to the text and XML spaces described in this topic.

Text content snippets

The Text type selects the value of the Text field by looking at the topic markup as a text file. This is a very flexible feature that can also generate malformed XML, which you want to avoid. Be careful if you use generated content in text mode.

Example
Type Position Text Content
Text Before <div class="warning"> <div class="warning_label">Warning</div>

The above entries add a div element of class "warning_label" just before any div element of class "warning". Learn more about this example in this tutorial.

Tip

You can click on the WYSIWYG icon in the editor toolbar to switch to the xml view sourceof your topic. The XML view allows you to select text string to paste in the generated content grid.

XPath content snippets

The XPath type selects the target element by looking at the XML source file as a tree. When you use the XPath generated content type, the Content field must be a well formed xml element.

Example
Type Position Text Content
XPath After //a[contains(@href,'http')] <img class="external_link" src="images/external_link.jpg"/>

The above entries add a small external link icon to all links in the collection that target an http server. Learn more about this example in this tutorial. The XPath expression selects all anchors elements (<a>) that have a href attribute that contains "http". The Content, which is a well formed XHTML img element, is then added just After the selected node. Again, the display properties are defines with another CSS selector.

Tip

Don't forget to create a style in your stylesheet that will make this new content fit nicely within the publication.

Generated content options

The following table lists the different generated content options available.

Type Position Description
Text Before The textual Content is inserted before the Text
Text After The textual Content is inserted after the Text
Text Replace The textual Content replaces the Text
XPath Before The XML element in the Content column is inserted before the target element.
Xpath After The XML element in the Content column is inserted after the target element.
XPath Replace The XML element in the Content column ireplaces the target element.
XPath First child The XML element in the Content column is inserted as the first child of the target element.
XPath Last child The XML element in the Content column is inserted as the last child of the target element.
Caution

Note that the First child and Last child options only make sense when targeting an element with an XPath statement. These positions will do nothing in Text mode.

THESE PAGES ARE STILL UNDER CONSTRUCTION AND DO NOT NECESSARELY REFLECT THE CURRENT VERSION OF TÓPICO

109 / 194