38.3 Adding attributes with PI markers

An attribute PI marker includes the name of the attribute as a suffix to the predefined PI marker type name. The content of the marker becomes the value of the attribute for the applicable element tag:

<elementname attributetype="content">

For example, for HTML output, a Rowbgcolor PI marker with content yellow, placed just before a DITA <entry> tag, would add the attribute bgcolor with value yellow to the HTML <tr> tag for the current table row:

<?dthtm Rowbgcolor="yellow" ?>

results in:

<tr bgcolor="yellow">

Nonconforming attribute markers

A few attribute PI markers do not conform exactly to this naming and usage convention; for example, WAI support PI markers CellGroup and CellSpan. See §35.2.4 Using PI markers for table-cell attributes. Another nonconforming attribute marker is MetaType. For HTML output, this marker causes a <meta> tag to be added to the <head> element; Type becomes the value of the name attribute, and the content of the marker becomes the value of the content attribute.

Concatenated attribute markers

Although the text of a DITA PI marker is not limited in length, you can concatenate all PI markers for the same attribute that are inserted before the next item to which they apply. You can just add more PI markers of the same type, and continue the content. For example:

<?dthtm tablesummary="This table shows the properties" ?>
<?dthtm tablesummary=" you can use for thingamabobs." ?>

Also:

Extra attributes

Using PI markers to add attributes can result in extra attributes for a given tag. Browsers ignore extra attributes, but validators would not be pleased; see §22.13 Passing W3C validation tests. (Of course validators would not be pleased with most of what is on the Web, so that might be of little consequence.)

Duplicate markers

If multiple attribute PI markers with identical names but different content apply to the same element, DITA2Go uses the content of the last PI marker encountered as the value of the attribute.

For HTML or XML output, DITA2Go treats any PI marker that has a name that begins with Cell, Char, Graph, Link, Meta, Para, Row, or Table as an attribute PI marker. For HTML (for example), DITA2Go inserts the attribute="value" pair specified by each of the attribute marker types as follows:

CellAttr

In the <td> or <th> tag for the enclosing table cell.

CharAttr

In the tag for the current or next inline element.

GraphAttr

In the next <img> tag.

LinkAttr

In the next link (<a href=...>) tag.

MetaType

In a <meta> tag; produces a new element, <meta name="Type" content="content">, in the <head> element.

ParaAttr

In the tag for the current block element.

RowAttr

In the <tr> tag for the current table row; best practice is to place the marker in the first cell in the row.

TableAttr

In the <table> tag, in the enclosing table; if not positioned in a table, applies to the next table in the same flow.

Table 38-2 lists the elements to which each attribute PI marker can apply for each output type.

Table 38-2 Elements to which attribute PI markers apply, by output type

Marker

Output type

HTML/XHTML

Generic XML

DITA XML

DocBook XML

CellAttr

<td>, <th>

<td>, <th>

<entry>, <stentry>, <choption>, <chdesc>, <proptype>, <propvalue>, <propdesc>

<td>, <th>

CharAttr

inline elements

inline elements

inline elements

inline elements

GraphAttr

<img>

<img>

<image>

<imagedata>

LinkAttr

<a> ( (does not apply to Help pop-ups, secondary window jumps, or footnote cross references)

<a> (applies to the AtagElement setting; do not use for name; overridden by XMLLinkAttrs)

<xref> (can add to or replace standard href, type, format, and scope attributes)

<xref>, <ulink>

MetaType

<meta>

<meta>

 

 

ParaAttr

block elements

block elements

block elements

block elements

RowAttr

<tr>

<tr>

<row>, <strow>, <chrow>, <property>

<tr>, <row>

TableAttr

<table>

<table>

<table>, <simpletable>, <choicetable>, <properties>

<table>

Previous Topic:  38.2 Understanding effects of PI markers

Next Topic:  38.4 Inserting code or text with PI markers

Parent Topic:  38. Working with processing instructions

Sibling Topics:

38.1 Understanding DITA2Go PI markers

38.2 Understanding effects of PI markers

38.4 Inserting code or text with PI markers