You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

alt.properties.xml 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!-- $Id$ -->
  3. <!--
  4. <!DOCTYPE document SYSTEM "../../xml-docs/dtd/document-v10.dtd">
  5. -->
  6. <document>
  7. <header>
  8. <title>Implementing Properties</title>
  9. <authors>
  10. <person id="pbw" name="Peter B. West" email="pbwest@powerup.com.au"/>
  11. </authors>
  12. </header>
  13. <body>
  14. <!-- one of (anchor s1) -->
  15. <s1 title="An alternative properties implementation">
  16. <note>
  17. The following discussion focusses on the relationship between
  18. Flow Objects in the Flow Object tree, and properties. There
  19. is no (or only passing) discussion of the relationship between
  20. properties and traits, and by extension, between properties
  21. and the Area tree. The discussion is illustrated with some
  22. pseudo-UML diagrams.
  23. </note>
  24. <p>
  25. Property handling is complex and expensive. Varying numbers of
  26. properties apply to individual Flow Objects
  27. <strong>(FOs)</strong> in the <strong>FO
  28. tree </strong> but any property may effectively be
  29. assigned a value on any element of the tree. If that property
  30. is inheritable, its defined value will then be available to
  31. any children of the defining FO.
  32. </p>
  33. <note>
  34. <em>(XSL 1.0 Rec)</em> <strong>5.1.4 Inheritance</strong>
  35. ...The inheritable properties can be placed on any formatting
  36. object.
  37. </note>
  38. <p>
  39. Even if the value is not inheritable, it may be accessed by
  40. its children through the <code>inherit</code> keyword or the
  41. <code>from-parent()</code> core function, and potentially by
  42. any of its descendents through the
  43. <code>from-nearest-specified-value()</code> core function.
  44. </p>
  45. <p>
  46. In addition to the assigned values of properties, almost every
  47. property has an <strong>initial value</strong> which is used
  48. when no value has been assigned.
  49. </p>
  50. <s2 title="The history problem">
  51. <p>
  52. The difficulty and expense of handling properties comes from
  53. this univeral inheritance possibility. The list of properties
  54. which are assigned values on any particular <em>FO</em>
  55. element will not generally be large, but a current value is
  56. required for each property which applies to the <em>FO</em>
  57. being processed.
  58. </p>
  59. <p>
  60. The environment from which these values may be selected
  61. includes, for each <em>FO</em>, for each applicable property,
  62. the value assigned on this <em>FO</em>, the value which
  63. applied to the parent of this <em>FO</em>, the nearest value
  64. specified on an ancestor of this element, and the initial
  65. value of the property.
  66. </p>
  67. </s2>
  68. <s2 title="Data requirement and structure">
  69. <p>
  70. This determines the minimum set of properties and associated
  71. property value assignments that is necessary for the
  72. processing of any individual <em>FO</em>. Implicit in this
  73. set is the set of properties and associated values,
  74. effective on the current <em>FO</em>, that were assigned on
  75. that <em>FO</em>.
  76. </p>
  77. <p>
  78. This minimum requirement - the initial value, the
  79. nearest ancestor specified value, the parent computed value
  80. and the value assigned to the current element -
  81. suggests a stack implementation.
  82. </p>
  83. </s2>
  84. <s2 title="Stack considerations">
  85. <p>
  86. One possibility is to push to the stack only a minimal set
  87. of required elements. When a value is assigned, the
  88. relevant form or forms of that value (specified, computed,
  89. actual) are pushed onto the stack. As long as each
  90. <em>FO</em> maintains a list of the properties which were
  91. assigned from it, the value can be popped when the focus of
  92. FO processing retreats back up the <em>FO</em> tree.
  93. </p>
  94. <p>
  95. The complication is that, for elements which are not
  96. automatically inherited, when an <em>FO</em> is encountered
  97. which does <strong>not</strong> assign a value to the
  98. property, the initial value must either be already at the
  99. top of the stack or be pushed onto the stack.
  100. </p>
  101. <p>
  102. As a first approach, the simplest procedure may be to push a
  103. current value onto the stack for every element - initial
  104. values for non-inherited properties and the parental value
  105. otherwise. Then perform any processing of assigned values.
  106. This simplifies program logic at what is hopefully a small
  107. cost in memory and processing time. It may be tuned in a
  108. later iteration.
  109. </p>
  110. <s3 title="Stack implementation">
  111. <p>
  112. Initial attempts at this implementation have used
  113. <code>LinkedList</code>s as the stacks, on the assumption
  114. that
  115. </p>
  116. <sl>
  117. <!-- one of (dl sl ul ol li) -->
  118. <li>random access would not be required</li>
  119. <li>
  120. pushing and popping of list elements requires nearly
  121. constant (low) time
  122. </li>
  123. <li> no penalty for first addition to an empty list</li>
  124. <li>efficient access to both bottom and top of stack</li>
  125. </sl>
  126. <p>
  127. However, it may be required to perform stack access
  128. operations from an arbitrary place on the stack, in which
  129. case it would probably be more efficient to use
  130. <code>ArrayList</code>s instead.
  131. </p>
  132. </s3>
  133. </s2>
  134. <s2 title="Class vs instance">
  135. <p>
  136. An individual stack would contain values for a particular
  137. property, and the context of the stack is the property class
  138. as a whole. The property instances would be represented by
  139. the individual values on the stack. If properties are to be
  140. represented as instantiations of the class, the stack
  141. entries would presumably be references to, or at least
  142. referenced from, individual property objects. However, the
  143. most important information about individual property
  144. instances is the value assigned, and the relationship of
  145. this property object to its ancestors and its descendents.
  146. Other information would include the ownership of a property
  147. instance by a particular <em>FO</em>, and, in the other
  148. direction, the membership of the property in the set of
  149. properties for which an <em>FO</em> has defined values.
  150. </p>
  151. <p>
  152. In the presence of a stack, however, none of this required
  153. information mandates the instantiation of properties. All
  154. of the information mentioned so far can be effectively
  155. represented by a stack position and a link to an
  156. <em>FO</em>. If the property stack is maintained in
  157. parallel with a stack of <em>FOs</em>, even that link is
  158. implicit in the stack position.
  159. </p>
  160. </s2>
  161. <p>
  162. <strong>Next:</strong> <link href= "classes-overview.html"
  163. >property classes overview.</link>
  164. </p>
  165. </s1>
  166. </body>
  167. </document>