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

cvs commit: xml-xerces/java/src/org/apache/xerces/impl XMLDTDValidator.java XMLDocumentScannerImpl.java XMLNamespaceBinder.java

andyc       01/08/17 03:01:55

  Modified:    java/docs Tag: xerces_j_2 releases.xml
               java/src/org/apache/xerces/impl Tag: xerces_j_2
                        XMLDTDValidator.java XMLDocumentScannerImpl.java
                        XMLNamespaceBinder.java
  Log:
  1) Fixed bug where namespace binder would turn an emptyElement callback
     into startElement and endElement callbacks.
  2) Improved ability of document scanner to perform pull parsing. More
     work may still be done. [Q] Do we want to be able to control pull
     parsing such that only one callback gets performed per scan call?
     Is this even possible? What about the situation where a stage
     down the pipeline generates additional events (e.g. the namespace
     binder)?
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.16.2.17 +13 -0     xml-xerces/java/docs/releases.xml
  
  Index: releases.xml
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/docs/releases.xml,v
  retrieving revision 1.16.2.16
  retrieving revision 1.16.2.17
  diff -u -r1.16.2.16 -r1.16.2.17
  --- releases.xml	2001/08/16 07:38:30	1.16.2.16
  +++ releases.xml	2001/08/17 10:01:55	1.16.2.17
  @@ -4,6 +4,19 @@
    <release version='NOT YET RELEASED'>
     <desc/>
     <changes>
  +   <fix>
  +    <note>
  +     Improved ability of document scanner to perform pull parsing.
  +    </note>
  +    <submitter name='Andy Clark'/>
  +   </fix>
  +   <fix>
  +    <note>
  +     Fixed bug where namespace binder would turn an emptyElement callback into
  +     startElement and endElement callbacks.
  +    </note>
  +    <submitter name='Andy Clark'/>
  +   </fix>
      <update>
       <note>
        Updated standard parser configuration to separate DTD validation
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +2 -2      xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDTDValidator.java
  
  Index: XMLDTDValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDTDValidator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XMLDTDValidator.java	2001/08/16 07:38:30	1.1.2.1
  +++ XMLDTDValidator.java	2001/08/17 10:01:55	1.1.2.2
  @@ -122,7 +122,7 @@
    * @author Andy Clark, IBM
    * @author Jeffrey Rodriguez IBM
    *
  - * @version $Id: XMLDTDValidator.java,v 1.1.2.1 2001/08/16 07:38:30 andyc Exp $
  + * @version $Id: XMLDTDValidator.java,v 1.1.2.2 2001/08/17 10:01:55 andyc Exp $
    */
   public class XMLDTDValidator
       implements XMLComponent, 
  @@ -760,6 +760,7 @@
           throws XNIException {
   
           handleStartElement(element, attributes, true);
  +        handleEndElement(element, true);
   
       } // emptyElement(QName,XMLAttributes)
   
  @@ -2577,7 +2578,6 @@
           if (fDocumentHandler != null) {
               if (isEmpty) {
                   fDocumentHandler.emptyElement(element, attributes);
  -                handleEndElement(element, isEmpty);
               }
               else {
                   fDocumentHandler.startElement(element, attributes);
  
  
  
  1.1.2.3   +174 -63   xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDocumentScannerImpl.java
  
  Index: XMLDocumentScannerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDocumentScannerImpl.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- XMLDocumentScannerImpl.java	2001/08/15 06:58:47	1.1.2.2
  +++ XMLDocumentScannerImpl.java	2001/08/17 10:01:55	1.1.2.3
  @@ -104,7 +104,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Eric Ye, IBM
    *
  - * @version $Id: XMLDocumentScannerImpl.java,v 1.1.2.2 2001/08/15 06:58:47 andyc Exp $
  + * @version $Id: XMLDocumentScannerImpl.java,v 1.1.2.3 2001/08/17 10:01:55 andyc Exp $
    */
   public class XMLDocumentScannerImpl
       extends XMLScanner
  @@ -158,6 +158,15 @@
       /** Scanner state: Text declaration. */
       protected static final int SCANNER_STATE_TEXT_DECL = 16;
   
  +    /** Scanner state: DTD internal declarations. */
  +    protected static final int SCANNER_STATE_DTD_INTERNAL_DECLS = 17;
  +
  +    /** Scanner state: open DTD external subset. */
  +    protected static final int SCANNER_STATE_DTD_EXTERNAL = 18;
  +
  +    /** Scanner state: DTD external declarations. */
  +    protected static final int SCANNER_STATE_DTD_EXTERNAL_DECLS = 19;
  +
       // feature identifiers
   
       /** Feature identifier: namespaces. */
  @@ -248,6 +257,20 @@
       /** Element stack. */
       protected ElementStack fElementStack = new ElementStack();
   
  +    // other info
  +
  +    /** Document system identifier. */
  +    protected String fDocumentSystemId;
  +
  +    /** Doctype name. */
  +    protected String fDoctypeName;
  +
  +    /** Doctype declaration public identifier. */
  +    protected String fDoctypePublicId;
  +
  +    /** Doctype declaration system identifier. */
  +    protected String fDoctypeSystemId;
  +
       // features
   
       /** Namespaces. */
  @@ -269,6 +292,9 @@
       /** Prolog dispatcher. */
       protected Dispatcher fPrologDispatcher = new PrologDispatcher();
   
  +    /** DTD dispatcher. */
  +    protected Dispatcher fDTDDispatcher = new DTDDispatcher();
  +
       /** Content dispatcher. */
       protected Dispatcher fContentDispatcher = new ContentDispatcher();
   
  @@ -321,6 +347,7 @@
       public void setInputSource(XMLInputSource inputSource) throws IOException {
           fEntityManager.setEntityHandler(this);
           fEntityManager.startDocumentEntity(inputSource);
  +        fDocumentSystemId = fEntityManager.expandSystemId(inputSource.getSystemId());
       } // setInputSource(XMLInputSource)
   
       /** 
  @@ -375,6 +402,12 @@
   
           super.reset(componentManager);
   
  +        // other settings
  +        fDocumentSystemId = null;
  +        fDoctypeName = null;
  +        fDoctypePublicId = null;
  +        fDoctypeSystemId = null;
  +
           // sax features
           fNamespaces = componentManager.getFeature(NAMESPACES);
           fAttributes.setNamespaces(fNamespaces);
  @@ -691,7 +724,7 @@
       } // scanComment()
       
       /** Scans a doctype declaration. */
  -    protected void scanDoctypeDecl() throws IOException, XNIException {
  +    protected boolean scanDoctypeDecl() throws IOException, XNIException {
   
           // spaces
           if (!fEntityScanner.skipSpaces()) {
  @@ -700,22 +733,20 @@
           }
   
           // root element name
  -        String name = fEntityScanner.scanName();
  -        if (name == null) {
  +        fDoctypeName = fEntityScanner.scanName();
  +        if (fDoctypeName == null) {
               reportFatalError("MSG_ROOT_ELEMENT_TYPE_REQUIRED", null);
           }
   
           // external id
  -        String systemId = null;
  -        String publicId = null;
           if (fEntityScanner.skipSpaces()) {
               scanExternalID(fStrings, false);
  -            systemId = fStrings[0];
  -            publicId = fStrings[1];
  +            fDoctypeSystemId = fStrings[0];
  +            fDoctypePublicId = fStrings[1];
               fEntityScanner.skipSpaces();
           }
           
  -        fHasExternalDTD = systemId != null;
  +        fHasExternalDTD = fDoctypeSystemId != null;
   
           // call handler
           if (fDocumentHandler != null) {
  @@ -724,60 +755,23 @@
               //       subset) is parsed correctly but SAX2 requires that
               //       it knows the root element name and public and system
               //       identifier for the startDTD call. -Ac
  -            fDocumentHandler.doctypeDecl(name, publicId, systemId);
  +            fDocumentHandler.doctypeDecl(fDoctypeName, fDoctypePublicId, fDoctypeSystemId);
           }
   
  -        // internal subset
  -        if (fEntityScanner.skipChar('[')) {
  -            // clear entity handler
  -            fEntityManager.setEntityHandler(null);
  -
  -            // parser internal subset
  -            final boolean complete = true;
  -            // NOTE: Don't need to set the input source because it's
  -            //       the same one as the document entity *and* the
  -            //       scanner implementations rely on the entity
  -            //       manager for the details. -Ac
  -            fDTDScanner.scanDTDInternalSubset(complete, fStandalone, fHasExternalDTD);
  -
  -            // restore entity handler
  -            fEntityManager.setEntityHandler(this);
  -            // REVISIT: Do we need to emit an error here? We can usually
  -            //          assume that it will be consumed by the DTD scanner
  -            //          or else the DTD scanner will fail on seeing the
  -            //          document content. However, there is the continue-
  -            //          after-fatal-error setting... -Ac
  -            if (!fEntityScanner.skipChar(']')) {
  -                reportFatalError("EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET",
  -                                 null);
  -            }
  +        // is there an internal subset?
  +        boolean internalSubset = true;
  +        if (!fEntityScanner.skipChar('[')) {
  +            internalSubset = false;
               fEntityScanner.skipSpaces();
  +            if (!fEntityScanner.skipChar('>')) {
  +                reportFatalError("DoctypedeclUnterminated", new Object[]{fDoctypeName});
  +            }
  +            fMarkupDepth--;
           }
  -
  -        // end
  -        fEntityScanner.skipSpaces();
  -        if (!fEntityScanner.skipChar('>')) {
  -            reportFatalError("DoctypedeclUnterminated", new Object[]{name});
  -        }
  -        fMarkupDepth--;
  -
  -        // external subset
  -        if (systemId != null && (fValidation || fLoadExternalDTD)) {
  -            // clear entity handler
  -            fEntityManager.setEntityHandler(null);
  -
  -            // scan DTD
  -            final boolean complete = true;
  -            XMLInputSource xmlInputSource = 
  -                fEntityManager.resolveEntity(publicId, systemId, null);
  -            fDTDScanner.setInputSource(xmlInputSource);
  -            fDTDScanner.scanDTDExternalSubset(complete);
   
  -            // restore entity handler
  -            fEntityManager.setEntityHandler(this);
  -        }
  +        return internalSubset;
   
  -    } // scanDoctypeDecl()
  +    } // scanDoctypeDecl():boolean
   
       /** 
        * Scans a start element. This method will handle the binding of
  @@ -1304,6 +1298,9 @@
                   case SCANNER_STATE_TERMINATED: return "SCANNER_STATE_TERMINATED";
                   case SCANNER_STATE_CDATA: return "SCANNER_STATE_CDATA";
                   case SCANNER_STATE_TEXT_DECL: return "SCANNER_STATE_TEXT_DECL";
  +                case SCANNER_STATE_DTD_INTERNAL_DECLS: return "SCANNER_STATE_DTD_INTERNAL_DECLS";
  +                case SCANNER_STATE_DTD_EXTERNAL: return "SCANNER_STATE_DTD_EXTERNAL";
  +                case SCANNER_STATE_DTD_EXTERNAL_DECLS: return "SCANNER_STATE_DTD_EXTERNAL_DECLS";
               }
           }
   
  @@ -1498,7 +1495,7 @@
                       else {
                           scanXMLDeclOrTextDecl(false);
                       }
  -                    return complete;
  +                    return true;
                   }
               }
   
  @@ -1613,7 +1610,16 @@
                                   reportFatalError("AlreadySeenDoctype", null);
                               }
                               fSeenDoctypeDecl = true;
  -                            scanDoctypeDecl();
  +                            if (scanDoctypeDecl()) {
  +                                setScannerState(SCANNER_STATE_DTD_INTERNAL_DECLS);
  +                                setDispatcher(fDTDDispatcher);
  +                                return true;
  +                            }
  +                            if (fDoctypeSystemId != null) {
  +                                setScannerState(SCANNER_STATE_DTD_EXTERNAL);
  +                                setDispatcher(fDTDDispatcher);
  +                                return true;
  +                            }
                               setScannerState(SCANNER_STATE_PROLOG);
                               break;
                           }
  @@ -1640,13 +1646,118 @@
                   throw e;
               }
   
  -            return complete;
  +            return true;
   
           } // dispatch(boolean):boolean
   
       } // class PrologDispatcher
   
       /**
  +     * Dispatcher to handle the internal and external DTD subsets.
  +     *
  +     * @author Andy Clark, IBM
  +     */
  +    protected final class DTDDispatcher
  +        implements Dispatcher {
  +        
  +        //
  +        // Dispatcher methods
  +        //
  +
  +        /** 
  +         * Dispatch an XML "event".
  +         *
  +         * @param complete True if this dispatcher is intended to scan
  +         *                 and dispatch as much as possible.                 
  +         *
  +         * @returns True if there is more to dispatch either from this 
  +         *          or a another dispatcher.
  +         *
  +         * @throws IOException  Thrown on i/o error.
  +         * @throws XNIException Thrown on parse error.
  +         */
  +        public boolean dispatch(boolean complete) 
  +            throws IOException, XNIException {
  +
  +            fEntityManager.setEntityHandler(null);
  +            try {
  +                boolean again;
  +                do {
  +                    again = false;
  +                    switch (fScannerState) {
  +                        case SCANNER_STATE_DTD_INTERNAL_DECLS: {
  +                            boolean moreToScan = fDTDScanner.scanDTDInternalSubset(complete, fStandalone, fHasExternalDTD);
  +                            if (!moreToScan) {
  +                                // end doctype declaration
  +                                if (!fEntityScanner.skipChar(']')) {
  +                                    reportFatalError("EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET",
  +                                                     null);
  +                                }
  +                                fEntityScanner.skipSpaces();
  +                                fEntityScanner.skipSpaces();
  +                                if (!fEntityScanner.skipChar('>')) {
  +                                    reportFatalError("DoctypedeclUnterminated", new Object[]{fDoctypeName});
  +                                }
  +                                fMarkupDepth--;
  +
  +                                // scan external subset next
  +                                if (fDoctypeSystemId != null && (fValidation || fLoadExternalDTD)) {
  +                                    setScannerState(SCANNER_STATE_DTD_EXTERNAL);
  +                                }
  +
  +                                // break out of here
  +                                else {
  +                                    setScannerState(SCANNER_STATE_PROLOG);
  +                                    setDispatcher(fPrologDispatcher);
  +                                    fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
  +                                    return true;
  +                                }
  +                            }
  +                            break;
  +                        }
  +                        case SCANNER_STATE_DTD_EXTERNAL: {
  +                            XMLInputSource xmlInputSource = 
  +                                fEntityManager.resolveEntity(fDoctypePublicId, fDoctypeSystemId, fDocumentSystemId);
  +                            fDTDScanner.setInputSource(xmlInputSource);
  +                            setScannerState(SCANNER_STATE_DTD_EXTERNAL_DECLS);
  +                            again = true;
  +                            break;
  +                        }
  +                        case SCANNER_STATE_DTD_EXTERNAL_DECLS: {
  +                            boolean moreToScan = fDTDScanner.scanDTDExternalSubset(complete);
  +                            if (!moreToScan) {
  +                                setScannerState(SCANNER_STATE_PROLOG);
  +                                setDispatcher(fPrologDispatcher);
  +                                fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
  +                                return true;
  +                            }
  +                            break;
  +                        }
  +                        default: {
  +                            throw new XNIException("DTDDispatcher#dispatch: scanner state="+fScannerState+" ("+getScannerStateName(fScannerState)+')');
  +                        }
  +                    }
  +                } while (complete || again);
  +            }
  +
  +            // premature end of file
  +            catch (EOFException e) {
  +                reportFatalError("PrematureEOF", null);
  +                throw e;
  +            }
  +
  +            // cleanup
  +            finally {
  +                fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
  +            }
  +
  +            return true;
  +
  +        } // dispatch(boolean):boolean
  +
  +    } // class DTDDispatcher
  +
  +    /**
        * Dispatcher to handle content scanning.
        *
        * @author Andy Clark, IBM
  @@ -1754,7 +1865,7 @@
                                   if (scanEndElement() == 0) {
                                       setScannerState(SCANNER_STATE_TRAILING_MISC);
                                       setDispatcher(fTrailingMiscDispatcher);
  -                                    return complete;
  +                                    return true;
                                   }
                                   setScannerState(SCANNER_STATE_CONTENT);
                               }
  @@ -1827,7 +1938,7 @@
                               if (scanStartElement()) {
                                   setScannerState(SCANNER_STATE_TRAILING_MISC);
                                   setDispatcher(fTrailingMiscDispatcher);
  -                                return complete;
  +                                return true;
                               }
                               setScannerState(SCANNER_STATE_CONTENT);
                               break;
  @@ -1846,7 +1957,7 @@
                   throw e;
               }
   
  -            return complete;
  +            return true;
   
           } // dispatch(boolean):boolean
   
  
  
  
  1.1.2.16  +117 -96   xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLNamespaceBinder.java
  
  Index: XMLNamespaceBinder.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLNamespaceBinder.java,v
  retrieving revision 1.1.2.15
  retrieving revision 1.1.2.16
  diff -u -r1.1.2.15 -r1.1.2.16
  --- XMLNamespaceBinder.java	2001/08/09 06:27:45	1.1.2.15
  +++ XMLNamespaceBinder.java	2001/08/17 10:01:55	1.1.2.16
  @@ -91,7 +91,7 @@
    *
    * @author Andy Clark, IBM
    *
  - * @version $Id: XMLNamespaceBinder.java,v 1.1.2.15 2001/08/09 06:27:45 andyc Exp $
  + * @version $Id: XMLNamespaceBinder.java,v 1.1.2.16 2001/08/17 10:01:55 andyc Exp $
    */
   public class XMLNamespaceBinder 
       implements XMLComponent, XMLDocumentHandler {
  @@ -493,72 +493,7 @@
        */
       public void startElement(QName element, XMLAttributes attributes)
           throws XNIException {
  -
  -        // add new namespace context
  -        fNamespaceSupport.pushContext();
  -
  -        // search for new namespace bindings
  -        int length = attributes.getLength();
  -        for (int i = 0; i < length; i++) {
  -            String rawname = attributes.getQName(i);
  -            if (rawname.startsWith("xmlns")) {
  -                // declare prefix in context
  -                String prefix = rawname.length() > 5
  -                              ? attributes.getLocalName(i) : fEmptySymbol;
  -                String uri = attributes.getValue(i);
  -                uri = fSymbolTable.addSymbol(uri);
  -                fNamespaceSupport.declarePrefix(prefix, uri.length() != 0 ? uri : null);
  -
  -                // call handler
  -                if (fDocumentHandler != null) {
  -                    fDocumentHandler.startPrefixMapping(prefix, uri);
  -                }
  -            }
  -        }
  -
  -        // bind the element
  -        String prefix = element.prefix != null
  -                      ? element.prefix : fEmptySymbol;
  -        element.uri = fNamespaceSupport.getURI(prefix);
  -        if (element.prefix == null && element.uri != null) {
  -            element.prefix = fEmptySymbol;
  -        }
  -        if (element.prefix != null && element.uri == null) {
  -            fErrorReporter.reportError(XMLMessageFormatter.XMLNS_DOMAIN,
  -                                       "ElementPrefixUnbound",
  -                                       new Object[]{element.prefix, element.rawname},
  -                                       XMLErrorReporter.SEVERITY_FATAL_ERROR);
  -        }
  -
  -        // bind the attributes
  -        for (int i = 0; i < length; i++) {
  -            attributes.getName(i, fAttributeQName);
  -            String aprefix = fAttributeQName.prefix != null 
  -                           ? fAttributeQName.prefix : fEmptySymbol;
  -            String arawname = fAttributeQName.rawname;
  -            if (aprefix == fXmlSymbol) {
  -                fAttributeQName.uri = fNamespaceSupport.getURI(fXmlSymbol);
  -                attributes.setName(i, fAttributeQName);
  -            }
  -            else if (arawname != fXmlnsSymbol && !arawname.startsWith("xmlns:")) {
  -                if (aprefix != fEmptySymbol) {
  -                    fAttributeQName.uri = fNamespaceSupport.getURI(aprefix);
  -                    if (fAttributeQName.uri == null) {
  -                        fErrorReporter.reportError(XMLMessageFormatter.XMLNS_DOMAIN,
  -                                                   "AttributePrefixUnbound",
  -                                                   new Object[]{aprefix, arawname},
  -                                                   XMLErrorReporter.SEVERITY_FATAL_ERROR);
  -                    }
  -                    attributes.setName(i, fAttributeQName);
  -                }
  -            }
  -        }
  -
  -        // call handler
  -        if (fDocumentHandler != null && !fOnlyPassPrefixMappingEvents) {
  -            fDocumentHandler.startElement(element, attributes);
  -        }
  -
  +        handleStartElement(element, attributes, false);
       } // startElement(QName,XMLAttributes)
   
       /**
  @@ -571,10 +506,8 @@
        */
       public void emptyElement(QName element, XMLAttributes attributes)
           throws XNIException {
  -
  -        startElement(element, attributes);
  -        endElement(element);
  -
  +        handleStartElement(element, attributes, true);
  +        handleEndElement(element, true);
       } // emptyElement(QName,XMLAttributes)
   
       /**
  @@ -616,31 +549,7 @@
        * @throws XNIException Thrown by handler to signal an error.
        */
       public void endElement(QName element) throws XNIException {
  -
  -        // bind element
  -        String eprefix = element.prefix != null ? element.prefix : fEmptySymbol;
  -        element.uri = fNamespaceSupport.getURI(eprefix);
  -        if (element.uri != null) {
  -            element.prefix = eprefix;
  -        }
  -        
  -        // call handlers
  -        if (fDocumentHandler != null && !fOnlyPassPrefixMappingEvents) {
  -            fDocumentHandler.endElement(element);
  -        }
  -
  -        // end prefix mappings
  -        if (fDocumentHandler != null) {
  -            int count = fNamespaceSupport.getDeclaredPrefixCount();
  -            for (int i = count - 1; i >= 0; i--) {
  -                String prefix = fNamespaceSupport.getDeclaredPrefixAt(i);
  -                fDocumentHandler.endPrefixMapping(prefix);
  -            }
  -        }
  -
  -        // pop context
  -        fNamespaceSupport.popContext();
  -
  +        handleEndElement(element, false);
       } // endElement(QName)
   
       /**
  @@ -712,5 +621,117 @@
               fDocumentHandler.endEntity(name);
           }
       } // endEntity(String)
  +
  +    //
  +    // Protected methods
  +    //
  +
  +    /** Handles start element. */
  +    protected void handleStartElement(QName element, XMLAttributes attributes,
  +                                      boolean isEmpty) throws XNIException {
  +
  +        // add new namespace context
  +        fNamespaceSupport.pushContext();
  +
  +        // search for new namespace bindings
  +        int length = attributes.getLength();
  +        for (int i = 0; i < length; i++) {
  +            String rawname = attributes.getQName(i);
  +            if (rawname.startsWith("xmlns")) {
  +                // declare prefix in context
  +                String prefix = rawname.length() > 5
  +                              ? attributes.getLocalName(i) : fEmptySymbol;
  +                String uri = attributes.getValue(i);
  +                uri = fSymbolTable.addSymbol(uri);
  +                fNamespaceSupport.declarePrefix(prefix, uri.length() != 0 ? uri : null);
  +
  +                // call handler
  +                if (fDocumentHandler != null) {
  +                    fDocumentHandler.startPrefixMapping(prefix, uri);
  +                }
  +            }
  +        }
  +
  +        // bind the element
  +        String prefix = element.prefix != null
  +                      ? element.prefix : fEmptySymbol;
  +        element.uri = fNamespaceSupport.getURI(prefix);
  +        if (element.prefix == null && element.uri != null) {
  +            element.prefix = fEmptySymbol;
  +        }
  +        if (element.prefix != null && element.uri == null) {
  +            fErrorReporter.reportError(XMLMessageFormatter.XMLNS_DOMAIN,
  +                                       "ElementPrefixUnbound",
  +                                       new Object[]{element.prefix, element.rawname},
  +                                       XMLErrorReporter.SEVERITY_FATAL_ERROR);
  +        }
  +
  +        // bind the attributes
  +        for (int i = 0; i < length; i++) {
  +            attributes.getName(i, fAttributeQName);
  +            String aprefix = fAttributeQName.prefix != null 
  +                           ? fAttributeQName.prefix : fEmptySymbol;
  +            String arawname = fAttributeQName.rawname;
  +            if (aprefix == fXmlSymbol) {
  +                fAttributeQName.uri = fNamespaceSupport.getURI(fXmlSymbol);
  +                attributes.setName(i, fAttributeQName);
  +            }
  +            else if (arawname != fXmlnsSymbol && !arawname.startsWith("xmlns:")) {
  +                if (aprefix != fEmptySymbol) {
  +                    fAttributeQName.uri = fNamespaceSupport.getURI(aprefix);
  +                    if (fAttributeQName.uri == null) {
  +                        fErrorReporter.reportError(XMLMessageFormatter.XMLNS_DOMAIN,
  +                                                   "AttributePrefixUnbound",
  +                                                   new Object[]{aprefix, arawname},
  +                                                   XMLErrorReporter.SEVERITY_FATAL_ERROR);
  +                    }
  +                    attributes.setName(i, fAttributeQName);
  +                }
  +            }
  +        }
  +
  +        // call handler
  +        if (fDocumentHandler != null && !fOnlyPassPrefixMappingEvents) {
  +            if (isEmpty) {
  +                fDocumentHandler.emptyElement(element, attributes);
  +            }
  +            else {
  +                fDocumentHandler.startElement(element, attributes);
  +            }
  +        }
  +
  +    } // handleStartElement(QName,XMLAttributes,boolean)
  +
  +    /** Handles end element. */
  +    protected void handleEndElement(QName element, boolean isEmpty)
  +        throws XNIException {
  +
  +        // bind element
  +        String eprefix = element.prefix != null ? element.prefix : fEmptySymbol;
  +        element.uri = fNamespaceSupport.getURI(eprefix);
  +        if (element.uri != null) {
  +            element.prefix = eprefix;
  +        }
  +        
  +        // call handlers
  +        if (fDocumentHandler != null && !fOnlyPassPrefixMappingEvents) {
  +            if (!isEmpty) {
  +                fDocumentHandler.endElement(element);
  +            }
  +        }
  +
  +        // end prefix mappings
  +        if (fDocumentHandler != null) {
  +            int count = fNamespaceSupport.getDeclaredPrefixCount();
  +            for (int i = count - 1; i >= 0; i--) {
  +                String prefix = fNamespaceSupport.getDeclaredPrefixAt(i);
  +                fDocumentHandler.endPrefixMapping(prefix);
  +            }
  +        }
  +
  +        // pop context
  +        fNamespaceSupport.popContext();
  +
  +    } // handleEndElement(QName,boolean)
   
   } // class XMLNamespaceBinder
  
  
  

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