cziegeler 2003/01/14 01:39:37 Modified: xmlutil/src/java/org/apache/avalon/excalibur/xml/xslt XSLTProcessorImpl.java xmlutil/src/java/org/apache/excalibur/xml/dom DefaultDOMHandler.java Added: xmlutil/src/java/org/apache/excalibur/xml/dom XMLFragment.java xmlutil/src/java/org/apache/excalibur/xml/sax ContentHandlerWrapper.java XMLizable.java AbstractXMLConsumer.java XercesParser.java Removed: xmlutil/src/java/org/apache/avalon/excalibur/xml XMLConsumer.java EntityResolver.java XMLizable.java JaxpParser.java AbstractXMLConsumer.java Parser.java ContentHandlerWrapper.java XercesParser.java XMLFragment.java Log: Cleaning up xml package Revision Changes Path 1.22 +2 -2 jakarta-avalon-excalibur/xmlutil/src/java/org/apache/avalon/excalibur/xml/xslt/XSLTProcessorImpl.java Index: XSLTProcessorImpl.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/xmlutil/src/java/org/apache/avalon/excalibur/xml/xslt/XSLTProcessorImpl.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- XSLTProcessorImpl.java 14 Jan 2003 07:38:22 -0000 1.21 +++ XSLTProcessorImpl.java 14 Jan 2003 09:39:36 -0000 1.22 @@ -24,7 +24,7 @@ import javax.xml.transform.sax.TemplatesHandler; import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.stream.StreamSource; -import org.apache.avalon.excalibur.xml.XMLizable; +import org.apache.excalibur.xml.sax.XMLizable; import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.component.ComponentException; 1.8 +3 -2 jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xml/dom/DefaultDOMHandler.java Index: DefaultDOMHandler.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xml/dom/DefaultDOMHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DefaultDOMHandler.java 12 Nov 2002 23:35:34 -0000 1.7 +++ DefaultDOMHandler.java 14 Jan 2003 09:39:36 -0000 1.8 @@ -9,7 +9,8 @@ import javax.xml.transform.dom.DOMResult; import javax.xml.transform.sax.TransformerHandler; -import org.apache.avalon.excalibur.xml.ContentHandlerWrapper; + +import org.apache.excalibur.xml.sax.ContentHandlerWrapper; import org.w3c.dom.Document; /** 1.1 jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xml/dom/XMLFragment.java Index: XMLFragment.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.xml.dom; import org.w3c.dom.DOMException; import org.w3c.dom.Node; /** * This interface must be implemented by classes willing * to provide an XML representation of their current state. * <br/> * * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a> for the original XObject class * @version CVS $Revision: 1.1 $ $Date: 2003/01/14 09:39:36 $ */ public interface XMLFragment { /** * Appends children representing the object's state to the given node. */ void toDOM( Node node ) throws DOMException; } 1.1 jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xml/sax/ContentHandlerWrapper.java Index: ContentHandlerWrapper.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.xml.sax; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; import org.xml.sax.ext.LexicalHandler; /** * This class is an utility class "wrapping" around a SAX version 2.0 * [EMAIL PROTECTED] ContentHandler} and forwarding it those events received throug * its [EMAIL PROTECTED] XMLConsumer}s interface. * <br> * * @deprecated Moved to org.apache.excalibur.xml.sax package. Modified to be * thread safe. * @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a> * (Apache Software Foundation, Computer Associates) * @version CVS $Revision: 1.1 $ $Date: 2003/01/14 09:39:37 $ */ public class ContentHandlerWrapper extends AbstractXMLConsumer { /** The current [EMAIL PROTECTED] ContentHandler}. */ private ContentHandler m_contentHandler; /** The optional [EMAIL PROTECTED] LexicalHandler} */ private LexicalHandler m_lexicalHandler; /** * Create a new <code>ContentHandlerWrapper</code> instance. */ public ContentHandlerWrapper() { } /** * Create a new <code>ContentHandlerWrapper</code> instance. */ public ContentHandlerWrapper( final ContentHandler contentHandler ) { setContentHandler( contentHandler ); } /** * Create a new <code>ContentHandlerWrapper</code> instance. */ public ContentHandlerWrapper( final ContentHandler contentHandler, final LexicalHandler lexicalHandler ) { setContentHandler( contentHandler ); setLexicalHandler( lexicalHandler ); } /** * Set the [EMAIL PROTECTED] ContentHandler} that will receive XML data. * * @exception IllegalStateException If the [EMAIL PROTECTED] ContentHandler} * was already set. */ public void setContentHandler( final ContentHandler contentHandler ) throws IllegalStateException { if( null != m_contentHandler ) { throw new IllegalStateException(); } m_contentHandler = contentHandler; } /** * Set the [EMAIL PROTECTED] LexicalHandler} that will receive XML data. * * @exception IllegalStateException If the [EMAIL PROTECTED] LexicalHandler} * was already set. */ public void setLexicalHandler( final LexicalHandler lexicalHandler ) throws IllegalStateException { if( null != m_lexicalHandler ) { throw new IllegalStateException(); } m_lexicalHandler = lexicalHandler; } /** * Receive an object for locating the origin of SAX document events. */ public void setDocumentLocator( final Locator locator ) { if( null == m_contentHandler ) { return; } else { m_contentHandler.setDocumentLocator( locator ); } } /** * Receive notification of the beginning of a document. */ public void startDocument() throws SAXException { if( null == m_contentHandler ) { final String message = "ContentHandler not set"; throw new SAXException( message ); } m_contentHandler.startDocument(); } /** * Receive notification of the end of a document. */ public void endDocument() throws SAXException { m_contentHandler.endDocument(); } /** * Begin the scope of a prefix-URI Namespace mapping. */ public void startPrefixMapping( final String prefix, final String uri ) throws SAXException { if( null == m_contentHandler ) { final String message = "ContentHandler not set"; throw new SAXException( message ); } m_contentHandler.startPrefixMapping( prefix, uri ); } /** * End the scope of a prefix-URI mapping. */ public void endPrefixMapping( final String prefix ) throws SAXException { m_contentHandler.endPrefixMapping( prefix ); } /** * Receive notification of the beginning of an element. */ public void startElement( final String uri, final String loc, final String raw, final Attributes a ) throws SAXException { m_contentHandler.startElement( uri, loc, raw, a ); } /** * Receive notification of the end of an element. */ public void endElement( final String uri, final String loc, final String raw ) throws SAXException { m_contentHandler.endElement( uri, loc, raw ); } /** * Receive notification of character data. */ public void characters( final char[] ch, final int start, final int len ) throws SAXException { m_contentHandler.characters( ch, start, len ); } /** * Receive notification of ignorable whitespace in element content. */ public void ignorableWhitespace( final char[] ch, final int start, final int len ) throws SAXException { m_contentHandler.ignorableWhitespace( ch, start, len ); } /** * Receive notification of a processing instruction. */ public void processingInstruction( final String target, final String data ) throws SAXException { m_contentHandler.processingInstruction( target, data ); } /** * Receive notification of a skipped entity. * * @param name The name of the skipped entity. If it is a parameter * entity, the name will begin with '%'. */ public void skippedEntity( final String name ) throws SAXException { m_contentHandler.skippedEntity( name ); } /** * Report the start of DTD declarations, if any. * * @param name The document type name. * @param publicId The declared public identifier for the external DTD * subset, or null if none was declared. * @param systemId The declared system identifier for the external DTD * subset, or null if none was declared. */ public void startDTD( final String name, final String publicId, final String systemId ) throws SAXException { if( null != m_lexicalHandler ) { m_lexicalHandler.startDTD( name, publicId, systemId ); } } /** * Report the end of DTD declarations. */ public void endDTD() throws SAXException { if( null != m_lexicalHandler ) { m_lexicalHandler.endDTD(); } } /** * Report the beginning of an entity. * * @param name The name of the entity. If it is a parameter entity, the * name will begin with '%'. */ public void startEntity( final String name ) throws SAXException { if( null != m_lexicalHandler ) { m_lexicalHandler.startEntity( name ); } } /** * Report the end of an entity. * * @param name The name of the entity that is ending. */ public void endEntity( final String name ) throws SAXException { if( null != m_lexicalHandler ) { m_lexicalHandler.endEntity( name ); } } /** * Report the start of a CDATA section. */ public void startCDATA() throws SAXException { if( null != m_lexicalHandler ) { m_lexicalHandler.startCDATA(); } } /** * Report the end of a CDATA section. */ public void endCDATA() throws SAXException { if( null != m_lexicalHandler ) { m_lexicalHandler.endCDATA(); } } /** * Report an XML comment anywhere in the document. * * @param ch An array holding the characters in the comment. * @param start The starting position in the array. * @param len The number of characters to use from the array. */ public void comment( final char[] ch, final int start, final int len ) throws SAXException { if( null != m_lexicalHandler ) { m_lexicalHandler.comment( ch, start, len ); } } } 1.1 jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xml/sax/XMLizable.java Index: XMLizable.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.xml.sax; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** * This interface can be implemented by classes willing to provide an XML representation * of their current state as SAX events. * * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @version CVS $Revision: 1.1 $ $Date: 2003/01/14 09:39:37 $ */ public interface XMLizable { /** * Generates SAX events representing the object's state. * <b>NOTE</b> : if the implementation can produce lexical events, care should be taken * that <code>handler</code> can actually be a [EMAIL PROTECTED] XMLConsumer} that accepts such * events or directly implements the LexicalHandler interface! */ void toSAX( ContentHandler handler ) throws SAXException; } 1.1 jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xml/sax/AbstractXMLConsumer.java Index: AbstractXMLConsumer.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.xml.sax; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.SAXException; /** * This abstract class provides default implementation of the methods specified * by the <code>XMLConsumer</code> interface. * * @deprecated Can be constructed using no operation handlers. * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a> * (Apache Software Foundation, Exoffice Technologies) * @version CVS $Revision: 1.1 $ $Date: 2003/01/14 09:39:37 $ */ public abstract class AbstractXMLConsumer extends AbstractLogEnabled implements XMLConsumer { /** * Receive an object for locating the origin of SAX document events. * * @param locator An object that can return the location of any SAX * document event. */ public void setDocumentLocator( final Locator locator ) { } /** * Receive notification of the beginning of a document. */ public void startDocument() throws SAXException { } /** * Receive notification of the end of a document. */ public void endDocument() throws SAXException { } /** * Begin the scope of a prefix-URI Namespace mapping. * * @param prefix The Namespace prefix being declared. * @param uri The Namespace URI the prefix is mapped to. */ public void startPrefixMapping( final String prefix, final String uri ) throws SAXException { } /** * End the scope of a prefix-URI mapping. * * @param prefix The prefix that was being mapping. */ public void endPrefixMapping( final String prefix ) throws SAXException { } /** * Receive notification of the beginning of an element. * * @param uri The Namespace URI, or the empty string if the element has no * Namespace URI or if Namespace * processing is not being performed. * @param loc The local name (without prefix), or the empty string if * Namespace processing is not being performed. * @param raw The raw XML 1.0 name (with prefix), or the empty string if * raw names are not available. * @param a The attributes attached to the element. If there are no * attributes, it shall be an empty Attributes object. */ public void startElement( final String uri, final String loc, final String raw, final Attributes a ) throws SAXException { } /** * Receive notification of the end of an element. * * @param uri The Namespace URI, or the empty string if the element has no * Namespace URI or if Namespace * processing is not being performed. * @param loc The local name (without prefix), or the empty string if * Namespace processing is not being performed. * @param raw The raw XML 1.0 name (with prefix), or the empty string if * raw names are not available. */ public void endElement( final String uri, final String loc, final String raw ) throws SAXException { } /** * Receive notification of character data. * * @param ch The characters from the XML document. * @param start The start position in the array. * @param len The number of characters to read from the array. */ public void characters( final char[] ch, final int start, final int len ) throws SAXException { } /** * Receive notification of ignorable whitespace in element content. * * @param ch The characters from the XML document. * @param start The start position in the array. * @param len The number of characters to read from the array. */ public void ignorableWhitespace( final char[] ch, final int start, final int len ) throws SAXException { } /** * Receive notification of a processing instruction. * * @param target The processing instruction target. * @param data The processing instruction data, or null if none was * supplied. */ public void processingInstruction( final String target, final String data ) throws SAXException { } /** * Receive notification of a skipped entity. * * @param name The name of the skipped entity. If it is a parameter * entity, the name will begin with '%'. */ public void skippedEntity( final String name ) throws SAXException { } /** * Report the start of DTD declarations, if any. * * @param name The document type name. * @param publicId The declared public identifier for the external DTD * subset, or null if none was declared. * @param systemId The declared system identifier for the external DTD * subset, or null if none was declared. */ public void startDTD( final String name, final String publicId, final String systemId ) throws SAXException { } /** * Report the end of DTD declarations. */ public void endDTD() throws SAXException { } /** * Report the beginning of an entity. * * @param name The name of the entity. If it is a parameter entity, the * name will begin with '%'. */ public void startEntity( final String name ) throws SAXException { } /** * Report the end of an entity. * * @param name The name of the entity that is ending. */ public void endEntity( final String name ) throws SAXException { } /** * Report the start of a CDATA section. */ public void startCDATA() throws SAXException { } /** * Report the end of a CDATA section. */ public void endCDATA() throws SAXException { } /** * Report an XML comment anywhere in the document. * * @param ch An array holding the characters in the comment. * @param start The starting position in the array. * @param len The number of characters to use from the array. */ public void comment( final char[] ch, final int start, final int len ) throws SAXException { } } 1.1 jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xml/sax/XercesParser.java Index: XercesParser.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.xml.sax; import java.io.IOException; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.xerces.dom.DocumentImpl; import org.apache.xerces.parsers.DOMParser; import org.apache.xerces.parsers.SAXParser; import org.w3c.dom.Document; import org.xml.sax.ContentHandler; import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.ext.LexicalHandler; /** * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a> * (Apache Software Foundation, Exoffice Technologies) * @version CVS $Revision: 1.1 $ $Date: 2003/01/14 09:39:37 $ */ public final class XercesParser extends AbstractLogEnabled implements Parser, org.apache.excalibur.xml.dom.Parser, ErrorHandler, ThreadSafe, Initializable { public void initialize() throws Exception { final String message = "WARNING: XercesParser has been deprecated in favour of " + "JaxpParser. Please use JaxpParser unless it is incompatible" + "with your environment"; getLogger().warn( message ); } public void parse( final InputSource in, final ContentHandler consumer ) throws SAXException, IOException { if( consumer instanceof LexicalHandler ) { parse( in, consumer, (LexicalHandler)consumer ); } else { parse( in, consumer, null ); } } /** * Parse the [EMAIL PROTECTED] InputSource} and send * SAX events to the content handler and * the lexical handler. */ public void parse( final InputSource in, final ContentHandler contentHandler, final LexicalHandler lexicalHandler ) throws SAXException, IOException { final SAXParser parser = createSAXParser(); if( null != lexicalHandler ) { parser.setProperty( "http://xml.org/sax/properties/lexical-handler", lexicalHandler ); } parser.setErrorHandler( this ); parser.setContentHandler( contentHandler ); parser.parse( in ); } /** * Parses a new Document object from the given [EMAIL PROTECTED] InputSource}. */ public Document parseDocument( final InputSource input ) throws SAXException, IOException { try { final DOMParser parser = new DOMParser(); parser.setFeature( "http://xml.org/sax/features/validation", false ); parser.setFeature( "http://xml.org/sax/features/namespaces", true ); parser.setFeature( "http://xml.org/sax/features/namespace-prefixes", true ); parser.parse( input ); return parser.getDocument(); } catch( final Exception e ) { final String message = "Could not build DocumentBuilder"; getLogger().error( message, e ); return null; } } /** * Return a new [EMAIL PROTECTED] Document}. */ public Document createDocument() throws SAXException { return new DocumentImpl(); } /** * Receive notification of a recoverable error. */ public void error( final SAXParseException spe ) throws SAXException { final String message = "Error parsing " + spe.getSystemId() + " (line " + spe.getLineNumber() + " col. " + spe.getColumnNumber() + "): " + spe.getMessage(); throw new SAXException( message, spe ); } /** * Receive notification of a fatal error. */ public void fatalError( final SAXParseException spe ) throws SAXException { final String message = "Fatal error parsing " + spe.getSystemId() + " (line " + spe.getLineNumber() + " col. " + spe.getColumnNumber() + "): " + spe.getMessage(); throw new SAXException( message, spe ); } /** * Receive notification of a warning. */ public void warning( final SAXParseException spe ) throws SAXException { final String message = "Warning parsing " + spe.getSystemId() + " (line " + spe.getLineNumber() + " col. " + spe.getColumnNumber() + "): " + spe.getMessage(); throw new SAXException( message, spe ); } /** * Utility method to create a SAXParser. * * @return new SAXParser * @throws SAXException if unable to create parser */ private SAXParser createSAXParser() throws SAXException { final SAXParser parser = new SAXParser(); parser.setFeature( "http://xml.org/sax/features/validation", false ); parser.setFeature( "http://xml.org/sax/features/namespaces", true ); parser.setFeature( "http://xml.org/sax/features/namespace-prefixes", true ); return parser; } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>