You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2001/06/04 22:54:54 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema TraverseSchema.java

neilg       01/06/04 13:54:54

  Modified:    java/src/org/apache/xerces/validators/common
                        XMLValidator.java
               java/src/org/apache/xerces/validators/schema
                        TraverseSchema.java
  Log:
  more (hopefully the last...) bugfixes for <import> as well as a tiny bit of cleanup in XMLValidator
  
  Revision  Changes    Path
  1.156     +9 -5      xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java
  
  Index: XMLValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java,v
  retrieving revision 1.155
  retrieving revision 1.156
  diff -u -r1.155 -r1.156
  --- XMLValidator.java	2001/05/31 21:13:17	1.155
  +++ XMLValidator.java	2001/06/04 20:54:52	1.156
  @@ -124,7 +124,7 @@
   /**
    * This class is the super all-in-one validator used by the parser.
    *
  - * @version $Id: XMLValidator.java,v 1.155 2001/05/31 21:13:17 neilg Exp $
  + * @version $Id: XMLValidator.java,v 1.156 2001/06/04 20:54:52 neilg Exp $
    */
   public final class XMLValidator
       implements DefaultEntityHandler.EventHandler,
  @@ -3090,15 +3090,19 @@
                           }
                        }
                     }
  -                  if (elementIndex == -1) {
  -                     switchGrammar(fGrammarNameSpaceIndex);
  +                  // if *still* can't find it, try a grammar with no targetNamespace
  +                  if(elementIndex == -1 && element.uri == StringPool.EMPTY_STRING) {
  +                    boolean success = switchGrammar(element.uri);
  +                    if(success) {
  +                        fGrammarNameSpaceIndex = element.uri;
  +                        elementIndex = fGrammar.getElementDeclIndex(element.localpart, TOP_LEVEL_SCOPE);
  +                    }
                     }
                  }
                  //if still can't resolve it, try TOP_LEVEL_SCOPE AGAIN
                  /****/
                  if ( element.uri == StringPool.EMPTY_STRING && elementIndex == -1 
  -               && fNamespacesScope != null 
  -               && fNamespacesScope.getNamespaceForPrefix(StringPool.EMPTY_STRING) != StringPool.EMPTY_STRING ) {
  +               && fNamespacesScope != null ) {
                  elementIndex = fGrammar.getElementDeclIndex(element.localpart, TOP_LEVEL_SCOPE);
                  // REVISIT:
                  // this is a hack to handle the situation where namespace prefix "" is bound to nothing, and there
  
  
  
  1.186     +18 -1     xml-xerces/java/src/org/apache/xerces/validators/schema/TraverseSchema.java
  
  Index: TraverseSchema.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/TraverseSchema.java,v
  retrieving revision 1.185
  retrieving revision 1.186
  diff -u -r1.185 -r1.186
  --- TraverseSchema.java	2001/06/01 20:08:43	1.185
  +++ TraverseSchema.java	2001/06/04 20:54:53	1.186
  @@ -128,7 +128,7 @@
    *  
    * @see org.apache.xerces.validators.common.Grammar
    *
  - * @version $Id: TraverseSchema.java,v 1.185 2001/06/01 20:08:43 neilg Exp $
  + * @version $Id: TraverseSchema.java,v 1.186 2001/06/04 20:54:53 neilg Exp $
    */
   public class TraverseSchema implements 
                               NamespacesScope.NamespacesHandler{
  @@ -1818,8 +1818,25 @@
                return;
            }
            fImportLocations.addElement((Object)location);
  +        // check to make sure we're not importing ourselves...
  +        if(source.getSystemId().equals(fCurrentSchemaURL)) {
  +            // REVISIT:  localize
  +            return;
  +        }
   
            String namespaceString = importDecl.getAttribute(SchemaSymbols.ATT_NAMESPACE);
  +         if(namespaceString.length() == 0) {
  +            if(fTargetNSURI == StringPool.EMPTY_STRING) {
  +                // REVISIT:  localize
  +                reportGenericSchemaError("src-import.1.2:  if the namespace attribute on an <import> element is not present, the <import>ing schema must have a targetNamespace");
  +            }
  +        } else {
  +            if(fTargetNSURIString.equals(namespaceString.trim())) {
  +                // REVISIT:  localize
  +                reportGenericSchemaError("src-import.1.1:  the namespace attribute of an <import> element must not be the same as the targetNamespace of the <import>ing schema");
  +            }
  +        }  
  +                
            SchemaGrammar importedGrammar = (SchemaGrammar) fGrammarResolver.getGrammar(namespaceString);
   
            if (importedGrammar == null) {
  
  
  

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