You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2003/01/17 23:40:55 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/util DOMErrorHandlerWrapper.java

elena       2003/01/17 14:40:54

  Modified:    java/src/org/apache/xerces/dom DOMErrorImpl.java
                        DeferredDocumentImpl.java
                        DeferredProcessingInstructionImpl.java
                        ProcessingInstructionImpl.java
               java/src/org/apache/xerces/dom3 DOMError.java
               java/src/org/apache/xerces/parsers AbstractDOMParser.java
                        DOMBuilderImpl.java
               java/src/org/apache/xerces/util DOMErrorHandlerWrapper.java
  Log:
  For PIs the baseURI is lost if entity refs are expanded, instead a warning is issued.
  Modifying also DOMError interfaces to include "type" and "relatedData" fields
  
  Revision  Changes    Path
  1.9       +12 -1     xml-xerces/java/src/org/apache/xerces/dom/DOMErrorImpl.java
  
  Index: DOMErrorImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DOMErrorImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DOMErrorImpl.java	23 Aug 2002 20:14:38 -0000	1.8
  +++ DOMErrorImpl.java	17 Jan 2003 22:40:53 -0000	1.9
  @@ -92,6 +92,9 @@
       public String fMessage = null;
       public DOMLocatorImpl fLocator = new DOMLocatorImpl();
       public Exception fException = null;
  +    public String fType;
  +    public Object fRelatedData;
  +   
   
   
       //
  @@ -156,6 +159,14 @@
       public void reset(){
           fSeverity = DOMError.SEVERITY_WARNING; 
           fException = null;
  +    }
  +    
  +    public String getType(){
  +        return fType;
  +    }
  +    
  +    public Object getRelatedData(){
  +        return fRelatedData;
       }
   
   
  
  
  
  1.51      +1 -15     xml-xerces/java/src/org/apache/xerces/dom/DeferredDocumentImpl.java
  
  Index: DeferredDocumentImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DeferredDocumentImpl.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- DeferredDocumentImpl.java	17 Jan 2003 14:28:06 -0000	1.50
  +++ DeferredDocumentImpl.java	17 Jan 2003 22:40:54 -0000	1.51
  @@ -582,26 +582,12 @@
       /** Creates a processing instruction node in the table. */
       public int createDeferredProcessingInstruction(String target,
                                                      String data) {
  -
           // create node
           int nodeIndex = createNode(Node.PROCESSING_INSTRUCTION_NODE);
           int chunk = nodeIndex >> CHUNK_SHIFT;
           int index = nodeIndex & CHUNK_MASK;
           setChunkValue(fNodeName, target, chunk, index);
           setChunkValue(fNodeValue, data, chunk, index);
  -        // return node index
  -        return nodeIndex;
  -
  -    } // createDeferredProcessingInstruction(String,String):int
  -
  -
  -    /** Set a baseURI for a processing instruction node in the table. */
  -    public int setDeferredPIBaseURI(int nodeIndex, String baseURI) {
  -
  -        // create node
  -        int chunk = nodeIndex >> CHUNK_SHIFT;
  -        int index = nodeIndex & CHUNK_MASK;
  -        setChunkValue(fNodeURI, baseURI, chunk, index);
           // return node index
           return nodeIndex;
   
  
  
  
  1.12      +1 -2      xml-xerces/java/src/org/apache/xerces/dom/DeferredProcessingInstructionImpl.java
  
  Index: DeferredProcessingInstructionImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DeferredProcessingInstructionImpl.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DeferredProcessingInstructionImpl.java	7 May 2002 19:29:03 -0000	1.11
  +++ DeferredProcessingInstructionImpl.java	17 Jan 2003 22:40:54 -0000	1.12
  @@ -124,7 +124,6 @@
               (DeferredDocumentImpl) this.ownerDocument();
           target  = ownerDocument.getNodeName(fNodeIndex);
           data = ownerDocument.getNodeValueString(fNodeIndex);
  -        baseURI = ownerDocument.getNodeURI(fNodeIndex);
   
       } // synchronizeData()
   
  
  
  
  1.12      +2 -12     xml-xerces/java/src/org/apache/xerces/dom/ProcessingInstructionImpl.java
  
  Index: ProcessingInstructionImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/ProcessingInstructionImpl.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ProcessingInstructionImpl.java	7 May 2002 19:29:03 -0000	1.11
  +++ ProcessingInstructionImpl.java	17 Jan 2003 22:40:54 -0000	1.12
  @@ -86,7 +86,6 @@
       //
   
       protected String target;
  -    protected String baseURI;
   
       //
       // Constructors
  @@ -187,17 +186,8 @@
           if (needsSyncData()) {
               synchronizeData();
           }
  -        return (baseURI!=null)?baseURI:ownerNode.getBaseURI();
  +        return ownerNode.getBaseURI();
       }
   
  -
  -    /** NON-DOM: set base uri*/
  -    public void setBaseURI(String uri){
  -        if (needsSyncData()) {
  -            synchronizeData();
  -        }
  -        // if was included in the tree using entity reference
  -        baseURI = uri;
  -    }
   
   } // class ProcessingInstructionImpl
  
  
  
  1.3       +21 -0     xml-xerces/java/src/org/apache/xerces/dom3/DOMError.java
  
  Index: DOMError.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom3/DOMError.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DOMError.java	23 Aug 2002 20:14:39 -0000	1.2
  +++ DOMError.java	17 Jan 2003 22:40:54 -0000	1.3
  @@ -60,5 +60,26 @@
        * The location of the error.
        */
       public DOMLocator getLocation();
  +    
  +        /**
  +     *  The related <code>Error.type</code> dependent data if any. 
  +     */
  +
  +    public Object getRelatedData();
  +        /**
  +     *  A <code>DOMString</code> indicating which related data is expected in 
  +     * <code>relatedData</code>. Users should refer to the specification of 
  +     * the error in order to find its <code>DOMString</code> type and 
  +     * <code>relatedData</code> definitions if any.  As an example, [<a href='http://www.w3.org/TR/DOM-Level-3-LS'>DOM Level 3 Load and Save</a>] does 
  +     * not keep the [baseURI] property defined on a Processing Instruction 
  +     * information item. Therefore, the <code>DOMBuilder</code> generates a 
  +     * <code>SEVERITY_WARNING</code> with <code>type</code> 
  +     * <code>"infoset-baseURI"</code> and the lost [baseURI] property 
  +     * represented as a <code>DOMString</code> in the 
  +     * <code>relatedData</code> attribute. 
  +     */
  +
  +    public String getType();
  +
   
   }
  
  
  
  1.81      +40 -18    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.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- AbstractDOMParser.java	16 Jan 2003 22:53:45 -0000	1.80
  +++ AbstractDOMParser.java	17 Jan 2003 22:40:54 -0000	1.81
  @@ -62,6 +62,7 @@
   
   import org.apache.xerces.dom.AttrImpl;
   import org.apache.xerces.dom.CoreDocumentImpl;
  +import org.apache.xerces.dom.DOMErrorImpl;
   import org.apache.xerces.dom.DeferredDocumentImpl;
   import org.apache.xerces.dom.DocumentImpl;
   import org.apache.xerces.dom.DocumentTypeImpl;
  @@ -79,6 +80,7 @@
   import org.apache.xerces.impl.Constants;
   import org.apache.xerces.impl.dv.XSSimpleType;
   import org.apache.xerces.impl.xs.psvi.XSTypeDefinition;
  +import org.apache.xerces.util.DOMErrorHandlerWrapper;
   import org.apache.xerces.util.ObjectFactory;
   import org.apache.xerces.xni.Augmentations;
   import org.apache.xerces.xni.NamespaceContext;
  @@ -200,7 +202,9 @@
       //
       // Data
       //
  -
  +    
  +    /** DOM L3 error handler */
  +    protected DOMErrorHandlerWrapper fErrorHandler = null;
   
       /** True if inside DTD. */
       protected boolean fInDTD;
  @@ -1597,7 +1601,7 @@
        * 
        * @param node
        */
  -    protected void handleBaseURI (Node node){
  +    protected final void handleBaseURI (Node node){
           if (fDocumentImpl != null) {
               // REVISIT: remove dependency on our implementation when
               //          DOM L3 becomes REC
  @@ -1608,8 +1612,10 @@
               if (nodeType == Node.ELEMENT_NODE) {
                   // if an element already has xml:base attribute
                   // do nothing
  -                if (fNamespaceAware && (((Element)node).getAttributeNodeNS("http://www.w3.org/XML/1998/namespace","base")!=null)) { 
  -                    return;
  +                if (fNamespaceAware) {
  +                    if (((Element)node).getAttributeNodeNS("http://www.w3.org/XML/1998/namespace","base")!=null) { 
  +                        return;
  +                    }
                   } else if (((Element)node).getAttributeNode("xml:base") != null) {
                       return;
                   }
  @@ -1623,10 +1629,17 @@
                       }
                   }
               }
  -            else if (nodeType == Node.PROCESSING_INSTRUCTION_NODE) {
  +			else if (nodeType == Node.PROCESSING_INSTRUCTION_NODE) {
  +                            
                   baseURI = ((EntityReferenceImpl)fCurrentNode).getBaseURI();
  -                ((ProcessingInstructionImpl)node).setBaseURI(baseURI);
  -            }
  +				if (baseURI !=null && fErrorHandler != null) {
  +					DOMErrorImpl error = new DOMErrorImpl();
  +                    error.fType = "infoset-baseURI";
  +                    error.fRelatedData = baseURI;
  +					error.fSeverity = error.SEVERITY_WARNING;
  +					fErrorHandler.getErrorHandler().handleError(error);
  +				}
  +			}
           }
       }
   
  @@ -1638,8 +1651,9 @@
        * 
        * @param node
        */
  -    protected void handleBaseURI (int node){
  +    protected final void handleBaseURI (int node){
           short nodeType = fDeferredDocumentImpl.getNodeType(node, false);
  +
           if (nodeType == Node.ELEMENT_NODE) {
               String baseURI = fDeferredDocumentImpl.getNodeValueString(fCurrentNodeIndex, false);
               if (baseURI == null) {
  @@ -1653,17 +1667,25 @@
                                                              true);
               }
           }
  -        else if (nodeType == Node.PROCESSING_INSTRUCTION_NODE) {
  +		else if (nodeType == Node.PROCESSING_INSTRUCTION_NODE) {
   
  -            // retrieve baseURI from the entity reference
  -            String baseURI = fDeferredDocumentImpl.getNodeValueString(fCurrentNodeIndex, false);
   
  -            if (baseURI == null) {
  -                // try baseURI of the entity declaration
  -                baseURI = fDeferredDocumentImpl.getDeferredEntityBaseURI(fDeferredEntityDecl);
  -            }
  -            fDeferredDocumentImpl.setDeferredPIBaseURI(node, baseURI);
  -        }
  +			// retrieve baseURI from the entity reference
  +			String baseURI = fDeferredDocumentImpl.getNodeValueString(fCurrentNodeIndex, false);
  +
  +			if (baseURI == null) {
  +				// try baseURI of the entity declaration
  +				baseURI = fDeferredDocumentImpl.getDeferredEntityBaseURI(fDeferredEntityDecl);
  +			}
  +
  +			if (baseURI != null && fErrorHandler != null) {
  +				DOMErrorImpl error = new DOMErrorImpl();
  +				error.fType = "infoset-baseURI";
  +				error.fRelatedData = baseURI; 
  +                error.fSeverity = error.SEVERITY_WARNING;
  +				fErrorHandler.getErrorHandler().handleError(error);
  +			}
  +		}
       }
   
                          
  
  
  
  1.28      +1 -2      xml-xerces/java/src/org/apache/xerces/parsers/DOMBuilderImpl.java
  
  Index: DOMBuilderImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/DOMBuilderImpl.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- DOMBuilderImpl.java	7 Jan 2003 22:23:47 -0000	1.27
  +++ DOMBuilderImpl.java	17 Jan 2003 22:40:54 -0000	1.28
  @@ -141,7 +141,6 @@
   
       protected final static boolean DEBUG = false;
   
  -    protected DOMErrorHandlerWrapper fErrorHandler = null;
       //
       // Constructors
       //
  
  
  
  1.7       +7 -4      xml-xerces/java/src/org/apache/xerces/util/DOMErrorHandlerWrapper.java
  
  Index: DOMErrorHandlerWrapper.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/util/DOMErrorHandlerWrapper.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DOMErrorHandlerWrapper.java	23 Aug 2002 20:14:39 -0000	1.6
  +++ DOMErrorHandlerWrapper.java	17 Jan 2003 22:40:54 -0000	1.7
  @@ -161,7 +161,8 @@
                           XMLParseException exception) throws XNIException {
           fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
           fDOMError.fException = exception;
  -        fDOMError.fMessage = exception.getMessage();
  +        fDOMError.fType = key;         
  +        fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
           DOMLocatorImpl locator = fDOMError.fLocator;
           if (locator != null) {
               locator.fColumnNumber = exception.getColumnNumber();
  @@ -192,7 +193,8 @@
                         XMLParseException exception) throws XNIException {
           fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
           fDOMError.fException = exception;
  -        fDOMError.fMessage = exception.getMessage();
  +        fDOMError.fType = key;         
  +        fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
           DOMLocatorImpl locator = fDOMError.fLocator;
           if (locator != null) {
               locator.fColumnNumber = exception.getColumnNumber();
  @@ -231,7 +233,8 @@
                              XMLParseException exception) throws XNIException {
           fDOMError.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
           fDOMError.fException = exception;
  -        fDOMError.fMessage = exception.getMessage();
  +        fDOMError.fType = key;         
  +        fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
           DOMLocatorImpl locator = fDOMError.fLocator;
           if (locator != null) {
               locator.fColumnNumber = exception.getColumnNumber();
  
  
  

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