8.3. The Style Sheet Dialog

Style sheets are created and modified using the style sheet dialog. You can display this dialog by selecting Element->Style Sheet from the main menu or by clicking on the Style Sheet button in to toolbar. Both actions will display the style sheet dialog and pre-select the style sheet for the current element.

The style sheet dialog uses five tabs to organize the style sheet information for the elements in your document.

8.3.1. Style overview

The first tab of the style sheet dialog contains a combo box for selecting an Element or XPath. When the style sheet dialog is invoked, the current element is pre-selected in this combo box. The information in the other tabs of the style sheet dialog refers to the element that is selected here.

Figure 8-1. The style sheet dialog 1

You can switch to the style sheet for another element by selecting a different entry from the combo box. The combo box contains both element names and defined XPath specifications.

The current style for the element or XPath that is selected in the combo box is applied to the example text in the text field below to show you the effects of the current style sheet settings for this XPath.

You can add a new XPath specification (see Adding new XPaths) to the available styles by pressing the Add button or you can delete the current XPath specification by pressing the Delete button. You can not delete the XPath specifications that contain only an element name.

If you press the Add button, a second dialog for defining an new XPath will be displayed. Please refer to Adding new XPaths for more details.

8.3.2. Fonts

The second tab of the style sheet dialog contains the font and color-specific settings for the selected XPath.

Figure 8-2. The style sheet dialog 2

The Face and Size fields determine the font and font size to use. Both combo boxes can be set to inherited for inheriting the values from the parent element.

The foreground color can be chosen by clicking on the colored square to the left of the Selected option. A color selection pop-up will appear for choosing the font color of the element. Selecting the Inherited option will make the element inherit the values from its parent.

The background color for the element can be selected in the same way as the foreground color. The Stippling value can be used to gray-out the element. The background color of the element will be combined with a gray-value of the selected percentage.

Slant, Weight, Overstrike, and Underline values can be explicitly defined to display the element in a certain way or they can be inherited from the parent element.

8.3.3. Spacing

The third tab of the style sheet dialog contains information about the vertical and horizontal spacing for an element.

Figure 8-3. The style sheet dialog 3

The first three settings for Indent and Offset apply to the indentation of lines within the element. Left indent first line is the value of screen pixels that a line in this element should be left-indented. Left indent other line determines the left indent for wrapped lines, i.e. the left indent that is used for the remainder of a line that did not fit into the window. Right indent specifies the amount of right indentation for the element content.

Vertical offset is mostly used for subscript and superscript elements and specifies the number of pixels that the element content should be raised above or below the baseline of the surrounding text.

Alignment specifies whether the element content is left or right aligned or centered in the document window.

Note: The effectiveness of settings that apply to a complete line is determined by the occurrence of the first displayed item on a line.

For example, you might specify that a title element should be centered on the screen. A title element may occur in a section directly after the start tag of the section element. If both tags are shown on the same line, the settings of the section element (whose start tag occurs before the title element) determines how the line is adjusted.

Tip: If you want to specify the alignment or indentation for an element, then make sure that this element will appear on its own line by setting the appropriate options in the Line breaking tab.

The Above first line, Above other lines and Below lines determine how much additional white space epcEdit will add between lines within the element.

The Above Element and Below Element values determine an extra amount of white space to add above and below the lines that contain the start and end tag of the element, respectively.

8.3.4. Line Breaking

The fourth tab in the style sheet dialog contains options for automatic line breaking before and after an element. Line breaking in epcEdit means automatically inserting a newline character before or after the start and end tags for an element.

Figure 8-4. The style sheet dialog 4

By default, the style sheet mechanism will not modify any line breaks in your document. You must explicitly enable automatic line breaking for an element of XPath by selecting the Enable automatic line breaking option at the top of the dialog.

The settings for line breaking occur in parallel for the start and end tag of an element. A line may be broken before or after the start or end tag of an element. There are three options for breaking a line before or after the start or end tag of an element

Context dependent

If this option is selected, epcEdit will decide whether to break a line before the start tag of an element of after the end tag of an element based on the context in which the element occurs. A line is broken before the start tag of an element if the start tag of the element immediately follows the end tag of another element. A line is broken after the end tag of the element if the end tag immediately precedes the start tag of the next element.

Always

If this option is selected, epcEdit will always insert a line break before the start tag or after the end tag of the element.

Never

if this option is selected, epcEdit will never insert a line break before the start tag or after the end tag of an element.

These options govern the insertion of line breaks before the start tag or after the end tag of an element. The newline characters are inserted around the element. The Break line after start tag and Break line before end tag options tell epcEdit to insert line break within the element immediately after the start tag or before the end tag.

The options described above will normally take effect only if the element occurs within another element that contains only elements, but no data (i.e. in an element with element content). The line breaks that are inserted in such a context are treated as ignorable whitespace by an XML/SGML processing system. If an element occurs within mixed content (where both elements and data can occur), a line break may be considered part of the data by an XML/SGML processor. To avoid this problem, epcEdit will not apply the settings above if an element occurs in mixed content.

To apply the line breaking settings even if an element occurs in mixed content, the Apply in mixed content option must be checked.

If you select the Remove Line Breaks option at the bottom of the document, epcEdit will re-flow the content of the element or XPath by replacing line breaks within the affected elements by space characters.

8.3.5. Images

The next-to-last tab of the style sheet dialog controls list enumerations and the insertion of embedded images.

Figure 8-5. The style sheet dialog 5

An image can be displayed inside an element if one of attributes specify the image. The image can either be specified by an attribute that contains a file name, by an attribute that references an entity or by both. The two drop-down lists at the top of the dialog can be used to select the attributes that contain the image specification.

If both attributes (file and entity) are specified, the attribute value specifications in the individual elements control which image is displayed. If only one of these attributes is specified for an element in the document instance, the value of this attribute will be used for the image. If both attributes are specified for an element in the document instance, the value of the file attribute will take precedence. For example, the style sheet may declare that a graphic element can specify the image with an attribute name fileref of with an attribute named entityref. If a graphic element with both attributes occurs in the document instance, the value of the attribute fileref will be used for selecting the image.

Other attributes can be used to control the width and height of the image. The names of these attributes can be selected in the Width and Height drop-down lists.

An element may be treated as a part of an enumeration or it can be prefixed with a bullet or a predefined text. The options in the lower part of the dialog can be used to select the prefix for the element by entering a text string, by selecting one of the enumeration types, or by choosing one of the bullet types.

8.3.6. Insertion

The Insertion tab of the style sheet dialog is used to control what happens when a new element with the given type is inserted. The settings in this tab apply only to XPaths that contain a single element name.

Figure 8-6. The stylesheet dialog 6

These options determine what epcEdit will do when the selected element is inserted.

The default behaviour is to insert all required elements automatically. Inserting the required elements scans through the element definition from left to right and creates a new element for every element that must occur inside the new element. For every new sub-element that is created, epcEdit will determine which elements are required inside the sub-elemnt and insert the required elements of the sub-element.

This process stops when epcEdit encounters a situation where it can not decide which element has to be inserted, e.g. because an alternative of two required element types is specified in the DTD.

You can choose to insert arbitrary text in the new element. The text can contain valid markup in textual form. When inserting the text, epcEdit will interpret the markup and create the corresponding structures. If the text contains markup that leads to the creation of new elements, the required sub-elements for these elements will not be automatically inserted.