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.

FOValidationEventProducer.java 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.fo;
  19. import org.xml.sax.Locator;
  20. import org.apache.xmlgraphics.util.QName;
  21. import org.apache.fop.apps.FOPException;
  22. import org.apache.fop.events.EventBroadcaster;
  23. import org.apache.fop.events.EventProducer;
  24. import org.apache.fop.fo.expr.PropertyException;
  25. /**
  26. * Event producer interface for XSL-FO validation messages.
  27. */
  28. public interface FOValidationEventProducer extends EventProducer {
  29. /**
  30. * Factory class for the event producer.
  31. */
  32. class Factory {
  33. /**
  34. * Creates a new event producer.
  35. * @param broadcaster the event broadcaster to use
  36. * @return the new event producer
  37. */
  38. public static FOValidationEventProducer create(EventBroadcaster broadcaster) {
  39. return (FOValidationEventProducer)broadcaster.getEventProducerFor(
  40. FOValidationEventProducer.class);
  41. }
  42. }
  43. /**
  44. * Too many child nodes.
  45. * @param source the event source
  46. * @param elementName the name of the context node
  47. * @param offendingNode the offending node
  48. * @param loc the location of the error or null
  49. * @throws ValidationException the validation error provoked by the method call
  50. * @event.severity FATAL
  51. */
  52. void tooManyNodes(Object source, String elementName, QName offendingNode,
  53. Locator loc) throws ValidationException;
  54. /**
  55. * The node order is wrong.
  56. * @param source the event source
  57. * @param elementName the name of the context node
  58. * @param tooLateNode string name of node that should be earlier in document
  59. * @param tooEarlyNode string name of node that should be later in document
  60. * @param canRecover indicates whether FOP can recover from this problem and continue working
  61. * @param loc the location of the error or null
  62. * @throws ValidationException the validation error provoked by the method call
  63. */
  64. void nodeOutOfOrder(Object source, String elementName,
  65. String tooLateNode, String tooEarlyNode, boolean canRecover,
  66. Locator loc) throws ValidationException;
  67. /**
  68. * An invalid child was encountered.
  69. * @param source the event source
  70. * @param elementName the name of the context node
  71. * @param offendingNode the offending node
  72. * @param ruleViolated the rule that was violated or null
  73. * @param loc the location of the error or null
  74. * @throws ValidationException the validation error provoked by the method call
  75. */
  76. void invalidChild(Object source, String elementName, QName offendingNode, String ruleViolated,
  77. Locator loc) throws ValidationException;
  78. /**
  79. * A required child element is missing.
  80. * @param source the event source
  81. * @param elementName the name of the context node
  82. * @param contentModel the expected content model
  83. * @param canRecover indicates whether FOP can recover from this problem and continue working
  84. * @param loc the location of the error or null
  85. * @throws ValidationException the validation error provoked by the method call
  86. * @event.severity FATAL
  87. */
  88. void missingChildElement(Object source, String elementName,
  89. String contentModel, boolean canRecover,
  90. Locator loc) throws ValidationException;
  91. /**
  92. * An element is missing a required property.
  93. * @param source the event source
  94. * @param elementName the name of the context node
  95. * @param propertyName the name of the missing property
  96. * @param loc the location of the error or null
  97. * @throws ValidationException the validation error provoked by the method call
  98. * @event.severity FATAL
  99. */
  100. void missingProperty(Object source, String elementName, String propertyName,
  101. Locator loc) throws ValidationException;
  102. /**
  103. * An id was used twice in a document.
  104. * @param source the event source
  105. * @param elementName the name of the context node
  106. * @param id the id that was reused
  107. * @param canRecover indicates whether FOP can recover from this problem and continue working
  108. * @param loc the location of the error or null
  109. * @throws ValidationException the validation error provoked by the method call
  110. * @event.severity FATAL
  111. */
  112. void idNotUnique(Object source, String elementName, String id, boolean canRecover,
  113. Locator loc) throws ValidationException;
  114. /**
  115. * There are multiple color profiles defined with the same name.
  116. * @param source the event source
  117. * @param elementName the name of the context node
  118. * @param name the duplicate color profile name
  119. * @param loc the location of the error or null
  120. * @event.severity WARN
  121. */
  122. void colorProfileNameNotUnique(Object source, String elementName, String name,
  123. Locator loc);
  124. /**
  125. * There are multiple page masters defined with the same name.
  126. * @param source the event source
  127. * @param elementName the name of the context node
  128. * @param name the duplicate page master name
  129. * @param loc the location of the error or null
  130. * @throws ValidationException the validation error provoked by the method call
  131. * @event.severity FATAL
  132. */
  133. void masterNameNotUnique(Object source, String elementName, String name,
  134. Locator loc) throws ValidationException;
  135. /**
  136. * A marker is not an initial child on a node.
  137. * @param source the event source
  138. * @param elementName the name of the context node
  139. * @param mcname the marker class name
  140. * @param loc the location of the error or null
  141. * @event.severity ERROR
  142. */
  143. void markerNotInitialChild(Object source, String elementName, String mcname, Locator loc);
  144. /**
  145. * A marker class name is not unique within the same parent.
  146. * @param source the event source
  147. * @param elementName the name of the context node
  148. * @param mcname the marker class name
  149. * @param loc the location of the error or null
  150. * @event.severity ERROR
  151. */
  152. void markerNotUniqueForSameParent(Object source, String elementName,
  153. String mcname, Locator loc);
  154. /**
  155. * An invalid property was found.
  156. * @param source the event source
  157. * @param elementName the name of the context node
  158. * @param attr the invalid attribute
  159. * @param canRecover indicates whether FOP can recover from this problem and continue working
  160. * @param loc the location of the error or null
  161. * @throws ValidationException the validation error provoked by the method call
  162. * @event.severity FATAL
  163. */
  164. void invalidProperty(Object source, String elementName, QName attr, boolean canRecover,
  165. Locator loc) throws ValidationException;
  166. /**
  167. * An invalid property value was encountered.
  168. * @param source the event source
  169. * @param elementName the name of the context node
  170. * @param propName the property name
  171. * @param propValue the property value
  172. * @param e the property exception caused by the invalid value
  173. * @param loc the location of the error or null
  174. * @event.severity ERROR
  175. */
  176. void invalidPropertyValue(Object source, String elementName,
  177. String propName, String propValue, PropertyException e,
  178. Locator loc);
  179. /**
  180. * A feature is not supported, yet.
  181. * @param source the event source
  182. * @param elementName the name of the context node
  183. * @param feature the unsupported feature
  184. * @param loc the location of the error or null
  185. * @event.severity WARN
  186. */
  187. void unimplementedFeature(Object source, String elementName, String feature,
  188. Locator loc);
  189. /**
  190. * Missing internal-/external-destination on basic-link or bookmark.
  191. * @param source the event source
  192. * @param elementName the name of the context node
  193. * @param loc the location of the error or null
  194. * @throws ValidationException the validation error provoked by the method call
  195. * @event.severity FATAL
  196. */
  197. void missingLinkDestination(Object source, String elementName, Locator loc)
  198. throws ValidationException;
  199. /**
  200. * Indicates a problem while cloning a marker (ex. due to invalid property values).
  201. * @param source the event source
  202. * @param markerClassName the "marker-class-name" of the marker
  203. * @param fe the FOP exception that cause this problem
  204. * @param loc the location of the error or null
  205. * @event.severity ERROR
  206. */
  207. void markerCloningFailed(Object source, String markerClassName, FOPException fe, Locator loc);
  208. /**
  209. * A region name is mapped to multiple region classes.
  210. * @param source the event source
  211. * @param regionName the region name
  212. * @param defaultRegionClass1 the first default region class
  213. * @param defaultRegionClass2 the second default region class
  214. * @param loc the location of the error or null
  215. * @throws ValidationException the validation error provoked by the method call
  216. * @event.severity FATAL
  217. */
  218. void regionNameMappedToMultipleRegionClasses(Object source, String regionName,
  219. String defaultRegionClass1, String defaultRegionClass2, Locator loc)
  220. throws ValidationException;
  221. /**
  222. * There are multiple flows with the same name.
  223. * @param source the event source
  224. * @param elementName the name of the context node
  225. * @param flowName the flow name
  226. * @param loc the location of the error or null
  227. * @throws ValidationException the validation error provoked by the method call
  228. * @event.severity FATAL
  229. */
  230. void duplicateFlowNameInPageSequence(Object source, String elementName, String flowName,
  231. Locator loc) throws ValidationException;
  232. /**
  233. * A flow name could not be mapped to a region.
  234. * @param source the event source
  235. * @param elementName the name of the context node
  236. * @param flowName the flow name
  237. * @param loc the location of the error or null
  238. * @throws ValidationException the validation error provoked by the method call
  239. * @event.severity FATAL
  240. */
  241. void flowNameNotMapped(Object source, String elementName, String flowName,
  242. Locator loc) throws ValidationException;
  243. /**
  244. * A page master could not be found.
  245. * @param source the event source
  246. * @param elementName the name of the context node
  247. * @param masterReference the page master reference
  248. * @param loc the location of the error or null
  249. * @throws ValidationException the validation error provoked by the method call
  250. * @event.severity FATAL
  251. */
  252. void masterNotFound(Object source, String elementName, String masterReference,
  253. Locator loc) throws ValidationException;
  254. /**
  255. * An illegal region name was used.
  256. * @param source the event source
  257. * @param elementName the name of the context node
  258. * @param regionName the region name
  259. * @param loc the location of the error or null
  260. * @throws ValidationException the validation error provoked by the method call
  261. * @event.severity FATAL
  262. */
  263. void illegalRegionName(Object source, String elementName, String regionName,
  264. Locator loc) throws ValidationException;
  265. /**
  266. * A non-zero border and/or padding has been encountered on a region.
  267. * @param source the event source
  268. * @param elementName the name of the context node
  269. * @param regionName the region name
  270. * @param canRecover indicates whether FOP can recover from this problem and continue working
  271. * @param loc the location of the error or null
  272. * @throws ValidationException the validation error provoked by the method call
  273. * @event.severity FATAL
  274. */
  275. void nonZeroBorderPaddingOnRegion(Object source, String elementName, String regionName,
  276. boolean canRecover, Locator loc) throws ValidationException;
  277. /**
  278. * If overflow property is set to "scroll", a column-count other than "1" may not be specified.
  279. * @param source the event source
  280. * @param elementName the name of the context node
  281. * @param loc the location of the error or null
  282. * @throws ValidationException the validation error provoked by the method call
  283. * @event.severity FATAL
  284. */
  285. void columnCountErrorOnRegionBodyOverflowScroll(Object source, String elementName,
  286. Locator loc) throws ValidationException;
  287. /**
  288. * fo:root must be root.
  289. * @param source the event source
  290. * @param elementName the name of the context node
  291. * @param loc the location of the error or null
  292. * @throws ValidationException the validation error provoked by the method call
  293. * @event.severity FATAL
  294. */
  295. void invalidFORoot(Object source, String elementName,
  296. Locator loc) throws ValidationException;
  297. /**
  298. * No FO document was found.
  299. * @param source the event source
  300. * @throws ValidationException the validation error provoked by the method call
  301. * @event.severity FATAL
  302. */
  303. void emptyDocument(Object source) throws ValidationException;
  304. /**
  305. * An unknown/unsupported formatting object has been encountered.
  306. * @param source the event source
  307. * @param elementName the name of the context node
  308. * @param offendingNode the offending node
  309. * @param loc the location of the error or null
  310. * @event.severity WARN
  311. */
  312. void unknownFormattingObject(Object source, String elementName,
  313. QName offendingNode, Locator loc);
  314. }