Source Code Cross Referenced for XercesParser.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » components » parser » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » apache lenya 2.0 » org.apache.cocoon.components.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.components.parser;
018:
019:        import org.apache.avalon.framework.activity.Disposable;
020:        import org.apache.avalon.framework.component.ComponentException;
021:        import org.apache.avalon.framework.component.ComponentManager;
022:        import org.apache.avalon.framework.component.Composable;
023:        import org.apache.cocoon.components.resolver.Resolver;
024:        import org.apache.cocoon.xml.AbstractXMLProducer;
025:        import org.apache.xerces.dom.DocumentImpl;
026:        import org.apache.xerces.dom.DocumentTypeImpl;
027:        import org.apache.xerces.parsers.DOMParser;
028:        import org.apache.xerces.parsers.SAXParser;
029:        import org.w3c.dom.Document;
030:        import org.xml.sax.ErrorHandler;
031:        import org.xml.sax.InputSource;
032:        import org.xml.sax.SAXException;
033:        import org.xml.sax.SAXParseException;
034:
035:        import java.io.IOException;
036:
037:        /**
038:         *
039:         * @deprecated The Avalon XML Parser is now used inside Cocoon. This role
040:         *             will be removed in future releases.
041:
042:         * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
043:         *         (Apache Software Foundation)
044:         * @version CVS $Id: XercesParser.java 433543 2006-08-22 06:22:54Z crossley $
045:         */
046:        public class XercesParser extends AbstractXMLProducer implements 
047:                Parser, ErrorHandler, Composable, Disposable {
048:
049:            /** the SAX Parser */
050:            final SAXParser parser;
051:
052:            /** the component manager */
053:            protected ComponentManager manager;
054:
055:            /** the Entity Resolver */
056:            protected Resolver resolver = null;
057:
058:            public XercesParser() throws SAXException {
059:                this .parser = new SAXParser();
060:
061:                this .parser.setFeature(
062:                        "http://xml.org/sax/features/validation", false);
063:                this .parser.setFeature(
064:                        "http://xml.org/sax/features/namespaces", true);
065:            }
066:
067:            /**
068:             * Get the Entity Resolver from the component manager
069:             */
070:            public void compose(ComponentManager manager)
071:                    throws ComponentException {
072:                this .manager = manager;
073:                if (getLogger().isDebugEnabled()) {
074:                    getLogger().debug("Looking up " + Resolver.ROLE);
075:                }
076:                if (manager.hasComponent(Resolver.ROLE)) {
077:                    this .resolver = (Resolver) manager.lookup(Resolver.ROLE);
078:                }
079:            }
080:
081:            /**
082:             * Dispose
083:             */
084:            public void dispose() {
085:                if (this .manager != null) {
086:                    this .manager.release(this .resolver);
087:                }
088:            }
089:
090:            public void parse(InputSource in) throws SAXException, IOException {
091:                this .parser.setProperty(
092:                        "http://xml.org/sax/properties/lexical-handler",
093:                        super .lexicalHandler);
094:                this .parser.setErrorHandler(this );
095:                this .parser.setContentHandler(super .contentHandler);
096:                if (this .resolver != null)
097:                    this .parser.setEntityResolver(this .resolver);
098:                this .parser.parse(in);
099:            }
100:
101:            /**
102:             * Create a new Document object.
103:             */
104:            public Document newDocument() {
105:                return (newDocument(null, null, null));
106:            }
107:
108:            /**
109:             * Create a new Document object with a specified DOCTYPE.
110:             */
111:            public Document newDocument(String name) {
112:                return (newDocument(name, null, null));
113:            }
114:
115:            /**
116:             * Create a new Document object with a specified DOCTYPE, public ID and
117:             * system ID.
118:             */
119:            public Document newDocument(String name, String pub, String sys) {
120:                DocumentImpl doc = new DocumentImpl();
121:                if ((pub != null) || (sys != null)) {
122:                    DocumentTypeImpl dtd = new DocumentTypeImpl(doc, name, pub,
123:                            sys);
124:                    doc.appendChild(dtd);
125:                } else if (name != null) {
126:                    DocumentTypeImpl dtd = new DocumentTypeImpl(doc, name);
127:                    doc.appendChild(dtd);
128:                }
129:                return (doc);
130:            }
131:
132:            /**
133:             * Parses a new Document object from the given InputSource.
134:             */
135:            public Document parseDocument(InputSource input)
136:                    throws SAXException, IOException {
137:                DOMParser parser = null;
138:
139:                try {
140:                    parser = new DOMParser();
141:
142:                    parser.setFeature("http://xml.org/sax/features/validation",
143:                            false);
144:                    parser.setFeature("http://xml.org/sax/features/namespaces",
145:                            true);
146:
147:                    parser.parse(input);
148:                } catch (Exception pce) {
149:                    getLogger().error("Could not build DocumentBuilder", pce);
150:                    return null;
151:                }
152:
153:                return parser.getDocument();
154:            }
155:
156:            /**
157:             * Receive notification of a recoverable error.
158:             */
159:            public void error(SAXParseException e) throws SAXException {
160:                throw new SAXException("Error parsing " + e.getSystemId()
161:                        + " (line " + e.getLineNumber() + " col. "
162:                        + e.getColumnNumber() + "): " + e.getMessage(), e);
163:            }
164:
165:            /**
166:             * Receive notification of a fatal error.
167:             */
168:            public void fatalError(SAXParseException e) throws SAXException {
169:                throw new SAXException("Fatal error parsing " + e.getSystemId()
170:                        + " (line " + e.getLineNumber() + " col. "
171:                        + e.getColumnNumber() + "): " + e.getMessage(), e);
172:            }
173:
174:            /**
175:             * Receive notification of a warning.
176:             */
177:            public void warning(SAXParseException e) throws SAXException {
178:                throw new SAXException("Warning parsing " + e.getSystemId()
179:                        + " (line " + e.getLineNumber() + " col. "
180:                        + e.getColumnNumber() + "): " + e.getMessage(), e);
181:            }
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.