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.

AbstractRenderer.java 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.render;
  18. // Java
  19. import java.awt.geom.Rectangle2D;
  20. import java.io.IOException;
  21. import java.io.OutputStream;
  22. import java.util.Date;
  23. import java.util.Map;
  24. import java.util.List;
  25. import java.util.Iterator;
  26. // XML
  27. import org.w3c.dom.Document;
  28. // FOP
  29. import org.apache.fop.apps.FOPException;
  30. import org.apache.fop.area.Area;
  31. import org.apache.fop.area.BeforeFloat;
  32. import org.apache.fop.area.Block;
  33. import org.apache.fop.area.BlockViewport;
  34. import org.apache.fop.area.BodyRegion;
  35. import org.apache.fop.area.CTM;
  36. import org.apache.fop.area.Flow;
  37. import org.apache.fop.area.Footnote;
  38. import org.apache.fop.area.LineArea;
  39. import org.apache.fop.area.MainReference;
  40. import org.apache.fop.area.Span;
  41. import org.apache.fop.area.Page;
  42. import org.apache.fop.area.PageViewport;
  43. import org.apache.fop.area.RegionViewport;
  44. import org.apache.fop.area.RegionReference;
  45. import org.apache.fop.area.Title;
  46. import org.apache.fop.area.TreeExt;
  47. import org.apache.fop.area.inline.Container;
  48. import org.apache.fop.area.inline.ForeignObject;
  49. import org.apache.fop.area.inline.Image;
  50. import org.apache.fop.area.inline.InlineArea;
  51. import org.apache.fop.area.inline.InlineParent;
  52. import org.apache.fop.area.inline.Leader;
  53. import org.apache.fop.area.inline.Space;
  54. import org.apache.fop.area.inline.Viewport;
  55. import org.apache.fop.area.inline.TextArea;
  56. import org.apache.fop.area.inline.Character;
  57. import org.apache.fop.apps.FOUserAgent;
  58. import org.apache.fop.fo.Constants;
  59. import org.apache.fop.fonts.FontInfo;
  60. import org.apache.fop.fo.pagination.Region;
  61. import org.apache.commons.logging.Log;
  62. import org.apache.commons.logging.LogFactory;
  63. // Avalon
  64. import org.apache.avalon.framework.configuration.Configurable;
  65. import org.apache.avalon.framework.configuration.Configuration;
  66. import org.apache.avalon.framework.configuration.ConfigurationException;
  67. /**
  68. * Abstract base class for all renderers. The Abstract renderer does all the
  69. * top level processing of the area tree and adds some abstract methods to
  70. * handle viewports. This keeps track of the current block and inline position.
  71. */
  72. public abstract class AbstractRenderer
  73. implements Renderer, Configurable, Constants {
  74. /**
  75. * user agent
  76. */
  77. protected FOUserAgent userAgent;
  78. /**
  79. * logging instance
  80. */
  81. protected static Log logger = LogFactory.getLog("FOP");
  82. /**
  83. * block progression position
  84. */
  85. protected int currentBPPosition = 0;
  86. /**
  87. * inline progression position
  88. */
  89. protected int currentIPPosition = 0;
  90. /**
  91. * current inline progression position in block
  92. */
  93. protected int currentBlockIPPosition = 0;
  94. /**
  95. * the block progression position of the containing block used for
  96. * absolutely positioned blocks
  97. */
  98. protected int containingBPPosition = 0;
  99. /**
  100. * the inline progression position of the containing block used for
  101. * absolutely positioned blocks
  102. */
  103. protected int containingIPPosition = 0;
  104. /**
  105. * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
  106. */
  107. public void configure(Configuration conf) throws ConfigurationException {
  108. }
  109. /**
  110. * Returns the Commons-Logging instance for this class
  111. * @return The Commons-Logging instance
  112. */
  113. protected Log getLogger() {
  114. return logger;
  115. }
  116. /**
  117. * @see org.apache.fop.render.Renderer
  118. */
  119. public abstract void setupFontInfo(FontInfo fontInfo);
  120. /**
  121. * @see org.apache.fop.render.Renderer
  122. */
  123. public void setUserAgent(FOUserAgent agent) {
  124. userAgent = agent;
  125. }
  126. /** @see org.apache.fop.render.Renderer */
  127. public void startRenderer(OutputStream outputStream)
  128. throws IOException { }
  129. /** @see org.apache.fop.render.Renderer */
  130. public void stopRenderer()
  131. throws IOException { }
  132. /**
  133. * Check if this renderer supports out of order rendering. If this renderer
  134. * supports out of order rendering then it means that the pages that are
  135. * not ready will be prepared and a future page will be rendered.
  136. *
  137. * @return True if the renderer supports out of order rendering
  138. * @see org.apache.fop.render.Renderer
  139. */
  140. public boolean supportsOutOfOrder() {
  141. return false;
  142. }
  143. /**
  144. * @param ext (todo) Description of the Parameter
  145. * @see org.apache.fop.render.Renderer
  146. */
  147. public void renderExtension(TreeExt ext) { }
  148. /**
  149. * Prepare a page for rendering. This is called if the renderer supports
  150. * out of order rendering. The renderer should prepare the page so that a
  151. * page further on in the set of pages can be rendered. The body of the
  152. * page should not be rendered. The page will be rendered at a later time
  153. * by the call to render page.
  154. *
  155. * @see org.apache.fop.render.Renderer
  156. */
  157. public void preparePage(PageViewport page) { }
  158. /**
  159. * Utility method to convert a page sequence title to a string. Some
  160. * renderers may only be able to use a string title. A title is a sequence
  161. * of inline areas that this method attempts to convert to an equivalent
  162. * string.
  163. *
  164. * @param title The Title to convert
  165. * @return An expanded string representing the title
  166. */
  167. protected String convertTitleToString(Title title) {
  168. List children = title.getInlineAreas();
  169. String str = convertToString(children);
  170. return str.trim();
  171. }
  172. private String convertToString(List children) {
  173. StringBuffer sb = new StringBuffer();
  174. for (int count = 0; count < children.size(); count++) {
  175. InlineArea inline = (InlineArea) children.get(count);
  176. if (inline instanceof Character) {
  177. sb.append(((Character) inline).getChar());
  178. } else if (inline instanceof TextArea) {
  179. sb.append(((TextArea) inline).getTextArea());
  180. } else if (inline instanceof InlineParent) {
  181. sb.append(convertToString(
  182. ((InlineParent) inline).getChildAreas()));
  183. } else {
  184. sb.append(" ");
  185. }
  186. }
  187. return sb.toString();
  188. }
  189. /** @see org.apache.fop.render.Renderer */
  190. public void startPageSequence(Title seqTitle) {
  191. //do nothing
  192. }
  193. // normally this would be overriden to create a page in the
  194. // output
  195. /** @see org.apache.fop.render.Renderer */
  196. public void renderPage(PageViewport page)
  197. throws IOException, FOPException {
  198. Page p = page.getPage();
  199. renderPageAreas(p);
  200. }
  201. /**
  202. * Renders page areas.
  203. *
  204. * @param page The page whos page areas are to be rendered
  205. */
  206. protected void renderPageAreas(Page page) {
  207. /* Spec does not appear to specify whether fo:region-body should
  208. appear above or below side regions in cases of overlap. FOP
  209. decision is to have fo:region-body on top, hence it is rendered
  210. last here. */
  211. RegionViewport viewport;
  212. viewport = page.getRegionViewport(Region.BEFORE_CODE);
  213. renderRegionViewport(viewport);
  214. viewport = page.getRegionViewport(Region.START_CODE);
  215. renderRegionViewport(viewport);
  216. viewport = page.getRegionViewport(Region.END_CODE);
  217. renderRegionViewport(viewport);
  218. viewport = page.getRegionViewport(Region.AFTER_CODE);
  219. renderRegionViewport(viewport);
  220. viewport = page.getRegionViewport(Region.BODY_CODE);
  221. renderRegionViewport(viewport);
  222. }
  223. /**
  224. * Renders a region viewport. <p>
  225. *
  226. * The region may clip the area and it establishes a position from where
  227. * the region is placed.</p>
  228. *
  229. * @param port The region viewport to be rendered
  230. */
  231. protected void renderRegionViewport(RegionViewport port) {
  232. if (port != null) {
  233. Rectangle2D view = port.getViewArea();
  234. // The CTM will transform coordinates relative to
  235. // this region-reference area into page coords, so
  236. // set origin for the region to 0,0.
  237. currentBPPosition = 0;
  238. currentIPPosition = 0;
  239. currentBlockIPPosition = currentIPPosition;
  240. RegionReference region = port.getRegion();
  241. handleRegionTraits(port);
  242. // shouldn't the viewport have the CTM
  243. startVParea(region.getCTM());
  244. // do after starting viewport area
  245. if (region.getRegionClass() == Region.BODY_CODE) {
  246. renderBodyRegion((BodyRegion) region);
  247. } else {
  248. renderRegion(region);
  249. }
  250. endVParea();
  251. }
  252. }
  253. /**
  254. * (todo) Description of the Method
  255. *
  256. * @param ctm The coordinate transformation matrix to use
  257. */
  258. protected void startVParea(CTM ctm) { }
  259. /**
  260. * Handle the traits for a region
  261. * This is used to draw the traits for the given page region.
  262. * (See Sect. 6.4.1.2 of XSL-FO spec.)
  263. * @param rv the RegionViewport whose region is to be drawn
  264. */
  265. protected void handleRegionTraits(RegionViewport rv) {
  266. // draw border and background
  267. }
  268. /**
  269. * (todo) Description of the Method
  270. */
  271. protected void endVParea() { }
  272. /**
  273. * Renders a region reference area.
  274. *
  275. * @param region The region reference area
  276. */
  277. protected void renderRegion(RegionReference region) {
  278. List blocks = region.getBlocks();
  279. renderBlocks(null, blocks);
  280. }
  281. /**
  282. * Renders a body region area.
  283. *
  284. * @param region The body region
  285. */
  286. protected void renderBodyRegion(BodyRegion region) {
  287. BeforeFloat bf = region.getBeforeFloat();
  288. if (bf != null) {
  289. renderBeforeFloat(bf);
  290. }
  291. MainReference mr = region.getMainReference();
  292. if (mr != null) {
  293. renderMainReference(mr);
  294. }
  295. Footnote foot = region.getFootnote();
  296. if (foot != null) {
  297. renderFootnote(foot);
  298. }
  299. }
  300. /**
  301. * Renders a before float area.
  302. *
  303. * @param bf The before float area
  304. */
  305. protected void renderBeforeFloat(BeforeFloat bf) {
  306. List blocks = bf.getChildAreas();
  307. if (blocks != null) {
  308. renderBlocks(null, blocks);
  309. Block sep = bf.getSeparator();
  310. if (sep != null) {
  311. renderBlock(sep);
  312. }
  313. }
  314. }
  315. /**
  316. * Renders a footnote
  317. *
  318. * @param footnote The footnote
  319. */
  320. protected void renderFootnote(Footnote footnote) {
  321. List blocks = footnote.getChildAreas();
  322. if (blocks != null) {
  323. Block sep = footnote.getSeparator();
  324. if (sep != null) {
  325. renderBlock(sep);
  326. }
  327. renderBlocks(null, blocks);
  328. }
  329. }
  330. /**
  331. * Renders the main reference area.
  332. * <p>
  333. * The main reference area contains a list of spans that are
  334. * stacked on the page.
  335. * The spans contain a list of normal flow reference areas
  336. * that are positioned into columns.
  337. * </p>
  338. *
  339. * @param mr The main reference area
  340. */
  341. protected void renderMainReference(MainReference mr) {
  342. int saveIPPos = currentIPPosition;
  343. Span span = null;
  344. List spans = mr.getSpans();
  345. for (int count = 0; count < spans.size(); count++) {
  346. span = (Span) spans.get(count);
  347. int offset = (mr.getWidth()
  348. - (span.getColumnCount() - 1) * mr.getColumnGap())
  349. / span.getColumnCount() + mr.getColumnGap();
  350. for (int c = 0; c < span.getColumnCount(); c++) {
  351. Flow flow = (Flow) span.getFlow(c);
  352. renderFlow(flow);
  353. currentIPPosition += offset;
  354. }
  355. currentIPPosition = saveIPPos;
  356. currentBPPosition += span.getHeight();
  357. }
  358. }
  359. /**
  360. * Renders a flow reference area.
  361. *
  362. * @param flow The flow reference area
  363. */
  364. protected void renderFlow(Flow flow) {
  365. // the normal flow reference area contains stacked blocks
  366. List blocks = flow.getChildAreas();
  367. if (blocks != null) {
  368. renderBlocks(null, blocks);
  369. }
  370. }
  371. /**
  372. * Handle block traits.
  373. * This method is called when the correct ip and bp posiiton is
  374. * set. This should be overridden to draw border and background
  375. * traits for the block area.
  376. *
  377. * @param block the block area
  378. */
  379. protected void handleBlockTraits(Block block) {
  380. // draw border and background
  381. }
  382. /**
  383. * Renders a block viewport.
  384. *
  385. * @param bv The block viewport
  386. * @param children The children to render within the block viewport
  387. */
  388. protected void renderBlockViewport(BlockViewport bv, List children) {
  389. // clip and position viewport if necessary
  390. if (bv.getPositioning() == Block.ABSOLUTE) {
  391. // save positions
  392. int saveIP = currentIPPosition;
  393. int saveBP = currentBPPosition;
  394. CTM ctm = bv.getCTM();
  395. currentIPPosition = 0;
  396. currentBPPosition = 0;
  397. startVParea(ctm);
  398. handleBlockTraits(bv);
  399. renderBlocks(bv, children);
  400. endVParea();
  401. // clip if necessary
  402. currentIPPosition = saveIP;
  403. currentBPPosition = saveBP;
  404. } else {
  405. // save position and offset
  406. int saveIP = currentIPPosition;
  407. int saveBP = currentBPPosition;
  408. handleBlockTraits(bv);
  409. renderBlocks(bv, children);
  410. currentIPPosition = saveIP;
  411. currentBPPosition = saveBP + bv.getHeight();
  412. }
  413. }
  414. /**
  415. * Renders a list of block areas.
  416. *
  417. * @param parent the parent block if the parent is a block, otherwise
  418. * a null value.
  419. * @param blocks The block areas
  420. */
  421. protected void renderBlocks(Block parent, List blocks) {
  422. // the position of the containing block is used for
  423. // absolutely positioned areas
  424. int contBP = currentBPPosition;
  425. int contIP = currentIPPosition;
  426. containingBPPosition = contBP;
  427. containingIPPosition = contIP;
  428. for (int count = 0; count < blocks.size(); count++) {
  429. Object obj = blocks.get(count);
  430. if (obj instanceof Block) {
  431. containingBPPosition = contBP;
  432. containingIPPosition = contIP;
  433. renderBlock((Block) obj);
  434. containingBPPosition = contBP;
  435. containingIPPosition = contIP;
  436. } else {
  437. // a line area is rendered from the top left position
  438. // of the line, each inline object is offset from there
  439. LineArea line = (LineArea) obj;
  440. currentBlockIPPosition =
  441. currentIPPosition + line.getStartIndent();
  442. renderLineArea(line);
  443. currentBPPosition += line.getHeight();
  444. }
  445. }
  446. }
  447. /**
  448. * Renders a block area.
  449. *
  450. * @param block The block area
  451. */
  452. protected void renderBlock(Block block) {
  453. List children = block.getChildAreas();
  454. if (children == null) {
  455. handleBlockTraits(block);
  456. // simply move position
  457. currentBPPosition += block.getHeight();
  458. } else if (block instanceof BlockViewport) {
  459. renderBlockViewport((BlockViewport) block, children);
  460. } else {
  461. // save position and offset
  462. int saveIP = currentIPPosition;
  463. int saveBP = currentBPPosition;
  464. if (block.getPositioning() == Block.ABSOLUTE) {
  465. currentIPPosition = containingIPPosition + block.getXOffset();
  466. currentBPPosition = containingBPPosition + block.getYOffset();
  467. handleBlockTraits(block);
  468. renderBlocks(block, children);
  469. // absolute blocks do not effect the layout
  470. currentBPPosition = saveBP;
  471. } else {
  472. // relative blocks are offset
  473. currentIPPosition += block.getXOffset();
  474. currentBPPosition += block.getYOffset();
  475. handleBlockTraits(block);
  476. renderBlocks(block, children);
  477. // stacked and relative blocks effect stacking
  478. currentBPPosition = saveBP + block.getHeight();
  479. }
  480. currentIPPosition = saveIP;
  481. }
  482. }
  483. /**
  484. * Renders a line area. <p>
  485. *
  486. * A line area may have grouped styling for its children such as underline,
  487. * background.</p>
  488. *
  489. * @param line The line area
  490. */
  491. protected void renderLineArea(LineArea line) {
  492. List children = line.getInlineAreas();
  493. for (int count = 0; count < children.size(); count++) {
  494. InlineArea inline = (InlineArea) children.get(count);
  495. renderInlineArea(inline);
  496. }
  497. }
  498. protected void renderInlineArea(InlineArea inlineArea) {
  499. if (inlineArea instanceof TextArea) {
  500. renderText((TextArea) inlineArea);
  501. } else if (inlineArea instanceof InlineParent) {
  502. renderInlineParent((InlineParent) inlineArea);
  503. } else if (inlineArea instanceof Space) {
  504. renderInlineSpace((Space) inlineArea);
  505. } else if (inlineArea instanceof Character) {
  506. renderCharacter((Character) inlineArea);
  507. } else if (inlineArea instanceof Viewport) {
  508. renderViewport((Viewport) inlineArea);
  509. } else if (inlineArea instanceof Leader) {
  510. renderLeader((Leader) inlineArea);
  511. }
  512. }
  513. /** @see org.apache.fop.render.Renderer */
  514. protected void renderCharacter(Character ch) {
  515. currentBlockIPPosition += ch.getWidth();
  516. }
  517. /** @see org.apache.fop.render.Renderer */
  518. protected void renderInlineSpace(Space space) {
  519. // an inline space moves the inline progression position
  520. // for the current block by the width or height of the space
  521. // it may also have styling (only on this object) that needs
  522. // handling
  523. currentBlockIPPosition += space.getWidth();
  524. }
  525. /** @see org.apache.fop.render.Renderer */
  526. protected void renderLeader(Leader area) {
  527. currentBlockIPPosition += area.getWidth();
  528. }
  529. /** @see org.apache.fop.render.Renderer */
  530. protected void renderText(TextArea text) {
  531. currentBlockIPPosition += text.getWidth();
  532. }
  533. /** @see org.apache.fop.render.Renderer */
  534. protected void renderInlineParent(InlineParent ip) {
  535. int saveIP = currentBlockIPPosition;
  536. Iterator iter = ip.getChildAreas().iterator();
  537. while (iter.hasNext()) {
  538. renderInlineArea((InlineArea) iter.next());
  539. }
  540. currentBlockIPPosition = saveIP + ip.getWidth();
  541. }
  542. /** @see org.apache.fop.render.Renderer */
  543. protected void renderViewport(Viewport viewport) {
  544. Area content = viewport.getContent();
  545. int saveBP = currentBPPosition;
  546. currentBPPosition += viewport.getOffset();
  547. Rectangle2D contpos = viewport.getContentPosition();
  548. if (content instanceof Image) {
  549. renderImage((Image) content, contpos);
  550. } else if (content instanceof Container) {
  551. renderContainer((Container) content);
  552. } else if (content instanceof ForeignObject) {
  553. renderForeignObject((ForeignObject) content, contpos);
  554. }
  555. currentBlockIPPosition += viewport.getWidth();
  556. currentBPPosition = saveBP;
  557. }
  558. /**
  559. * Renders an image area.
  560. *
  561. * @param image The image
  562. * @param pos The target position of the image
  563. * (todo) Make renderImage() protected
  564. */
  565. public void renderImage(Image image, Rectangle2D pos) {
  566. // Default: do nothing.
  567. // Some renderers (ex. Text) don't support images.
  568. }
  569. /** @see org.apache.fop.render.Renderer */
  570. public void renderContainer(Container cont) {
  571. int saveIP = currentIPPosition;
  572. currentIPPosition = currentBlockIPPosition;
  573. int saveBlockIP = currentBlockIPPosition;
  574. int saveBP = currentBPPosition;
  575. List blocks = cont.getBlocks();
  576. renderBlocks(null, blocks);
  577. currentIPPosition = saveIP;
  578. currentBlockIPPosition = saveBlockIP;
  579. currentBPPosition = saveBP;
  580. }
  581. /**
  582. * Renders a foreign object area.
  583. *
  584. * @param fo The foreign object area
  585. * @param pos The target position of the foreign object
  586. * (todo) Make renderForeignObject() protected
  587. */
  588. public void renderForeignObject(ForeignObject fo, Rectangle2D pos) {
  589. // Default: do nothing.
  590. // Some renderers (ex. Text) don't support foreign objects.
  591. }
  592. /**
  593. * Set the default xml handler for the given mime type.
  594. * @param mime MIME type
  595. * @param handler XMLHandler to use
  596. */
  597. public void setDefaultXMLHandler(FOUserAgent foua, String mime,
  598. XMLHandler handler) {
  599. foua.defaults.put(mime, handler);
  600. }
  601. /**
  602. * Add an xml handler for the given mime type and xml namespace.
  603. * @param mime MIME type
  604. * @param ns Namespace URI
  605. * @param handler XMLHandler to use
  606. */
  607. public void addXMLHandler(FOUserAgent foua, String mime, String ns,
  608. XMLHandler handler) {
  609. Map mh = (Map) foua.handlers.get(mime);
  610. if (mh == null) {
  611. mh = new java.util.HashMap();
  612. foua.handlers.put(mime, mh);
  613. }
  614. mh.put(ns, handler);
  615. }
  616. /**
  617. * Render the xml document with the given xml namespace.
  618. * The Render Context is by the handle to render into the current
  619. * rendering target.
  620. * @param ctx rendering context
  621. * @param doc DOM Document containing the source document
  622. * @param namespace Namespace URI of the document
  623. */
  624. public void renderXML(FOUserAgent foua, RendererContext ctx, Document doc,
  625. String namespace) {
  626. String mime = ctx.getMimeType();
  627. Map mh = (Map) foua.handlers.get(mime);
  628. XMLHandler handler = null;
  629. if (mh != null) {
  630. handler = (XMLHandler) mh.get(namespace);
  631. }
  632. if (handler == null) {
  633. handler = (XMLHandler) foua.defaults.get(mime);
  634. }
  635. if (handler != null) {
  636. try {
  637. handler.handleXML(ctx, doc, namespace);
  638. } catch (Throwable t) {
  639. // could not handle document
  640. getLogger().error("Some XML content will be ignored. "
  641. + "Could not render XML", t);
  642. }
  643. } else {
  644. // no handler found for document
  645. getLogger().warn("Some XML content will be ignored. "
  646. + "No handler defined for XML: " + namespace);
  647. }
  648. }
  649. }