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