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.

parsing.xml 4.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  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. <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN" "http://forrest.apache.org/dtd/document-v13.dtd">
  18. <document>
  19. <header>
  20. <title>Apache™ FOP Design: Input Parsing</title>
  21. <version>$Revision$</version>
  22. </header>
  23. <body>
  24. <section id="intro">
  25. <title>Introduction</title>
  26. <p>Parsing is the process of reading the XSL-FO input and making the information in it available to Apache™ FOP.</p>
  27. </section>
  28. <section id="input">
  29. <title>SAX for Input</title>
  30. <p>The two standard ways of dealing with XML input are SAX and DOM.
  31. SAX basically creates events as it parses an XML document in a serial fashion; a program using SAX (and not storing anything internally) will only see a small window of the document at any point in time, and can never look forward in the document.
  32. DOM creates and stores a tree representation of the document, allowing a view of the entire document as an integrated whole.
  33. One issue that may seem counter-intuitive to some new FOP developers, and which has from time to time been contentious, is that FOP uses SAX for input.
  34. (DOM can be used as input as well, but it is converted into SAX events before entering FOP, effectively negating its advantages).</p>
  35. <p>Since FOP essentially needs a tree representation of the FO input, at first glance it seems to make sense to use DOM.
  36. Instead, FOP takes SAX events and builds its own tree-like structure. Why?</p>
  37. <ul>
  38. <li>DOM has a relatively large memory footprint. FOP's FO Tree is a lighter-weight structure.</li>
  39. <li>DOM contains an entire document. FOP is able to process individual fo:page-sequence objects discretely, without the need to have the entire document in memory. For documents that have only one fo:page-sequence object, FOP's approach is no advantage, but in other cases it is a huge advantage. A 500-page book that is broken into 100 5-page chapters, each in its own fo:page-sequence, essentially needs only 1% of the document memory that would be required if using DOM as input.</li>
  40. </ul>
  41. <p>See the <link href="../../trunk/embedding.html#input">Input Section of the User Embedding Document</link> for a discussion of input usage patterns and some implementation details.</p>
  42. <p>FOP's <link href="fotree.html">FO Tree Mechanism</link> is responsible for catching the SAX events and processing them.</p>
  43. </section>
  44. <section id="validation">
  45. <title>Validation</title>
  46. <p>If the input XML is not well-formed, that will be reported.</p>
  47. <p>There is no DTD for XSL-FO, so no formal validation is possible at the parser level.</p>
  48. <p>The SAX handler will report an error for unrecognized <link href="#namespaces">namespaces</link>.</p>
  49. </section>
  50. <section id="namespaces">
  51. <title>Namespaces</title>
  52. <p>To allow for extensions to the XSL-FO language, FOP provides a mechanism for handling foreign namespaces.</p>
  53. <p>See <link href="../../trunk/extensions.html">User Extensions</link> for a discussion of standard extensions shipped with FOP, and their related namespaces.</p>
  54. <p>See <link href="../extensions.html">Developer Extensions</link> for a discussion of the mechanisms in place to allow developers to add their own extensions, including how to tell FOP about the foreign namespace.</p>
  55. </section>
  56. <section id="status">
  57. <title>Status</title>
  58. <section id="status-todo">
  59. <title>To Do</title>
  60. </section>
  61. <section id="status-wip">
  62. <title>Work In Progress</title>
  63. </section>
  64. <section id="status-complete">
  65. <title>Completed</title>
  66. <ul>
  67. <li>better handling of unknown xml and xml from an unknown namespace</li>
  68. <li>Changed extensions to allow for external xml</li>
  69. <li>Can have a default element mapping for extensions</li>
  70. </ul>
  71. </section>
  72. </section>
  73. </body>
  74. </document>