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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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 broadcaster.getEventProducerFor(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 valid but not yet supported child was encountered.
  80. *
  81. * @param source the event source
  82. * @param elementName the name of the context node
  83. * @param offendingNode the offending node
  84. * @param loc the location of the error or null
  85. * @throws ValidationException the validation error provoked by the method call
  86. */
  87. void notSupportedChild(Object source, String elementName, QName offendingNode, Locator loc)
  88. throws ValidationException;
  89. /**
  90. * A required child element is missing.
  91. * @param source the event source
  92. * @param elementName the name of the context node
  93. * @param contentModel the expected content model
  94. * @param canRecover indicates whether FOP can recover from this problem and continue working
  95. * @param loc the location of the error or null
  96. * @throws ValidationException the validation error provoked by the method call
  97. * @event.severity FATAL
  98. */
  99. void missingChildElement(Object source, String elementName,
  100. String contentModel, boolean canRecover,
  101. Locator loc) throws ValidationException;
  102. /**
  103. * An element is missing a required property.
  104. * @param source the event source
  105. * @param elementName the name of the context node
  106. * @param propertyName the name of the missing property
  107. * @param loc the location of the error or null
  108. * @throws ValidationException the validation error provoked by the method call
  109. * @event.severity FATAL
  110. */
  111. void missingProperty(Object source, String elementName, String propertyName,
  112. Locator loc) throws ValidationException;
  113. /**
  114. * An id was used twice in a document.
  115. * @param source the event source
  116. * @param elementName the name of the context node
  117. * @param id the id that was reused
  118. * @param canRecover indicates whether FOP can recover from this problem and continue working
  119. * @param loc the location of the error or null
  120. * @throws ValidationException the validation error provoked by the method call
  121. * @event.severity FATAL
  122. */
  123. void idNotUnique(Object source, String elementName, String id, boolean canRecover,
  124. Locator loc) throws ValidationException;
  125. /**
  126. * There are multiple color profiles defined with the same name.
  127. * @param source the event source
  128. * @param elementName the name of the context node
  129. * @param name the duplicate color profile name
  130. * @param loc the location of the error or null
  131. * @event.severity WARN
  132. */
  133. void colorProfileNameNotUnique(Object source, String elementName, String name,
  134. Locator loc);
  135. /**
  136. * There are multiple page masters defined with the same name.
  137. * @param source the event source
  138. * @param elementName the name of the context node
  139. * @param name the duplicate page master name
  140. * @param loc the location of the error or null
  141. * @throws ValidationException the validation error provoked by the method call
  142. * @event.severity FATAL
  143. */
  144. void masterNameNotUnique(Object source, String elementName, String name,
  145. Locator loc) throws ValidationException;
  146. /**
  147. * An fo:marker appears as initial descendant in an fo:block-container
  148. * that generates absolutely positioned areas
  149. * @param source the event source
  150. * @param loc the location of the error (possibly null)
  151. * @event.severity ERROR
  152. */
  153. void markerBlockContainerAbsolutePosition(Object source, Locator loc);
  154. /**
  155. * A marker is not an initial child on a node.
  156. * @param source the event source
  157. * @param elementName the name of the context node
  158. * @param mcname the marker class name
  159. * @param loc the location of the error or null
  160. * @event.severity ERROR
  161. */
  162. void markerNotInitialChild(Object source, String elementName, String mcname, Locator loc);
  163. /**
  164. * A marker class name is not unique within the same parent.
  165. * @param source the event source
  166. * @param elementName the name of the context node
  167. * @param mcname the marker class name
  168. * @param loc the location of the error or null
  169. * @event.severity ERROR
  170. */
  171. void markerNotUniqueForSameParent(Object source, String elementName,
  172. String mcname, Locator loc);
  173. /**
  174. * An invalid property was found.
  175. * @param source the event source
  176. * @param elementName the name of the context node
  177. * @param attr the invalid attribute
  178. * @param canRecover indicates whether FOP can recover from this problem and continue working
  179. * @param loc the location of the error or null
  180. * @throws ValidationException the validation error provoked by the method call
  181. * @event.severity FATAL
  182. */
  183. void invalidProperty(Object source, String elementName, QName attr, boolean canRecover,
  184. Locator loc) throws ValidationException;
  185. /**
  186. * An invalid property value was encountered.
  187. * @param source the event source
  188. * @param elementName the name of the context node
  189. * @param propName the property name
  190. * @param propValue the property value
  191. * @param e the property exception caused by the invalid value
  192. * @param loc the location of the error or null
  193. * @event.severity ERROR
  194. */
  195. void invalidPropertyValue(Object source, String elementName,
  196. String propName, String propValue, PropertyException e,
  197. Locator loc);
  198. /**
  199. * An invalid property value was encountered.
  200. * @param source the event source
  201. * @param elementName the name of the context node
  202. * @param propName the property name
  203. * @param propValue the property value
  204. * @param e the property exception caused by the invalid value
  205. * @param loc the location of the error or null
  206. * @event.severity WARN
  207. */
  208. void warnOnInvalidPropertyValue(Object source, String elementName,
  209. String propName, String propValue, PropertyException e,
  210. Locator loc);
  211. /**
  212. * A feature is not supported, yet.
  213. * @param source the event source
  214. * @param elementName the name of the context node
  215. * @param feature the unsupported feature
  216. * @param loc the location of the error or null
  217. * @event.severity WARN
  218. */
  219. void unimplementedFeature(Object source, String elementName, String feature,
  220. Locator loc);
  221. /**
  222. * Missing internal-/external-destination on basic-link or bookmark.
  223. * @param source the event source
  224. * @param elementName the name of the context node
  225. * @param loc the location of the error or null
  226. * @throws ValidationException the validation error provoked by the method call
  227. * @event.severity FATAL
  228. */
  229. void missingLinkDestination(Object source, String elementName, Locator loc)
  230. throws ValidationException;
  231. /**
  232. * Indicates a problem while cloning a marker (ex. due to invalid property values).
  233. * @param source the event source
  234. * @param markerClassName the "marker-class-name" of the marker
  235. * @param fe the FOP exception that cause this problem
  236. * @param loc the location of the error or null
  237. * @event.severity ERROR
  238. */
  239. void markerCloningFailed(Object source, String markerClassName, FOPException fe, Locator loc);
  240. /**
  241. * A region name is mapped to multiple region classes.
  242. * @param source the event source
  243. * @param regionName the region name
  244. * @param defaultRegionClass1 the first default region class
  245. * @param defaultRegionClass2 the second default region class
  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 regionNameMappedToMultipleRegionClasses(Object source, String regionName,
  251. String defaultRegionClass1, String defaultRegionClass2, Locator loc)
  252. throws ValidationException;
  253. /**
  254. * There are multiple flows with the same name.
  255. * @param source the event source
  256. * @param elementName the name of the context node
  257. * @param flowName the flow name
  258. * @param loc the location of the error or null
  259. * @throws ValidationException the validation error provoked by the method call
  260. * @event.severity FATAL
  261. */
  262. void duplicateFlowNameInPageSequence(Object source, String elementName, String flowName,
  263. Locator loc) throws ValidationException;
  264. /**
  265. * A flow name could not be mapped to a region.
  266. * @param source the event source
  267. * @param elementName the name of the context node
  268. * @param flowName the flow name
  269. * @param loc the location of the error or null
  270. * @throws ValidationException the validation error provoked by the method call
  271. * @event.severity FATAL
  272. */
  273. void flowNameNotMapped(Object source, String elementName, String flowName,
  274. Locator loc) throws ValidationException;
  275. /**
  276. * A page master could not be found.
  277. * @param source the event source
  278. * @param elementName the name of the context node
  279. * @param masterReference the page master reference
  280. * @param loc the location of the error or null
  281. * @throws ValidationException the validation error provoked by the method call
  282. * @event.severity FATAL
  283. */
  284. void masterNotFound(Object source, String elementName, String masterReference,
  285. Locator loc) throws ValidationException;
  286. /**
  287. * An illegal region name was used.
  288. * @param source the event source
  289. * @param elementName the name of the context node
  290. * @param regionName the region name
  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 illegalRegionName(Object source, String elementName, String regionName,
  296. Locator loc) throws ValidationException;
  297. /**
  298. * A non-zero border and/or padding has been encountered on a region.
  299. * @param source the event source
  300. * @param elementName the name of the context node
  301. * @param regionName the region name
  302. * @param canRecover indicates whether FOP can recover from this problem and continue working
  303. * @param loc the location of the error or null
  304. * @throws ValidationException the validation error provoked by the method call
  305. * @event.severity FATAL
  306. */
  307. void nonZeroBorderPaddingOnRegion(Object source, String elementName, String regionName,
  308. boolean canRecover, Locator loc) throws ValidationException;
  309. /**
  310. * If overflow property is set to "scroll", a column-count other than "1" may not be specified.
  311. * @param source the event source
  312. * @param elementName the name of the context node
  313. * @param loc the location of the error or null
  314. * @throws ValidationException the validation error provoked by the method call
  315. * @event.severity FATAL
  316. */
  317. void columnCountErrorOnRegionBodyOverflowScroll(Object source, String elementName,
  318. Locator loc) throws ValidationException;
  319. /**
  320. * fo:root must be root.
  321. * @param source the event source
  322. * @param elementName the name of the context node
  323. * @param loc the location of the error or null
  324. * @throws ValidationException the validation error provoked by the method call
  325. * @event.severity FATAL
  326. */
  327. void invalidFORoot(Object source, String elementName,
  328. Locator loc) throws ValidationException;
  329. /**
  330. * No FO document was found.
  331. * @param source the event source
  332. * @throws ValidationException the validation error provoked by the method call
  333. * @event.severity FATAL
  334. */
  335. void emptyDocument(Object source) throws ValidationException;
  336. /**
  337. * An unknown/unsupported formatting object has been encountered.
  338. * @param source the event source
  339. * @param elementName the name of the context node
  340. * @param offendingNode the offending node
  341. * @param loc the location of the error or null
  342. * @event.severity WARN
  343. */
  344. void unknownFormattingObject(Object source, String elementName,
  345. QName offendingNode, Locator loc);
  346. /**
  347. * A class for change bars is not unique.
  348. * @param source the event source
  349. * @param elementName the name of the context node
  350. * @param name the class name
  351. * @param loc the location of the error or null
  352. * @event.severity FATAL
  353. */
  354. void changeBarClassNotUnique(Object source, String elementName, String name,
  355. Locator loc);
  356. /**
  357. * Change bars were not stacked correctly
  358. * @param source the event source
  359. * @param elementName the name of the context node
  360. * @param beginName the class name of the beginning change bar
  361. * @param endName the class name of the ending change bar
  362. * @param loc the location of the error or null
  363. * @event.severity FATAL
  364. */
  365. void changeBarWrongStacking(Object source, String elementName, String beginName,
  366. String endName, Locator loc);
  367. /**
  368. * Change bar ended without a start of bar occurred
  369. * @param source the event source
  370. * @param elementName the name of the context node
  371. * @param loc the location of the error or null
  372. * @event.severity FATAL
  373. */
  374. void changeBarNoBegin(Object source, String elementName, Locator loc);
  375. /**
  376. * Change bar not descendant of fo:flow or fo:static-content
  377. * @param source the event source
  378. * @param elementName the name of the context node
  379. * @param loc the location of the error or null
  380. * @event.severity FATAL
  381. */
  382. void changeBarWrongAncestor(Object source, String elementName, Locator loc);
  383. /**
  384. * Alternate text is missing for a graphic element.
  385. *
  386. * @param source the event source
  387. * @param foElement name of the element (external-graphic or instream-foreign-object)
  388. * @param loc the location of the error or null
  389. * @event.severity WARN
  390. */
  391. void altTextMissing(Object source, String foElement, Locator loc);
  392. }