mrglavas    2004/11/04 13:35:08

  Modified:    java/src/org/apache/xerces/dom ElementNSImpl.java
  Log:
  DOM Level 3 specifies an attribute called strictErrorChecking [1] which when set to 
false
  allows an implementation to not test every possible error case. Reducing the amount
  of checking performed when strictErrorChecking is false. This patch is thanks to
  Naela Nissar.
  
  [1] 
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Document3-strictErrorChecking
  
  Revision  Changes    Path
  1.46      +40 -36    xml-xerces/java/src/org/apache/xerces/dom/ElementNSImpl.java
  
  Index: ElementNSImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/ElementNSImpl.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- ElementNSImpl.java        5 Oct 2004 17:12:51 -0000       1.45
  +++ ElementNSImpl.java        4 Nov 2004 21:35:08 -0000       1.46
  @@ -109,45 +109,49 @@
                    colon2 = qname.lastIndexOf(':');
           }
   
  -             ownerDocument().checkNamespaceWF(qname, colon1, colon2);
  +             ownerDocument.checkNamespaceWF(qname, colon1, colon2);
                if (colon1 < 0) {
                        // there is no prefix
                        localName = qname;
  -                     ownerDocument().checkQName(null, localName);
  -                     if (qname.equals("xmlns")
  -                             && (namespaceURI == null
  -                                     || 
!namespaceURI.equals(NamespaceContext.XMLNS_URI))
  -                             || (namespaceURI!=null && 
namespaceURI.equals(NamespaceContext.XMLNS_URI)
  -                                     && !qname.equals("xmlns"))) {
  -                             String msg =
  -                                     DOMMessageFormatter.formatMessage(
  -                                             DOMMessageFormatter.DOM_DOMAIN,
  -                                             "NAMESPACE_ERR",
  -                                             null);
  -                             throw new DOMException(DOMException.NAMESPACE_ERR, 
msg);
  +                     if (ownerDocument.errorChecking) {
  +                         ownerDocument.checkQName(null, localName);
  +                         if (qname.equals("xmlns")
  +                             && (namespaceURI == null
  +                             || !namespaceURI.equals(NamespaceContext.XMLNS_URI))
  +                             || (namespaceURI!=null && 
namespaceURI.equals(NamespaceContext.XMLNS_URI)
  +                             && !qname.equals("xmlns"))) {
  +                             String msg =
  +                                 DOMMessageFormatter.formatMessage(
  +                                         DOMMessageFormatter.DOM_DOMAIN,
  +                                         "NAMESPACE_ERR",
  +                                         null);
  +                             throw new DOMException(DOMException.NAMESPACE_ERR, 
msg);
  +                         }
                        }
                }//there is a prefix
                else {
  -            prefix = qname.substring(0, colon1);
  -
  -            //NAMESPACE_ERR:
  -            //1. if the qualifiedName has a prefix and the namespaceURI is null,
  -
  -            //2. or if the qualifiedName has a prefix that is "xml" and the 
namespaceURI
  -            //is different from " http://www.w3.org/XML/1998/namespace";
  -
  -            if( namespaceURI == null || ( prefix.equals("xml") && 
!namespaceURI.equals(NamespaceContext.XML_URI) )){
  -                             String msg =
  -                                     DOMMessageFormatter.formatMessage(
  -                                             DOMMessageFormatter.DOM_DOMAIN,
  -                                             "NAMESPACE_ERR",
  -                                             null);
  -                             throw new DOMException(DOMException.NAMESPACE_ERR, 
msg);
  -            }
  -
  -                     localName = qname.substring(colon2 + 1);
  -                     ownerDocument().checkQName(prefix, localName);
  -                     ownerDocument().checkDOMNSErr(prefix, namespaceURI);
  +                 prefix = qname.substring(0, colon1);
  +                 localName = qname.substring(colon2 + 1);
  +                 
  +                 //NAMESPACE_ERR:
  +                 //1. if the qualifiedName has a prefix and the namespaceURI is 
null,
  +                 
  +                 //2. or if the qualifiedName has a prefix that is "xml" and the 
namespaceURI
  +                 //is different from " http://www.w3.org/XML/1998/namespace";
  +                 
  +                 if (ownerDocument.errorChecking) {
  +                     if( namespaceURI == null || ( prefix.equals("xml") && 
!namespaceURI.equals(NamespaceContext.XML_URI) )){
  +                         String msg =
  +                             DOMMessageFormatter.formatMessage(
  +                                     DOMMessageFormatter.DOM_DOMAIN,
  +                                     "NAMESPACE_ERR",
  +                                     null);
  +                         throw new DOMException(DOMException.NAMESPACE_ERR, msg);
  +                     }
  +                     
  +                     ownerDocument.checkQName(prefix, localName);
  +                     ownerDocument.checkDOMNSErr(prefix, namespaceURI);
  +                 }
                }
        }
   
  @@ -285,7 +289,7 @@
           if (needsSyncData()) {
               synchronizeData();
           }
  -        if (ownerDocument().errorChecking) {
  +        if (ownerDocument.errorChecking) {
               if (isReadOnly()) {
                   String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
                   throw new DOMException(
  @@ -293,7 +297,7 @@
                                        msg);
               }
               if (prefix != null && prefix.length() != 0) {
  -                if 
(!CoreDocumentImpl.isXMLName(prefix,ownerDocument().isXML11Version())) {
  +                if 
(!CoreDocumentImpl.isXMLName(prefix,ownerDocument.isXML11Version())) {
                       String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"INVALID_CHARACTER_ERR", null);
                       throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
                   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to