top | previous | next

Step 10: Printing Attributes and attributes for printing

You can print attributes within prefix and suffix rules (maybe in other places too). If you just need to print a optional attribute value (impled) but don't need any decorations like parenthesis just do the following:

In all contexts.
Prefix: <$attribute[attr_name]>

If you want to surround attributes with something, e.g. *** *** to indicate that some element has special status, you must test if the attribute has a value. I don't know how to do this properly, but testing if the attribute value is equals or bigger than the first value in a list of values works (ugly). In the example below we test if the current element (e.g. Title) has an attribute Status with value bigger than rough-draft" in the list of choices. If true we print:

Prefix rules
If context is: [Status>="rough-draft"] 
Prefix:  +++ <$attribute[Status]> +++ 

FYI here is the DTD definition of this Status attribute (a "choice" type in the EDD)

<!ATTLIST Title Status (rough-draft | draft | bad | ok | good) #IMPLIED >

You can also use attributes to conditionnally print out text. A typical example are typed lists (bullets vs. numbers) like in the following case. Note that we do not test attribute values of the current element but of the parent element called List

Text format rules
1.If context is:List [Type ="Bullet"]
	  Numbering properties
		      Autonumber format:· 	
		      Character format:bulletsymbol
  Else,if context is:List [Type ="Numbered"]
		 	     Numbering properties
			         Autonumber format:<n+>	

More information about testing attributes (including occurencies in more complicated contexts are on page 36ff, 123ff, 149ff of the lovely developper's manual.