Difference between revisions of "Number labels"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
Line 66: Line 66:
  
 
For example the leveltext “%0;%1.%2:” will be heuristically transformed to style:num-prefix=””, style:num-suffix=”:” and text:display-levels=”3”.
 
For example the leveltext “%0;%1.%2:” will be heuristically transformed to style:num-prefix=””, style:num-suffix=”:” and text:display-levels=”3”.
 +
 +
== OD Schema enhancements ==
 +
 +
<pre>
 +
<define name="common-num-format-prefix-suffix-attlist" combine="interleave">
 +
<optional>
 +
  <attribute name="style:level-text"><ref name="string"/></attribute>
 +
</optional>
 +
</define>
 +
</pre>

Revision as of 11:48, 29 November 2006

Label generation in ODT

In the ODT file format the label of a number has the form

NUMBERLABEL ::= PREFIX SUBLEVEL* NUM POSTFIX
SUBLEVEL ::= (NUM ".")

where PREFIX and POSTFIX are arbitrary strings and NUM is a string representation of the number value (e.g. 1, A, I, i, ..., ).

Consider for example the numbered paragraph

(A.I.1) text text text text

whose label consists of the PREFIX “(“, the POSFIX “)”, the SUBLEVELs “A.” and “I.” and the number “1”.

In the ODT file format the above sample paragraph numbering will be represented as

<text:list-style style:name="L1">
	<text:list-level-style-number text:level="1" style:num-format="A">
		...
	</text:list-level-style-number>
	<text:list-level-style-number text:level="2" style:num-format="I">
		...
	</text:list-level-style-number>
	<text:list-level-style-number text:level="3" style:num-prefix="(" 
			style:num-suffix=")" style:num-format="1" 
			text:display-levels="3">
		...
	</text:list-level-style-number>
	...
</text:list-style>

Label generation in WordML

The number label generation of WordML is different. WordML has a “labeltext” which includes placeholders for the desired numbers. Consider for example the labeltext

(%0.%1.%2)

which models e.g. the label (A.I.1.) of the above paragraph when assuming that %0 is a placeholder for the number at level 0 whose format is “A, B, ...”; that %1 is a placeholder for the number at level 1 whose format is “I, II, ...” and that %2 is a placeholder for the number at level 2 whose format is “1, 2, ...”. Obviously every OO.o Writer label can be expressed by a WordML “labeltext”. However the opposite is not true. Consider the following labeltext

%0;%1.%2:

which generates labels of the form “1;1.1:”, “1;1.2:”, etc. It is not possible to express labels of that kind using OpenOffice Writer.

ODT Enhancement

For better roundtrip compatibility we suggest the implementation of a label specification mechanism into the ODT file format which is also based on a “labeltext”. A leveltext is an arbitrary string which contains placeholders of the form “%i” to represent the string representation of the ith-level's number.

In the file format the enhancement can be represented by adding an attribute “text:labeltext” to the text:list-level-style-number of the ODT file format. If the “text:labeltext” attribute is present, then the label will be generated using the “text:labeltext” attribute; in case the “text:labeltext” attribute is not present, the label will be generated using the style:num-prefix, style:num-suffix and text:display-levels attributes.

For backward compatibility we suggest ODT generating entities to also write the style:num-prefix, style:num-suffix and text:display-levels attributes. The following heuristic could be applied to infer the old attributes:

1. Let %max resp. %min be the greatest placeholder resp. the lowest placeholder in the leveltext. The text:display-levels attribute is set to %max-%min+1.

2. The style:num-prefix attribute is set to the substring starting at the first position of the labeltext and ending at the occurrence of the first placeholder.

3. The style:num-suffix attribute is set to the substring starting behind the occurrence of the last placeholder and ending at the end of the leveltext.

For example the leveltext “%0;%1.%2:” will be heuristically transformed to style:num-prefix=””, style:num-suffix=”:” and text:display-levels=”3”.

OD Schema enhancements

<define name="common-num-format-prefix-suffix-attlist" combine="interleave">
<optional>
  <attribute name="style:level-text"><ref name="string"/></attribute>
</optional>
</define>
Personal tools