Rendering XML Documents in Author Mode
The structure of an XML document and the required restrictions on its elements and their attributes are defined with an XML schema. This makes it easier to edit XML documents in a visual editor. For more information about schema association, see Associating a Schema to XML Documents. The Author mode renders the content of the XML documents visually, based on a CSS stylesheet associated with the document.
Associating a Stylesheet with an XML Document
The rendering of an XML document in the Author mode is driven by a CSS stylesheet that conforms to the version 2.1 of the CSS specification from the W3C consortium. Some CSS 3 features, such as namespaces and custom extensions, of the CSS specification are also supported.
There are several methods for associating a stylesheet (CSS) with an XML document:
- Insert the
xml-stylesheet
processing instruction with thetype
attribute at the beginning of the XML document. If you do not want to alter your XML documents, you should create a new document type (framework).CSS example:
<?xml-stylesheet type="text/css" href="test.css"?>
Note
XHTML documents need alink
element, with thehref
andtype
attributes in thehead
child element, as specified in the W3C CSS specification. XHTML example:<link href="/style/screen.css" rel="stylesheet" type="text/css"/>
Tip
You can also insert thexml-stylesheet
processing instruction by using the Associate XSLT/CSS Stylesheet action that is available on the toolbar or in the XML menu. - Configure a Document Type Association by adding a new CSS file in the settings. To do so, open the
Preferences dialog box and go to
Document Type Association. Edit the appropriate framework, open
the Author tab, then the CSS tab. Press
the New button to add a new
CSS file.
Note
The Document Type Associations are read-only, so you need to extend an existing one.
You can read more about associating a CSS to a document in the section about customizing the CSS of a document type.
If a document has no CSS association or the referenced stylesheet files cannot be loaded, a default one is used. A warning message is also displayed at the beginning of the document, presenting the reason why the CSS cannot be loaded.
Document with no CSS association default rendering
Selecting and Combining Multiple CSS Styles
Oxygen XML Editor plugin provides a Styles drop-down menu on the toolbar that allows you to select one main (non-alternate) CSS style and multiple alternate CSS styles. This makes it easy to change the look of the document.
Tip
You can select a main CSS stylesheet that styles the whole document and then apply alternate styles, as layers, to specific parts of the document. In the subsequent figure, a DITA document has the Century style selected for the main CSS and the alternate styles Full width, Show table column specification, Hints, and Inline actions are combined for additive styling to specific parts of the document.