Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

FOValidationEventProducer.java 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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 required child element is missing.
  81. * @param source the event source
  82. * @param elementName the name of the context node
  83. * @param contentModel the expected content model
  84. * @param canRecover indicates whether FOP can recover from this problem and continue working
  85. * @param loc the location of the error or null
  86. * @throws ValidationException the validation error provoked by the method call
  87. * @event.severity FATAL
  88. */
  89. void missingChildElement(Object source, String elementName,
  90. String contentModel, boolean canRecover,
  91. Locator loc) throws ValidationException;
  92. /**
  93. * An element is missing a required property.
  94. * @param source the event source
  95. * @param elementName the name of the context node
  96. * @param propertyName the name of the missing property
  97. * @param loc the location of the error or null
  98. * @throws ValidationException the validation error provoked by the method call
  99. * @event.severity FATAL
  100. */
  101. void missingProperty(Object source, String elementName, String propertyName,
  102. Locator loc) throws ValidationException;
  103. /**
  104. * An id was used twice in a document.
  105. * @param source the event source
  106. * @param elementName the name of the context node
  107. * @param id the id that was reused
  108. * @param canRecover indicates whether FOP can recover from this problem and continue working
  109. * @param loc the location of the error or null
  110. * @throws ValidationException the validation error provoked by the method call
  111. * @event.severity FATAL
  112. */
  113. void idNotUnique(Object source, String elementName, String id, boolean canRecover,
  114. Locator loc) throws ValidationException;
  115. /**
  116. * There are multiple color profiles defined with the same name.
  117. * @param source the event source
  118. * @param elementName the name of the context node
  119. * @param name the duplicate color profile name
  120. * @param loc the location of the error or null
  121. * @event.severity WARN
  122. */
  123. void colorProfileNameNotUnique(Object source, String elementName, String name,
  124. Locator loc);
  125. /**
  126. * There are multiple page masters 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 page master name
  130. * @param loc the location of the error or null
  131. * @throws ValidationException the validation error provoked by the method call
  132. * @event.severity FATAL
  133. */
  134. void masterNameNotUnique(Object source, String elementName, String name,
  135. Locator loc) throws ValidationException;
  136. /**
  137. * An fo:marker appears as initial descendant in an fo:block-container
  138. * that generates absolutely positioned areas
  139. * @param source the event source
  140. * @param loc the location of the error (possibly null)
  141. * @event.severity ERROR
  142. */
  143. void markerBlockContainerAbsolutePosition(Object source, Locator loc);
  144. /**
  145. * A marker is not an initial child on a node.
  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 markerNotInitialChild(Object source, String elementName, String mcname, Locator loc);
  153. /**
  154. * A marker class name is not unique within the same parent.
  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 markerNotUniqueForSameParent(Object source, String elementName,
  162. String mcname, Locator loc);
  163. /**
  164. * An invalid property was found.
  165. * @param source the event source
  166. * @param elementName the name of the context node
  167. * @param attr the invalid attribute
  168. * @param canRecover indicates whether FOP can recover from this problem and continue working
  169. * @param loc the location of the error or null
  170. * @throws ValidationException the validation error provoked by the method call
  171. * @event.severity FATAL
  172. */
  173. void invalidProperty(Object source, String elementName, QName attr, boolean canRecover,
  174. Locator loc) throws ValidationException;
  175. /**
  176. * An invalid property value was encountered.
  177. * @param source the event source
  178. * @param elementName the name of the context node
  179. * @param propName the property name
  180. * @param propValue the property value
  181. * @param e the property exception caused by the invalid value
  182. * @param loc the location of the error or null
  183. * @event.severity ERROR
  184. */
  185. void invalidPropertyValue(Object source, String elementName,
  186. String propName, String propValue, PropertyException e,
  187. Locator loc);
  188. /**
  189. * A feature is not supported, yet.
  190. * @param source the event source
  191. * @param elementName the name of the context node
  192. * @param feature the unsupported feature
  193. * @param loc the location of the error or null
  194. * @event.severity WARN
  195. */
  196. void unimplementedFeature(Object source, String elementName, String feature,
  197. Locator loc);
  198. /**
  199. * Missing internal-/external-destination on basic-link or bookmark.
  200. * @param source the event source
  201. * @param elementName the name of the context node
  202. * @param loc the location of the error or null
  203. * @throws ValidationException the validation error provoked by the method call
  204. * @event.severity FATAL
  205. */
  206. void missingLinkDestination(Object source, String elementName, Locator loc)
  207. throws ValidationException;
  208. /**
  209. * Indicates a problem while cloning a marker (ex. due to invalid property values).
  210. * @param source the event source
  211. * @param markerClassName the "marker-class-name" of the marker
  212. * @param fe the FOP exception that cause this problem
  213. * @param loc the location of the error or null
  214. * @event.severity ERROR
  215. */
  216. void markerCloningFailed(Object source, String markerClassName, FOPException fe, Locator loc);
  217. /**
  218. * A region name is mapped to multiple region classes.
  219. * @param source the event source
  220. * @param regionName the region name
  221. * @param defaultRegionClass1 the first default region class
  222. * @param defaultRegionClass2 the second default region class
  223. * @param loc the location of the error or null
  224. * @throws ValidationException the validation error provoked by the method call
  225. * @event.severity FATAL
  226. */
  227. void regionNameMappedToMultipleRegionClasses(Object source, String regionName,
  228. String defaultRegionClass1, String defaultRegionClass2, Locator loc)
  229. throws ValidationException;
  230. /**
  231. * There are multiple flows with the same name.
  232. * @param source the event source
  233. * @param elementName the name of the context node
  234. * @param flowName the flow name
  235. * @param loc the location of the error or null
  236. * @throws ValidationException the validation error provoked by the method call
  237. * @event.severity FATAL
  238. */
  239. void duplicateFlowNameInPageSequence(Object source, String elementName, String flowName,
  240. Locator loc) throws ValidationException;
  241. /**
  242. * A flow name could not be mapped to a region.
  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 flowNameNotMapped(Object source, String elementName, String flowName,
  251. Locator loc) throws ValidationException;
  252. /**
  253. * A page master could not be found.
  254. * @param source the event source
  255. * @param elementName the name of the context node
  256. * @param masterReference the page master reference
  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 masterNotFound(Object source, String elementName, String masterReference,
  262. Locator loc) throws ValidationException;
  263. /**
  264. * An illegal region name was used.
  265. * @param source the event source
  266. * @param elementName the name of the context node
  267. * @param regionName the region name
  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 illegalRegionName(Object source, String elementName, String regionName,
  273. Locator loc) throws ValidationException;
  274. /**
  275. * A non-zero border and/or padding has been encountered on a region.
  276. * @param source the event source
  277. * @param elementName the name of the context node
  278. * @param regionName the region name
  279. * @param canRecover indicates whether FOP can recover from this problem and continue working
  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 nonZeroBorderPaddingOnRegion(Object source, String elementName, String regionName,
  285. boolean canRecover, Locator loc) throws ValidationException;
  286. /**
  287. * If overflow property is set to "scroll", a column-count other than "1" may not be specified.
  288. * @param source the event source
  289. * @param elementName the name of the context node
  290. * @param loc the location of the error or null
  291. * @throws ValidationException the validation error provoked by the method call
  292. * @event.severity FATAL
  293. */
  294. void columnCountErrorOnRegionBodyOverflowScroll(Object source, String elementName,
  295. Locator loc) throws ValidationException;
  296. /**
  297. * fo:root must be root.
  298. * @param source the event source
  299. * @param elementName the name of the context node
  300. * @param loc the location of the error or null
  301. * @throws ValidationException the validation error provoked by the method call
  302. * @event.severity FATAL
  303. */
  304. void invalidFORoot(Object source, String elementName,
  305. Locator loc) throws ValidationException;
  306. /**
  307. * No FO document was found.
  308. * @param source the event source
  309. * @throws ValidationException the validation error provoked by the method call
  310. * @event.severity FATAL
  311. */
  312. void emptyDocument(Object source) throws ValidationException;
  313. /**
  314. * An unknown/unsupported formatting object has been encountered.
  315. * @param source the event source
  316. * @param elementName the name of the context node
  317. * @param offendingNode the offending node
  318. * @param loc the location of the error or null
  319. * @event.severity WARN
  320. */
  321. void unknownFormattingObject(Object source, String elementName,
  322. QName offendingNode, Locator loc);
  323. /**
  324. * Alternate text is missing for a graphic element.
  325. *
  326. * @param source the event source
  327. * @param foElement name of the element (external-graphic or instream-foreign-object)
  328. * @param loc the location of the error or null
  329. * @event.severity WARN
  330. */
  331. void altTextMissing(Object source, String foElement, Locator loc);
  332. }