xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From el...@apache.org
Subject cvs commit: xml-xerces/java/src/org/apache/xerces/parsers AbstractDOMParser.java
Date Tue, 10 Feb 2004 17:25:28 GMT
elena       2004/02/10 09:25:28

  Modified:    java/src/org/apache/xml/serialize HTMLSerializer.java
                        HTMLdtd.java DOMSerializerImpl.java
                        XMLSerializer.java
               java/src/org/apache/xerces/impl/msg
                        XMLSerializerMessages.properties
                        DOMMessages.properties
               java/src/org/apache/xerces/dom AttrImpl.java
                        PSVIDOMImplementationImpl.java
                        CoreDocumentImpl.java DOMNormalizer.java
               java/src/org/apache/xerces/parsers AbstractDOMParser.java
  Log:
  Commit the patch from Neil Delima:
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26812
  
  Revision  Changes    Path
  1.25      +11 -3     xml-xerces/java/src/org/apache/xml/serialize/HTMLSerializer.java
  
  Index: HTMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xml/serialize/HTMLSerializer.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- HTMLSerializer.java	10 Dec 2003 18:25:11 -0000	1.24
  +++ HTMLSerializer.java	10 Feb 2004 17:25:26 -0000	1.25
  @@ -73,6 +73,7 @@
   
   package org.apache.xml.serialize;
   
  +import org.apache.xerces.dom.DOMMessageFormatter;
   
   import java.io.IOException;
   import java.io.OutputStream;
  @@ -240,7 +241,10 @@
   
           try {
               if ( _printer == null )
  -                throw new IllegalStateException( "SER002 No writer supplied for serializer"
);
  +            	throw new IllegalStateException( 
  +				    DOMMessageFormatter.formatMessage(
  +				    DOMMessageFormatter.SERIALIZER_DOMAIN,
  +                    "NoWriterSupplied", null));
   
               state = getElementState();
               if ( isDocumentState() ) {
  @@ -508,7 +512,11 @@
   
           try {
               if ( _printer == null )
  -                throw new IllegalStateException( "SER002 No writer supplied for serializer"
);
  +                throw new IllegalStateException( 
  +				    DOMMessageFormatter.formatMessage(
  +				    DOMMessageFormatter.SERIALIZER_DOMAIN,
  +                    "NoWriterSupplied", null));
  +
   
               state = getElementState();
               if ( isDocumentState() ) {
  
  
  
  1.17      +12 -5     xml-xerces/java/src/org/apache/xml/serialize/HTMLdtd.java
  
  Index: HTMLdtd.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xml/serialize/HTMLdtd.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- HTMLdtd.java	10 Dec 2003 17:14:17 -0000	1.16
  +++ HTMLdtd.java	10 Feb 2004 17:25:26 -0000	1.17
  @@ -63,6 +63,7 @@
   
   package org.apache.xml.serialize;
   
  +import org.apache.xerces.dom.DOMMessageFormatter;
   
   import java.io.InputStream;
   import java.io.InputStreamReader;
  @@ -412,8 +413,12 @@
               _byName = new Hashtable();
               _byChar = new Hashtable();
               is = HTMLdtd.class.getResourceAsStream( ENTITIES_RESOURCE );
  -            if ( is == null )
  -                throw new RuntimeException( "SER003 The resource [" + ENTITIES_RESOURCE
+ "] could not be found.\n" + ENTITIES_RESOURCE);
  +            if ( is == null ) {
  +            	throw new RuntimeException( 
  +				    DOMMessageFormatter.formatMessage(
  +				    DOMMessageFormatter.SERIALIZER_DOMAIN,
  +                    "ResourceNotFound", new Object[] {ENTITIES_RESOURCE}));
  +            }    
               reader = new BufferedReader( new InputStreamReader( is, "ASCII" ) );
               line = reader.readLine();
               while ( line != null ) {
  @@ -438,8 +443,10 @@
               }
               is.close();
           }  catch ( Exception except ) {
  -            throw new RuntimeException( "SER003 The resource [" + ENTITIES_RESOURCE + "]
could not load: " +
  -                                        except.toString() + "\n" + ENTITIES_RESOURCE +
"\t" + except.toString());
  +			throw new RuntimeException( 
  +				DOMMessageFormatter.formatMessage(
  +				DOMMessageFormatter.SERIALIZER_DOMAIN,
  +                "ResourceNotLoaded", new Object[] {ENTITIES_RESOURCE, except.toString()}));
       	
           } finally {
               if ( is != null ) {
                   try {
  
  
  
  1.16      +11 -4     xml-xerces/java/src/org/apache/xml/serialize/DOMSerializerImpl.java
  
  Index: DOMSerializerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xml/serialize/DOMSerializerImpl.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DOMSerializerImpl.java	30 Jan 2004 00:16:50 -0000	1.15
  +++ DOMSerializerImpl.java	10 Feb 2004 17:25:26 -0000	1.16
  @@ -105,7 +105,7 @@
   
   
   /**
  - * Implemenatation of DOM Level 3 org.w3c.ls.LSSerializer  by delegating serialization
  + * EXPERIMENTAL: Implemenatation of DOM Level 3 org.w3c.ls.LSSerializer  by delegating
serialization
    * calls to <CODE>XMLSerializer</CODE>.
    * LSSerializer provides an API for serializing (writing) a DOM document out in an
    * XML document. The XML data is written to an output stream.
  @@ -742,7 +742,10 @@
                               error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
                               ser.fDOMErrorHandler.handleError(error);
                           }
  -                        throw new LSException(LSException.SERIALIZE_ERR, "no-output-specified");
  +                        throw new LSException(LSException.SERIALIZE_ERR, 
  +                            DOMMessageFormatter.formatMessage(
  +                                DOMMessageFormatter.SERIALIZER_DOMAIN, 
  +                                "no-output-specified", null));
                       }
                       else {
                           // URI was specified. Handle relative URIs.
  @@ -804,7 +807,11 @@
   				error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
                   ser.fDOMErrorHandler.handleError(error);
   			}
  -			return false;
  +            throw new LSException(LSException.SERIALIZE_ERR, 
  +                DOMMessageFormatter.formatMessage(
  +                    DOMMessageFormatter.SERIALIZER_DOMAIN, 
  +                    "unsupported-encoding", null));			
  +			//return false;
           } catch (RuntimeException e) {
               if (e == DOMNormalizer.abort){
                   // stopped at user request
  
  
  
  1.57      +24 -11    xml-xerces/java/src/org/apache/xml/serialize/XMLSerializer.java
  
  Index: XMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xml/serialize/XMLSerializer.java,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- XMLSerializer.java	29 Jan 2004 21:11:30 -0000	1.56
  +++ XMLSerializer.java	10 Feb 2004 17:25:27 -0000	1.57
  @@ -790,12 +790,16 @@
   
                       if (value.equals(NamespaceContext.XMLNS_URI)) {
                           if (fDOMErrorHandler != null) {
  -                            modifyDOMError("No prefix other than 'xmlns' can be bound to
'http://www.w3.org/2000/xmlns/' namespace name", 
  -                                           DOMError.SEVERITY_ERROR, attr);
  +                            String msg = DOMMessageFormatter.formatMessage(
  +                                DOMMessageFormatter.XML_DOMAIN,"CantBindXMLNS",null );
  +                            modifyDOMError(msg,  DOMError.SEVERITY_ERROR, attr);
                               boolean continueProcess = fDOMErrorHandler.handleError(fDOMError);
                               if (!continueProcess) {
                                   // stop the namespace fixup and validation
  -                                throw new RuntimeException("Stopped at user request");
  +            	                throw new RuntimeException( 
  +            	                    DOMMessageFormatter.formatMessage(
  +            	                    DOMMessageFormatter.SERIALIZER_DOMAIN,
  +            	                    "SerializationStopped", null));
                               }
                           }
                       } else {
  @@ -900,13 +904,17 @@
                   if (elem.getLocalName() == null) {
                       //  DOM Level 1 node!
                       if (fDOMErrorHandler != null) {
  -                        // REVISIT: MSG modify error message
  -                        modifyDOMError("DOM Level 1 Node: "+elem.getNodeName(), 
  -                                           DOMError.SEVERITY_ERROR, elem);
  +                        String msg = DOMMessageFormatter.formatMessage(
  +                            DOMMessageFormatter.DOM_DOMAIN, "NullLocalElementName", 
  +                            new Object[]{elem.getNodeName()});
  +                        modifyDOMError(msg,DOMError.SEVERITY_ERROR, elem);
                           boolean continueProcess = fDOMErrorHandler.handleError(fDOMError);
                           // REVISIT: should we terminate upon request?
                           if (!continueProcess) {
  -                            throw new RuntimeException("Process stoped at user request");
  +                           throw new RuntimeException( 
  +            	               DOMMessageFormatter.formatMessage(
  +            	               DOMMessageFormatter.SERIALIZER_DOMAIN,
  +            	               "SerializationStopped", null));
                           }
                       }
                   } else { // uri=null and no colon (DOM L2 node)
  @@ -1057,12 +1065,17 @@
                   } else { // attribute uri == null
                       if (attr.getLocalName() == null) {
                           if (fDOMErrorHandler != null) {
  -                            modifyDOMError("DOM Level 1 Node: "+name, 
  -                                           DOMError.SEVERITY_ERROR, attr);
  +                            String msg = DOMMessageFormatter.formatMessage(
  +                                DOMMessageFormatter.DOM_DOMAIN, 
  +                                "NullLocalAttrName", new Object[]{attr.getNodeName()});
                           
  +                            modifyDOMError(msg, DOMError.SEVERITY_ERROR, attr);
                               boolean continueProcess = fDOMErrorHandler.handleError(fDOMError);
                               if (!continueProcess) {
                                   // stop the namespace fixup and validation
  -                                throw new RuntimeException("Stopped at user request");
  +                                throw new RuntimeException( 
  +            	                   DOMMessageFormatter.formatMessage(
  +            	                   DOMMessageFormatter.SERIALIZER_DOMAIN,
  +            	                   "SerializationStopped", null));
                               }
                           }
                           printAttribute (name, value, attr.getSpecified());
  
  
  
  1.2       +8 -1      xml-xerces/java/src/org/apache/xerces/impl/msg/XMLSerializerMessages.properties
  
  Index: XMLSerializerMessages.properties
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/msg/XMLSerializerMessages.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLSerializerMessages.properties	17 Jul 2002 18:36:58 -0000	1.1
  +++ XMLSerializerMessages.properties	10 Feb 2004 17:25:27 -0000	1.2
  @@ -20,3 +20,10 @@
       InvalidNSDecl = Namespace declaration syntax is incorrect: {0}.
       EndingCDATA = The character sequence \"]]>\" must not appear in content unless used
to mark the end of a CDATA section.
       SplittingCDATA = Splitting a CDATA section containing the CDATA section termination
marker \"]]>\".
  +    ResourceNotFound = The resource ''{0}'' could not be found.
  +    ResourceNotLoaded = The resource ''{0}'' could not be loaded. {1}
  +    SerializationStopped =  Serialization stopped at user request.
  +
  +	#DOM Level 3 load and save messages
  +	no-output-specified = no-output-specified: The output destination for data to be written
to was null.
  +	unsupported-encoding = unsupported-encoding: An unsupported encoding is encountered. 
  
  
  
  1.7       +5 -2      xml-xerces/java/src/org/apache/xerces/impl/msg/DOMMessages.properties
  
  Index: DOMMessages.properties
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/msg/DOMMessages.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DOMMessages.properties	23 Jan 2004 20:05:46 -0000	1.6
  +++ DOMMessages.properties	10 Feb 2004 17:25:27 -0000	1.7
  @@ -45,12 +45,15 @@
   NullLocalElementName = A null local name was encountered during namespace normalization
of element {0}.
   NullLocalAttrName = A null local name was encountered during namespace normalization of
attribute {0}.
   
  +#Error codes used in DOMParser
  +InvalidDocumentClassName = The class name of the document factory \"{0}\" used to construct
the DOM tree is not of type org.w3c.dom.Document.
  +MissingDocumentClassName = The class name of the document factory \"{0}\" used to construct
the DOM tree could not be found.
  +
   #Ranges
   BAD_BOUNDARYPOINTS_ERR = The boundary-points of a Range do not meet specific requirements.
   INVALID_NODE_TYPE_ERR = The container of a boundary-point of a Range is being set to either
a node of an invalid type or a node with an ancestor of an invalid type.
   
   
   #Events
  -
   UNSPECIFIED_EVENT_TYPE_ERR = The Event's type was not specified by initializing the event
before the method was called. 
   
  
  
  
  1.54      +3 -3      xml-xerces/java/src/org/apache/xerces/dom/AttrImpl.java
  
  Index: AttrImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/AttrImpl.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- AttrImpl.java	13 Nov 2003 22:47:14 -0000	1.53
  +++ AttrImpl.java	10 Feb 2004 17:25:27 -0000	1.54
  @@ -910,8 +910,8 @@
           // Tail-call, should be optimizable
           if (hasStringValue()) {
               // we don't have any child per say so it can't be one of them!
  -            throw new DOMException(DOMException.NOT_FOUND_ERR, 
  -                                   "DOM008 Not found");
  +            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"NOT_FOUND_ERR", null);
  +            throw new DOMException(DOMException.NOT_FOUND_ERR, msg);            
           }
           return internalRemoveChild(oldChild, false);
       } // removeChild(Node) :Node
  
  
  
  1.4       +4 -2      xml-xerces/java/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java
  
  Index: PSVIDOMImplementationImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PSVIDOMImplementationImpl.java	14 Nov 2003 19:35:53 -0000	1.3
  +++ PSVIDOMImplementationImpl.java	10 Feb 2004 17:25:27 -0000	1.4
  @@ -146,7 +146,9 @@
       {
       	if (doctype != null && doctype.getOwnerDocument() != null) {
               throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, 
  -                                   "DOM005 Wrong document");
  +                                   DOMMessageFormatter.formatMessage(
  +                                   DOMMessageFormatter.XML_DOMAIN, 
  +					               "WRONG_DOCUMENT_ERR", null));
           }
           DocumentImpl doc = new PSVIDocumentImpl(doctype);
           Element e = doc.createElementNS( namespaceURI, qualifiedName);
  
  
  
  1.63      +8 -4      xml-xerces/java/src/org/apache/xerces/dom/CoreDocumentImpl.java
  
  Index: CoreDocumentImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/CoreDocumentImpl.java,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- CoreDocumentImpl.java	29 Jan 2004 21:06:04 -0000	1.62
  +++ CoreDocumentImpl.java	10 Feb 2004 17:25:27 -0000	1.63
  @@ -521,7 +521,7 @@
                   return fXPathEvaluator;
               }
               catch (Exception e){
  -                e.printStackTrace();
  +                //e.printStackTrace();
                   return null;
               }
           }
  @@ -548,8 +548,12 @@
       throws DOMException {
           
           if (errorChecking && !isXMLName(name,xml11Version)) {
  -            throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
  -            "DOM002 Illegal character");
  +            String msg =
  +                DOMMessageFormatter.formatMessage(
  +                    DOMMessageFormatter.DOM_DOMAIN,
  +                    "INVALID_CHARACTER_ERR",
  +                    null);
  +            throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
           }
           return new AttrImpl(this, name);
           
  
  
  
  1.49      +4 -4      xml-xerces/java/src/org/apache/xerces/dom/DOMNormalizer.java
  
  Index: DOMNormalizer.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DOMNormalizer.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- DOMNormalizer.java	29 Jan 2004 21:06:04 -0000	1.48
  +++ DOMNormalizer.java	10 Feb 2004 17:25:28 -0000	1.49
  @@ -908,13 +908,13 @@
                           if (fNamespaceValidation) {
                               String msg = DOMMessageFormatter.formatMessage(
                                   DOMMessageFormatter.DOM_DOMAIN, 
  -                                "NullLocalElementName", new Object[]{element.getNodeName()});
  +                                "NullLocalAttrName", new Object[]{attr.getNodeName()});
                               reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_FATAL_ERROR,
null, 
  -                                "NullLocalElementName");
  +                                "NullLocalAttrName");
                           } else {
                               String msg = DOMMessageFormatter.formatMessage(
                                   DOMMessageFormatter.DOM_DOMAIN, 
  -                                "NullLocalAttrName", new Object[]{element.getNodeName()});
  +                                "NullLocalAttrName", new Object[]{attr.getNodeName()});
                               reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR,
null, 
                                   "NullLocalAttrName");
                           }
  
  
  
  1.103     +10 -11    xml-xerces/java/src/org/apache/xerces/parsers/AbstractDOMParser.java
  
  Index: AbstractDOMParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/AbstractDOMParser.java,v
  retrieving revision 1.102
  retrieving revision 1.103
  diff -u -r1.102 -r1.103
  --- AbstractDOMParser.java	29 Jan 2004 19:03:35 -0000	1.102
  +++ AbstractDOMParser.java	10 Feb 2004 17:25:28 -0000	1.103
  @@ -66,6 +66,7 @@
   import org.apache.xerces.dom.DeferredDocumentImpl;
   import org.apache.xerces.dom.DocumentImpl;
   import org.apache.xerces.dom.DocumentTypeImpl;
  +import org.apache.xerces.dom.DOMMessageFormatter;
   import org.apache.xerces.dom.ElementDefinitionImpl;
   import org.apache.xerces.dom.ElementImpl;
   import org.apache.xerces.dom.ElementNSImpl;
  @@ -368,19 +369,17 @@
               ObjectFactory.findClassLoader (), true);
               //if (!_class.isAssignableFrom(Document.class)) {
               if (!Document.class.isAssignableFrom (_class)) {
  -                // REVISIT: message
  -                throw new IllegalArgumentException ("PAR002 Class, \"" +
  -                documentClassName +
  -                "\", is not of type org.w3c.dom.Document.\n" +
  -                documentClassName);
  +                throw new IllegalArgumentException (
  +                    DOMMessageFormatter.formatMessage(
  +                    DOMMessageFormatter.SERIALIZER_DOMAIN,
  +                    "InvalidDocumentClassName", new Object [] {documentClassName}));
               }
           }
           catch (ClassNotFoundException e) {
  -            // REVISIT: message
  -            throw new IllegalArgumentException ("PAR003 Class, \"" +
  -            documentClassName +
  -            "\", not found.\n" +
  -            documentClassName);
  +            throw new IllegalArgumentException (
  +                DOMMessageFormatter.formatMessage(
  +                DOMMessageFormatter.SERIALIZER_DOMAIN,
  +                "MissingDocumentClassName", new Object [] {documentClassName}));
           }
           
           // set document class name
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org


Mime
View raw message