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 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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.events.model.AbstractEventModelFactory;
  25. import org.apache.fop.events.model.EventModel;
  26. import org.apache.fop.fo.expr.PropertyException;
  27. /**
  28. * Event producer interface for XSL-FO validation messages.
  29. */
  30. public interface FOValidationEventProducer extends EventProducer {
  31. /**
  32. * Provider class for the event producer.
  33. */
  34. final class Provider {
  35. private Provider() { }
  36. /**
  37. * Returns an event producer.
  38. * @param broadcaster the event broadcaster to use
  39. * @return the event producer
  40. */
  41. public static FOValidationEventProducer get(EventBroadcaster broadcaster) {
  42. return (FOValidationEventProducer)broadcaster.getEventProducerFor(
  43. FOValidationEventProducer.class);
  44. }
  45. }
  46. /** Event model factory for Accessibility. */
  47. public static class EventModelFactory extends AbstractEventModelFactory {
  48. /** {@inheritDoc} */
  49. public EventModel createEventModel() {
  50. return loadModel(getClass(), "event-model.xml");
  51. }
  52. }
  53. /**
  54. * Too many child nodes.
  55. * @param source the event source
  56. * @param elementName the name of the context node
  57. * @param offendingNode the offending node
  58. * @param loc the location of the error or null
  59. * @throws ValidationException the validation error provoked by the method call
  60. * @event.severity FATAL
  61. */
  62. void tooManyNodes(Object source, String elementName, QName offendingNode,
  63. Locator loc) throws ValidationException;
  64. /**
  65. * The node order is wrong.
  66. * @param source the event source
  67. * @param elementName the name of the context node
  68. * @param tooLateNode string name of node that should be earlier in document
  69. * @param tooEarlyNode string name of node that should be later in document
  70. * @param canRecover indicates whether FOP can recover from this problem and continue working
  71. * @param loc the location of the error or null
  72. * @throws ValidationException the validation error provoked by the method call
  73. */
  74. void nodeOutOfOrder(Object source, String elementName,
  75. String tooLateNode, String tooEarlyNode, boolean canRecover,
  76. Locator loc) throws ValidationException;
  77. /**
  78. * An invalid child was encountered.
  79. * @param source the event source
  80. * @param elementName the name of the context node
  81. * @param offendingNode the offending node
  82. * @param ruleViolated the rule that was violated or null
  83. * @param loc the location of the error or null
  84. * @throws ValidationException the validation error provoked by the method call
  85. */
  86. void invalidChild(Object source, String elementName, QName offendingNode, String ruleViolated,
  87. Locator loc) throws ValidationException;
  88. /**
  89. * A required child element is missing.
  90. * @param source the event source
  91. * @param elementName the name of the context node
  92. * @param contentModel the expected content model
  93. * @param canRecover indicates whether FOP can recover from this problem and continue working
  94. * @param loc the location of the error or null
  95. * @throws ValidationException the validation error provoked by the method call
  96. * @event.severity FATAL
  97. */
  98. void missingChildElement(Object source, String elementName,
  99. String contentModel, boolean canRecover,
  100. Locator loc) throws ValidationException;
  101. /**
  102. * An element is missing a required property.
  103. * @param source the event source
  104. * @param elementName the name of the context node
  105. * @param propertyName the name of the missing property
  106. * @param loc the location of the error or null
  107. * @throws ValidationException the validation error provoked by the method call
  108. * @event.severity FATAL
  109. */
  110. void missingProperty(Object source, String elementName, String propertyName,
  111. Locator loc) throws ValidationException;
  112. /**
  113. * An id was used twice in a document.
  114. * @param source the event source
  115. * @param elementName the name of the context node
  116. * @param id the id that was reused
  117. * @param canRecover indicates whether FOP can recover from this problem and continue working
  118. * @param loc the location of the error or null
  119. * @throws ValidationException the validation error provoked by the method call
  120. * @event.severity FATAL
  121. */
  122. void idNotUnique(Object source, String elementName, String id, boolean canRecover,
  123. Locator loc) throws ValidationException;
  124. /**
  125. * There are multiple color profiles 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 color profile name
  129. * @param loc the location of the error or null
  130. * @event.severity WARN
  131. */
  132. void colorProfileNameNotUnique(Object source, String elementName, String name,
  133. Locator loc);
  134. /**
  135. * There are multiple page masters defined with the same name.
  136. * @param source the event source
  137. * @param elementName the name of the context node
  138. * @param name the duplicate page master name
  139. * @param loc the location of the error or null
  140. * @throws ValidationException the validation error provoked by the method call
  141. * @event.severity FATAL
  142. */
  143. void masterNameNotUnique(Object source, String elementName, String name,
  144. Locator loc) throws ValidationException;
  145. /**
  146. * An fo:marker appears as initial descendant in an fo:block-container
  147. * that generates absolutely positioned areas
  148. * @param source the event source
  149. * @param loc the location of the error (possibly null)
  150. * @event.severity ERROR
  151. */
  152. void markerBlockContainerAbsolutePosition(Object source, Locator loc);
  153. /**
  154. * A marker is not an initial child on a node.
  155. * @param source the event source
  156. * @param elementName the name of the context node
  157. * @param mcname the marker class name
  158. * @param loc the location of the error or null
  159. * @event.severity ERROR
  160. */
  161. void markerNotInitialChild(Object source, String elementName, String mcname, Locator loc);
  162. /**
  163. * A marker class name is not unique within the same parent.
  164. * @param source the event source
  165. * @param elementName the name of the context node
  166. * @param mcname the marker class name
  167. * @param loc the location of the error or null
  168. * @event.severity ERROR
  169. */
  170. void markerNotUniqueForSameParent(Object source, String elementName,
  171. String mcname, Locator loc);
  172. /**
  173. * An invalid property was found.
  174. * @param source the event source
  175. * @param elementName the name of the context node
  176. * @param attr the invalid attribute
  177. * @param canRecover indicates whether FOP can recover from this problem and continue working
  178. * @param loc the location of the error or null
  179. * @throws ValidationException the validation error provoked by the method call
  180. * @event.severity FATAL
  181. */
  182. void invalidProperty(Object source, String elementName, QName attr, boolean canRecover,
  183. Locator loc) throws ValidationException;
  184. /**
  185. * An invalid property value was encountered.
  186. * @param source the event source
  187. * @param elementName the name of the context node
  188. * @param propName the property name
  189. * @param propValue the property value
  190. * @param e the property exception caused by the invalid value
  191. * @param loc the location of the error or null
  192. * @event.severity ERROR
  193. */
  194. void invalidPropertyValue(Object source, String elementName,
  195. String propName, String propValue, PropertyException e,
  196. Locator loc);
  197. /**
  198. * A feature is not supported, yet.
  199. * @param source the event source
  200. * @param elementName the name of the context node
  201. * @param feature the unsupported feature
  202. * @param loc the location of the error or null
  203. * @event.severity WARN
  204. */
  205. void unimplementedFeature(Object source, String elementName, String feature,
  206. Locator loc);
  207. /**
  208. * Missing internal-/external-destination on basic-link or bookmark.
  209. * @param source the event source
  210. * @param elementName the name of the context node
  211. * @param loc the location of the error or null
  212. * @throws ValidationException the validation error provoked by the method call
  213. * @event.severity FATAL
  214. */
  215. void missingLinkDestination(Object source, String elementName, Locator loc)
  216. throws ValidationException;
  217. /**
  218. * Indicates a problem while cloning a marker (ex. due to invalid property values).
  219. * @param source the event source
  220. * @param markerClassName the "marker-class-name" of the marker
  221. * @param fe the FOP exception that cause this problem
  222. * @param loc the location of the error or null
  223. * @event.severity ERROR
  224. */
  225. void markerCloningFailed(Object source, String markerClassName, FOPException fe, Locator loc);
  226. /**
  227. * A region name is mapped to multiple region classes.
  228. * @param source the event source
  229. * @param regionName the region name
  230. * @param defaultRegionClass1 the first default region class
  231. * @param defaultRegionClass2 the second default region class
  232. * @param loc the location of the error or null
  233. * @throws ValidationException the validation error provoked by the method call
  234. * @event.severity FATAL
  235. */
  236. void regionNameMappedToMultipleRegionClasses(Object source, String regionName,
  237. String defaultRegionClass1, String defaultRegionClass2, Locator loc)
  238. throws ValidationException;
  239. /**
  240. * There are multiple flows with the same name.
  241. * @param source the event source
  242. * @param elementName the name of the context node
  243. * @param flowName the flow name
  244. * @param loc the location of the error or null
  245. * @throws ValidationException the validation error provoked by the method call
  246. * @event.severity FATAL
  247. */
  248. void duplicateFlowNameInPageSequence(Object source, String elementName, String flowName,
  249. Locator loc) throws ValidationException;
  250. /**
  251. * A flow name could not be mapped to a region.
  252. * @param source the event source
  253. * @param elementName the name of the context node
  254. * @param flowName the flow name
  255. * @param loc the location of the error or null
  256. * @throws ValidationException the validation error provoked by the method call
  257. * @event.severity FATAL
  258. */
  259. void flowNameNotMapped(Object source, String elementName, String flowName,
  260. Locator loc) throws ValidationException;
  261. /**
  262. * A page master could not be found.
  263. * @param source the event source
  264. * @param elementName the name of the context node
  265. * @param masterReference the page master reference
  266. * @param loc the location of the error or null
  267. * @throws ValidationException the validation error provoked by the method call
  268. * @event.severity FATAL
  269. */
  270. void masterNotFound(Object source, String elementName, String masterReference,
  271. Locator loc) throws ValidationException;
  272. /**
  273. * An illegal region name was used.
  274. * @param source the event source
  275. * @param elementName the name of the context node
  276. * @param regionName the region name
  277. * @param loc the location of the error or null
  278. * @throws ValidationException the validation error provoked by the method call
  279. * @event.severity FATAL
  280. */
  281. void illegalRegionName(Object source, String elementName, String regionName,
  282. Locator loc) throws ValidationException;
  283. /**
  284. * A non-zero border and/or padding has been encountered on a region.
  285. * @param source the event source
  286. * @param elementName the name of the context node
  287. * @param regionName the region name
  288. * @param canRecover indicates whether FOP can recover from this problem and continue working
  289. * @param loc the location of the error or null
  290. * @throws ValidationException the validation error provoked by the method call
  291. * @event.severity FATAL
  292. */
  293. void nonZeroBorderPaddingOnRegion(Object source, String elementName, String regionName,
  294. boolean canRecover, Locator loc) throws ValidationException;
  295. /**
  296. * If overflow property is set to "scroll", a column-count other than "1" may not be specified.
  297. * @param source the event source
  298. * @param elementName the name of the context node
  299. * @param loc the location of the error or null
  300. * @throws ValidationException the validation error provoked by the method call
  301. * @event.severity FATAL
  302. */
  303. void columnCountErrorOnRegionBodyOverflowScroll(Object source, String elementName,
  304. Locator loc) throws ValidationException;
  305. /**
  306. * fo:root must be root.
  307. * @param source the event source
  308. * @param elementName the name of the context node
  309. * @param loc the location of the error or null
  310. * @throws ValidationException the validation error provoked by the method call
  311. * @event.severity FATAL
  312. */
  313. void invalidFORoot(Object source, String elementName,
  314. Locator loc) throws ValidationException;
  315. /**
  316. * No FO document was found.
  317. * @param source the event source
  318. * @throws ValidationException the validation error provoked by the method call
  319. * @event.severity FATAL
  320. */
  321. void emptyDocument(Object source) throws ValidationException;
  322. /**
  323. * An unknown/unsupported formatting object has been encountered.
  324. * @param source the event source
  325. * @param elementName the name of the context node
  326. * @param offendingNode the offending node
  327. * @param loc the location of the error or null
  328. * @event.severity WARN
  329. */
  330. void unknownFormattingObject(Object source, String elementName,
  331. QName offendingNode, Locator loc);
  332. /**
  333. * Alternate text is missing for a graphic element.
  334. *
  335. * @param source the event source
  336. * @param foElement name of the element (external-graphic or instream-foreign-object)
  337. * @param loc the location of the error or null
  338. * @event.severity WARN
  339. */
  340. void altTextMissing(Object source, String foElement, Locator loc);
  341. }