Changeset 3240
- Timestamp:
- 02/21/08 18:35:19 (9 months ago)
- Files:
-
- trunk/example/text/xmlsax.d (modified) (3 diffs)
- trunk/tango/text/xml/Sax.d (modified) (52 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/example/text/xmlsax.d
r3236 r3240 25 25 auto content = import ("hamlet.xml"); 26 26 auto parser = new SaxParser!(char); 27 auto handler = new EventsHandler!(char); 28 //auto handler = new LengthHandler!(char); 29 parser.setContentHandler(handler); 27 //auto handler = new EventsHandler!(char); 28 //auto handler = new SaxHandler!(char); 29 auto handler = new LengthHandler!(char); 30 parser.setSaxHandler(handler); 30 31 parser.setContent(content); 31 32 … … 37 38 38 39 39 private class EventsHandler(Ch = char) : ContentHandler!(Ch) {40 private class EventsHandler(Ch = char) : SaxHandler!(Ch) { 40 41 41 42 public uint events; … … 90 91 } 91 92 92 private class LengthHandler(Ch = char) : ContentHandler!(Ch) {93 private class LengthHandler(Ch = char) : SaxHandler!(Ch) { 93 94 94 95 public uint elm; trunk/tango/text/xml/Sax.d
r3236 r3240 71 71 * @version 2.0.1+ (sax2r3pre1) 72 72 * @see org.xml.sax.XMLReader 73 * @see org.xml.sax.DTDHandler74 73 * @see org.xml.sax.ErrorHandler 75 74 *******************************************************************************/ 76 public interface ContentHandler(Ch = char) { 75 public class SaxHandler(Ch = char) { 76 77 Locator!(Ch) locator; 77 78 78 79 /******************************************************************************* … … 103 104 * @see org.xml.sax.Locator 104 105 *******************************************************************************/ 105 public void setDocumentLocator(Locator!(Ch) locator); 106 public void setDocumentLocator(Locator!(Ch) locator) 107 { 108 this.locator = locator; 109 } 106 110 107 111 /******************************************************************************* … … 116 120 * @see #endDocument 117 121 *******************************************************************************/ 118 public void startDocument(); 122 public void startDocument() 123 { 124 125 } 119 126 120 127 /******************************************************************************* … … 139 146 * @see #startDocument 140 147 *******************************************************************************/ 141 public void endDocument(); 148 public void endDocument() 149 { 150 151 } 142 152 143 153 /******************************************************************************* … … 179 189 * @see #startElement 180 190 *******************************************************************************/ 181 public void startPrefixMapping(Ch[] prefix, Ch[] uri); 191 public void startPrefixMapping(Ch[] prefix, Ch[] uri) 192 { 193 194 } 182 195 183 196 /******************************************************************************* … … 197 210 * @see #endElement 198 211 *******************************************************************************/ 199 public void endPrefixMapping(Ch[] prefix); 212 public void endPrefixMapping(Ch[] prefix) 213 { 214 215 } 200 216 201 217 /******************************************************************************* … … 263 279 * @see org.xml.sax.helpers.AttributesImpl 264 280 *******************************************************************************/ 265 public void startElement(Ch[] uri, Ch[] localName, Ch[] qName, Attribute!(Ch)[] atts); 281 public void startElement(Ch[] uri, Ch[] localName, Ch[] qName, Attribute!(Ch)[] atts) 282 { 283 284 } 266 285 267 286 /******************************************************************************* … … 286 305 * wrapping another exception 287 306 *******************************************************************************/ 288 public void endElement(Ch[] uri, Ch[] localName, Ch[] qName); 307 public void endElement(Ch[] uri, Ch[] localName, Ch[] qName) 308 { 309 310 } 289 311 290 312 /******************************************************************************* … … 331 353 * @see org.xml.sax.Locator 332 354 *******************************************************************************/ 333 public void characters(Ch ch[]); 355 public void characters(Ch ch[]) 356 { 357 358 } 334 359 335 360 /******************************************************************************* … … 358 383 * @see #characters 359 384 *******************************************************************************/ 360 public void ignorableWhitespace(Ch ch[]); 385 public void ignorableWhitespace(Ch ch[]) 386 { 387 388 } 361 389 362 390 /******************************************************************************* … … 382 410 * wrapping another exception 383 411 *******************************************************************************/ 384 public void processingInstruction(Ch[] target, Ch[] data); 412 public void processingInstruction(Ch[] target, Ch[] data) 413 { 414 415 } 385 416 386 417 /******************************************************************************* … … 409 440 * wrapping another exception 410 441 *******************************************************************************/ 411 public void skippedEntity(Ch[] name); 412 413 } 414 415 /******************************************************************************* 416 * Empty default implementation of the ContentHandler interface, 417 * meant for easy extension. 418 *******************************************************************************/ 419 class DefaultHandler(Ch = char) : ContentHandler!(Ch) { 420 421 /*********************************************************************** 422 423 ***********************************************************************/ 424 425 public void setDocumentLocator(Locator!(Ch) locator) { 426 } 427 428 /*********************************************************************** 429 430 ***********************************************************************/ 431 432 public void startDocument() { 433 } 434 435 /*********************************************************************** 436 437 ***********************************************************************/ 438 439 public void endDocument() { 440 } 441 442 /*********************************************************************** 443 444 ***********************************************************************/ 445 446 public void startPrefixMapping(Ch[] prefix, Ch[] uri) { 447 } 448 449 /*********************************************************************** 450 451 ***********************************************************************/ 452 453 public void endPrefixMapping(Ch[] prefix) { 454 } 455 456 /*********************************************************************** 457 458 ***********************************************************************/ 459 460 public void startElement(Ch[] uri, Ch[] localName, Ch[] qName, Attribute!(Ch)[] atts) { 461 } 462 463 /*********************************************************************** 464 465 ***********************************************************************/ 466 467 public void endElement(Ch[] uri, Ch[] localName, Ch[] qName) { 468 } 469 470 /*********************************************************************** 471 472 ***********************************************************************/ 473 474 public void characters(Ch ch[]) { 475 } 476 477 /*********************************************************************** 478 479 ***********************************************************************/ 480 481 public void ignorableWhitespace(Ch ch[]) { 482 } 483 484 /*********************************************************************** 485 486 ***********************************************************************/ 487 488 public void processingInstruction(Ch[] target, Ch[] data) { 489 } 490 491 /*********************************************************************** 492 493 ***********************************************************************/ 494 495 public void skippedEntity(Ch[] name) { 496 } 497 498 } 499 500 /******************************************************************************* 501 * Receive notification of basic DTD-related events. 502 * 503 * <blockquote> 504 * <em>This module, both source code and documentation, is in the 505 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> 506 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a> 507 * for further information. 508 * </blockquote> 509 * 510 * <p>If a SAX application needs information about notations and 511 * unparsed entities, then the application implements this 512 * interface and registers an instance with the SAX parser using 513 * the parser's setDTDHandler method. The parser uses the 514 * instance to report notation and unparsed entity declarations to 515 * the application.</p> 516 * 517 * <p>Note that this interface includes only those DTD events that 518 * the XML recommendation <em>requires</em> processors to report: 519 * notation and unparsed entity declarations.</p> 520 * 521 * <p>The SAX parser may report these events in any order, regardless 522 * of the order in which the notations and unparsed entities were 523 * declared; however, all DTD events must be reported after the 524 * document handler's startDocument event, and before the first 525 * startElement event. 526 * (If the {@link org.xml.sax.ext.LexicalHandler LexicalHandler} is 527 * used, these events must also be reported before the endDTD event.) 528 * </p> 529 * 530 * <p>It is up to the application to store the information for 531 * future use (perhaps in a hash table or object tree). 532 * If the application encounters attributes of type "NOTATION", 533 * "ENTITY", or "ENTITIES", it can use the information that it 534 * obtained through this interface to find the entity and/or 535 * notation corresponding with the attribute value.</p> 536 * 537 * @since SAX 1.0 538 * @author David Megginson 539 * @version 2.0.1 (sax2r2) 540 * @see org.xml.sax.XMLReader#setDTDHandler 541 *******************************************************************************/ 542 public interface DTDHandler(Ch = char) { 543 544 /******************************************************************************* 545 * Receive notification of a notation declaration event. 546 * 547 * <p>It is up to the application to record the notation for later 548 * reference, if necessary; 549 * notations may appear as attribute values and in unparsed entity 550 * declarations, and are sometime used with processing instruction 551 * target names.</p> 552 * 553 * <p>At least one of publicId and systemId must be non-null. 554 * If a system identifier is present, and it is a URL, the SAX 555 * parser must resolve it fully before passing it to the 556 * application through this event.</p> 557 * 558 * <p>There is no guarantee that the notation declaration will be 559 * reported before any unparsed entities that use it.</p> 560 * 561 * @param name The notation name. 562 * @param publicId The notation's public identifier, or null if 563 * none was given. 564 * @param systemId The notation's system identifier, or null if 565 * none was given. 566 * @exception org.xml.sax.SAXException Any SAX exception, possibly 567 * wrapping another exception. 568 * @see #unparsedEntityDecl 569 * @see org.xml.sax.Attributes 570 *******************************************************************************/ 571 public void notationDecl(Ch[] name, Ch[] publicId, Ch[] systemId); 572 573 /******************************************************************************* 574 * Receive notification of an unparsed entity declaration event. 575 * 576 * <p>Note that the notation name corresponds to a notation 577 * reported by the {@link #notationDecl notationDecl} event. 578 * It is up to the application to record the entity for later 579 * reference, if necessary; 580 * unparsed entities may appear as attribute values. 581 * </p> 582 * 583 * <p>If the system identifier is a URL, the parser must resolve it 584 * fully before passing it to the application.</p> 585 * 586 * @exception org.xml.sax.SAXException Any SAX exception, possibly 587 * wrapping another exception. 588 * @param name The unparsed entity's name. 589 * @param publicId The entity's public identifier, or null if none 590 * was given. 591 * @param systemId The entity's system identifier. 592 * @param notationName The name of the associated notation. 593 * @see #notationDecl 594 * @see org.xml.sax.Attributes 595 *******************************************************************************/ 596 public void unparsedEntityDecl(Ch[] name, Ch[] publicId, Ch[] systemId, Ch[] notationName); 442 public void skippedEntity(Ch[] name) 443 { 444 445 } 597 446 598 447 } … … 700 549 * Basic interface for SAX error handlers. 701 550 * 702 * <blockquote>703 * <em>This module, both source code and documentation, is in the704 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>705 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>706 * for further information.707 * </blockquote>708 *709 551 * <p>If a SAX application needs to implement customized error 710 552 * handling, it must implement this interface and then register an … … 760 602 * @see org.xml.sax.SAXParseException 761 603 *******************************************************************************/ 762 public void warning(SAXException !(Ch)exception);604 public void warning(SAXException exception); 763 605 764 606 /******************************************************************************* … … 787 629 * @see org.xml.sax.SAXParseException 788 630 *******************************************************************************/ 789 public void error(SAXException !(Ch)exception);631 public void error(SAXException exception); 790 632 791 633 /******************************************************************************* … … 817 659 * @see org.xml.sax.SAXParseException 818 660 *******************************************************************************/ 819 public void fatalError(SAXException !(Ch)exception);661 public void fatalError(SAXException exception); 820 662 821 663 } … … 823 665 /******************************************************************************* 824 666 * Interface for associating a SAX event with a document location. 825 *826 * <blockquote>827 * <em>This module, both source code and documentation, is in the828 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>829 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>830 * for further information.831 * </blockquote>832 667 * 833 668 * <p>If a SAX parser provides location information to the SAX … … 948 783 * Encapsulate a general SAX error or warning. 949 784 * 950 * <blockquote>951 * <em>This module, both source code and documentation, is in the952 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>953 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>954 * for further information.955 * </blockquote>956 *957 785 * <p>This class can contain basic error or warning information from 958 786 * either the XML parser or the application: a parser writer or … … 974 802 * @see org.xml.sax.SAXParseException 975 803 *******************************************************************************/ 976 public class SAXException (Ch = char): Exception {804 public class SAXException : Exception { 977 805 978 806 /******************************************************************************* … … 988 816 * @param message The error or warning message. 989 817 *******************************************************************************/ 990 public this ( Ch[] message) {818 public this (char[] message) { 991 819 super (message, null); 992 820 } … … 1014 842 * @param e The exception to be wrapped in a SAXException. 1015 843 *******************************************************************************/ 1016 public this ( Ch[] message, Exception e) {844 public this (char[] message, Exception e) { 1017 845 super (message, e); 1018 846 } … … 1027 855 * @return The error or warning message. 1028 856 *******************************************************************************/ 1029 public Ch[] message() {857 public char[] message() { 1030 858 if (msg == null && next != null) { 1031 859 return next.msg; … … 1042 870 class SaxParser(Ch = char) : XMLReader!(Ch), Locator!(Ch) { 1043 871 1044 private ContentHandler!(Ch) contentHandler; 1045 private DTDHandler!(Ch) dtdHandler; 872 private SaxHandler!(Ch) saxHandler; 1046 873 private ErrorHandler!(Ch) errorHandler; 1047 874 private EntityResolver!(Ch) entityResolver; … … 1239 1066 1240 1067 /******************************************************************************* 1241 * Allow an application to register a DTD event handler. 1242 * 1243 * <p>If the application does not register a DTD handler, all DTD 1244 * events reported by the SAX parser will be silently ignored.</p> 1068 * Allow an application to register a content event handler. 1069 * 1070 * <p>If the application does not register a content handler, all 1071 * content events reported by the SAX parser will be silently 1072 * ignored.</p> 1245 1073 * 1246 1074 * <p>Applications may register a new or different handler in the … … 1248 1076 * handler immediately.</p> 1249 1077 * 1250 * @param handler The DTD handler.1251 * @see #getDTDHandler1252 *******************************************************************************/1253 public void setDTDHandler(DTDHandler!(Ch) handler) {1254 dtdHandler = handler;1255 }1256 1257 /*******************************************************************************1258 * Return the current DTD handler.1259 *1260 * @return The current DTD handler, or null if none1261 * has been registered.1262 * @see #setDTDHandler1263 *******************************************************************************/1264 public DTDHandler!(Ch) getDTDHandler() {1265 return dtdHandler;1266 }1267 1268 /*******************************************************************************1269 * Allow an application to register a content event handler.1270 *1271 * <p>If the application does not register a content handler, all1272 * content events reported by the SAX parser will be silently1273 * ignored.</p>1274 *1275 * <p>Applications may register a new or different handler in the1276 * middle of a parse, and the SAX parser must begin using the new1277 * handler immediately.</p>1278 *1279 1078 * @param handler The content handler. 1280 1079 * @see #getContentHandler 1281 1080 *******************************************************************************/ 1282 public void set ContentHandler(ContentHandler!(Ch) handler) {1283 contentHandler = handler;1081 public void setSaxHandler(SaxHandler!(Ch) handler) { 1082 saxHandler = handler; 1284 1083 } 1285 1084 … … 1291 1090 * @see #setContentHandler 1292 1091 *******************************************************************************/ 1293 public ContentHandler!(Ch) getContentHandler() {1294 return contentHandler;1092 public SaxHandler!(Ch) getSaxHandler() { 1093 return saxHandler; 1295 1094 } 1296 1095 … … 1367 1166 * @see #parse(java.lang.String) 1368 1167 * @see #setEntityResolver 1369 * @see #setDTDHandler1370 1168 * @see #setContentHandler 1371 1169 * @see #setErrorHandler … … 1442 1240 *******************************************************************************/ 1443 1241 private void doParse() { 1444 contentHandler.setDocumentLocator(this);1445 contentHandler.startDocument();1242 saxHandler.setDocumentLocator(this); 1243 saxHandler.startDocument(); 1446 1244 while (true) { 1447 1245 switch (parser.next) { … … 1459 1257 case XmlTokenType.EndEmptyElement : 1460 1258 doStartElement; 1461 contentHandler.endElement(null, parser.localName, null);1259 saxHandler.endElement(null, parser.localName, null); 1462 1260 break; 1463 1261 case XmlTokenType.Data : 1464 1262 doStartElement; 1465 contentHandler.characters(parser.rawValue);1263 saxHandler.characters(parser.rawValue); 1466 1264 break; 1467 1265 case XmlTokenType.Comment : … … 1477 1275 1478 1276 default: 1479 throw new SAXException !(Ch)("unknown parser token type");1277 throw new SAXException("unknown parser token type"); 1480 1278 } 1481 1279 } 1482 1280 foo: 1483 contentHandler.endDocument();1281 saxHandler.endDocument(); 1484 1282 } 1485 1283 … … 1488 1286 private void doStartElement() { 1489 1287 if (hasStartElement) { 1490 contentHandler.startElement(null, startElemName, null, attributes[0..attrTop]);1288 saxHandler.startElement(null, startElemName, null, attributes[0..attrTop]); 1491 1289 hasStartElement = false; 1492 1290 attrTop = 0; … … 1592 1390 * Interface for an XML filter. 1593 1391 * 1594 * <blockquote>1595 * <em>This module, both source code and documentation, is in the1596 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>1597 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>1598 * for further information.1599 * </blockquote>1600 *1601 1392 * <p>An XML filter is like an XML reader, except that it obtains its 1602 1393 * events from another XML reader rather than a primary source like … … 1649 1440 * Base class for deriving an XML filter. 1650 1441 * 1651 * <blockquote>1652 * <em>This module, both source code and documentation, is in the1653 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>1654 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>1655 * for further information.1656 * </blockquote>1657 *1658 1442 * <p>This class is designed to sit between an {@link org.xml.sax.XMLReader 1659 1443 * XMLReader} and the client application's event handlers. By default, it … … 1669 1453 * @see org.xml.sax.XMLReader 1670 1454 * @see org.xml.sax.EntityResolver 1671 * @see org.xml.sax.DTDHandler1672 1455 * @see org.xml.sax.ContentHandler 1673 1456 * @see org.xml.sax.ErrorHandler 1674 1457 *******************************************************************************/ 1675 public class XMLFilterImpl(Ch = char) : XMLFilter, EntityResolver, DTDHandler, ContentHandler, ErrorHandler {1458 public class XMLFilterImpl(Ch = char) : SaxHandler, XMLFilter, EntityResolver, ErrorHandler { 1676 1459 1677 1460 //////////////////////////////////////////////////////////////////// … … 1846 1629 1847 1630 /******************************************************************************* 1848 * Set the DTD event handler.1849 *1850 * @param handler the new DTD handler1851 *******************************************************************************/1852 public void setDTDHandler(DTDHandler handler) {1853 dtdHandler = handler;1854 }1855 1856 /*******************************************************************************1857 * Get the current DTD event handler.1858 *1859 * @return The current DTD handler, or null if none was set.1860 *******************************************************************************/1861 public DTDHandler getDTDHandler() {1862 return dtdHandler;1863 }1864 1865 /*******************************************************************************1866 1631 * Set the content event handler. 1867 1632 * 1868 1633 * @param handler the new content handler 1869 1634 *******************************************************************************/ 1870 public void set ContentHandler(ContentHandler handler) {1871 contentHandler = handler;1635 public void setSaxHandler(SaxHandler handler) { 1636 saxHandler = handler; 1872 1637 } 1873 1638 … … 1877 1642 * @return The current content handler, or null if none was set. 1878 1643 *******************************************************************************/ 1879 public ContentHandler getContentHandler() {1880 return contentHandler;1644 public SaxHandler getSaxHandler() { 1645 return saxHandler; 1881 1646 } 1882 1647 … … 1975 1740 1976 1741 //////////////////////////////////////////////////////////////////// 1977 // Implementation of org.xml.sax.DTDHandler. 1978 //////////////////////////////////////////////////////////////////// 1979 /******************************************************************************* 1980 * Filter a notation declaration event. 1981 * 1982 * @param name The notation name. 1983 * @param publicId The notation's public identifier, or null. 1984 * @param systemId The notation's system identifier, or null. 1742 // Implementation of org.xml.sax.ContentHandler. 1743 //////////////////////////////////////////////////////////////////// 1744 /******************************************************************************* 1745 * Filter a new document locator event. 1746 * 1747 * @param locator The document locator. 1748 *******************************************************************************/ 1749 public void setDocumentLocator(Locator locator) { 1750 this.locator = locator; 1751 if (saxHandler != null) { 1752 saxHandler.setDocumentLocator(locator); 1753 } 1754 1755 } 1756 1757 /******************************************************************************* 1758 * Filter a start document event. 1759 * 1985 1760 * @exception org.xml.sax.SAXException The client may throw 1986 1761 * an exception during processing. 1987 1762 *******************************************************************************/ 1988 public void notationDecl(Ch[] name, Ch[] publicId, Ch[] systemId) { 1989 if (dtdHandler != null) { 1990 dtdHandler.notationDecl(name, publicId, systemId); 1991 } 1992 1993 } 1994 1995 /******************************************************************************* 1996 * Filter an unparsed entity declaration event. 1997 * 1998 * @param name The entity name. 1999 * @param publicId The entity's public identifier, or null. 2000 * @param systemId The entity's system identifier, or null. 2001 * @param notationName The name of the associated notation. 1763 public void startDocument() { 1764 if (saxHandler != null) { 1765 saxHandler.startDocument(); 1766 } 1767 1768 } 1769 1770 /******************************************************************************* 1771 * Filter an end document event. 1772 * 2002 1773 * @exception org.xml.sax.SAXException The client may throw 2003 1774 * an exception during processing. 2004 1775 *******************************************************************************/ 2005 public void unparsedEntityDecl(Ch[] name, Ch[] publicId, Ch[] systemId, Ch[] notationName) {2006 if (dtdHandler != null) {2007 dtdHandler.unparsedEntityDecl(name, publicId, systemId, notationName);2008 }2009 2010 }2011 2012 ////////////////////////////////////////////////////////////////////2013 // Implementation of org.xml.sax.ContentHandler.2014 ////////////////////////////////////////////////////////////////////2015 /*******************************************************************************2016 * Filter a new document locator event.2017 *2018 * @param locator The document locator.2019 *******************************************************************************/2020 public void setDocumentLocator(Locator locator) {2021 this.locator = locator;2022 if (contentHandler != null) {2023 contentHandler.setDocumentLocator(locator);2024 }2025 2026 }2027 2028 /*******************************************************************************2029 * Filter a start document event.2030 *2031 * @exception org.xml.sax.SAXException The client may throw2032 * an exception during processing.2033 *******************************************************************************/2034 public void startDocument() {2035 if (contentHandler != null) {2036 contentHandler.startDocument();2037 }2038 2039 }2040 2041 /*******************************************************************************2042 * Filter an end document event.2043 *2044 * @exception org.xml.sax.SAXException The client may throw2045 * an exception during processing.2046 *******************************************************************************/2047 1776 public void endDocument() { 2048 if ( contentHandler != null) {2049 contentHandler.endDocument();1777 if (saxHandler != null) { 1778 saxHandler.endDocument(); 2050 1779 } 2051 1780 … … 2061 1790 *******************************************************************************/ 2062 1791 public void startPrefixMapping(Ch[] prefix, Ch[] uri) { 2063 if ( contentHandler != null) {2064 contentHandler.startPrefixMapping(prefix, uri);1792 if (saxHandler != null) { 1793 saxHandler.startPrefixMapping(prefix, uri); 2065 1794 } 2066 1795 … … 2075 1804 *******************************************************************************/ 2076 1805 public void endPrefixMapping(Ch[] prefix) { 2077 if ( contentHandler != null) {2078 contentHandler.endPrefixMapping(prefix);1806 if (saxHandler != null) { 1807 saxHandler.endPrefixMapping(prefix); 2079 1808 } 2080 1809 … … 2093 1822 *******************************************************************************/ 2094 1823 public void startElement(Ch[] uri, Ch[] localName, Ch[] qName, Attribute[] atts) { 2095 if ( contentHandler != null) {2096 contentHandler.startElement(uri, localName, qName, atts);1824 if (saxHandler != null) { 1825 saxHandler.startElement(uri, localName, qName, atts); 2097 1826 } 2098 1827 … … 2110 1839 *******************************************************************************/ 2111 1840 public void endElement(Ch[] uri, Ch[] localName, Ch[] qName) { 2112 if ( contentHandler != null) {2113 contentHandler.endElement(uri, localName, qName);1841 if (saxHandler != null) { 1842 saxHandler.endElement(uri, localName, qName); 2114 1843 } 2115 1844 … … 2124 1853 *******************************************************************************/ 2125 1854 public void characters(Ch ch[]) { 2126 if ( contentHandler != null) {2127 contentHandler.characters(ch);1855 if (saxHandler != null) { 1856 saxHandler.characters(ch); 2128 1857 } 2129 1858 … … 2140 1869 *******************************************************************************/ 2141 1870 public void ignorableWhitespace(Ch ch[]) { 2142 if ( contentHandler != null) {2143 contentHandler.ignorableWhitespace(ch);1871 if (saxHandler != null) { 1872 saxHandler.ignorableWhitespace(ch); 2144 1873 } 2145 1874 … … 2155 1884 *******************************************************************************/ 2156 1885 public void processingInstruction(Ch[] target, Ch[] data) { 2157 if ( contentHandler != null) {2158 contentHandler.processingInstruction(target, data);1886 if (saxHandler != null) { 1887 saxHandler.processingInstruction(target, data); 2159 1888 } 2160 1889 … … 2169 1898 *******************************************************************************/ 2170 1899 public void skippedEntity(Ch[] name) { 2171 if ( contentHandler != null) {2172 contentHandler.skippedEntity(name);1900 if (saxHandler != null) { 1901 saxHandler.skippedEntity(name); 2173 1902 } 2174 1903 … … 2235 1964 } 2236 1965 parent.setEntityResolver(this); 2237 parent.setDTDHandler(this); 2238 parent.setContentHandler(this); 1966 parent.setSaxHandler(this); 2239 1967 parent.setErrorHandler(this); 2240 1968 } … … 2249 1977 private EntityResolver entityResolver = null; 2250 1978 2251 private DTDHandler dtdHandler = null; 2252 2253 private ContentHandler contentHandler = null; 1979 private SaxHandler saxHandler = null; 2254 1980 2255 1981 private ErrorHandler errorHandler = null; … … 2261 1987 /******************************************************************************* 2262 1988 * Interface for reading an XML document using callbacks. 2263 *2264 * <blockquote>2265 * <em>This module, both source code and documentation, is in the2266 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>2267 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>2268 * for further information.2269 * </blockquote>2270 *2271 * <p><strong>Note:</strong> despite its name, this interface does2272 * <em>not</em> extend the standard Java {@link java.io.Reader Reader}2273 * interface, because reading XML is a fundamentally different activity2274 * than reading character data.</p>2275 1989 * 2276 1990 * <p>XMLReader is the interface that an XML parser's SAX2 driver must … … 2477 2191 2478 2192 /******************************************************************************* 2479 * Allow an application to register a DTD event handler. 2480 * 2481 * <p>If the application does not register a DTD handler, all DTD 2482 * events reported by the SAX parser will be silently ignored.</p> 2193 * Allow an application to register a content event handler. 2194 * 2195 * <p>If the application does not register a content handler, all 2196 * content events reported by the SAX parser will be silently 2197 * ignored.</p> 2483 2198 * 2484 2199 * <p>Applications may register a new or different handler in the … … 2486 2201 * handler immediately.</p> 2487 2202 * 2488 * @param handler The DTD handler.2489 * @see #getDTDHandler2490 *******************************************************************************/2491 public void setDTDHandler(DTDHandler!(Ch) handler);2492 2493 /*******************************************************************************2494 * Return the current DTD handler.2495 *2496 * @return The current DTD handler, or null if none2497 * has been registered.2498 * @see #setDTDHandler2499 *******************************************************************************/2500 public DTDHandler!(Ch) getDTDHandler();2501 2502 /*******************************************************************************2503 * Allow an application to register a content event handler.2504 *2505 * <p>If the application does not register a content handler, all2506 * content events reported by the SAX parser will be silently2507 * ignored.</p>2508 *2509 * <p>Applications may register a new or different handler in the2510 * middle of a parse, and the SAX parser must begin using the new2511 * handler immediately.</p>2512 *2513 2203 * @param handler The content handler. 2514 2204 * @see #getContentHandler 2515 2205 *******************************************************************************/ 2516 public void set ContentHandler(ContentHandler!(Ch) handler);2206 public void setSaxHandler(SaxHandler!(Ch) handler); 2517 2207 2518 2208 /******************************************************************************* … … 2523 2213 * @see #setContentHandler 2524 2214 *******************************************************************************/ 2525 public ContentHandler!(Ch) getContentHandler();2215 public SaxHandler!(Ch) getSaxHandler(); 2526 2216 2527 2217 /********************************************************





