You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by lm...@apache.org on 2001/03/13 20:33:19 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/validators/common XMLValidator.java

lmartin     01/03/13 11:33:19

  Modified:    java/src/org/apache/xerces/validators/common
                        XMLValidator.java
  Log:
  validation error checking for abstract
  
  Revision  Changes    Path
  1.127     +37 -1     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.126
  retrieving revision 1.127
  diff -u -r1.126 -r1.127
  --- XMLValidator.java	2001/03/07 22:21:49	1.126
  +++ XMLValidator.java	2001/03/13 19:33:15	1.127
  @@ -121,7 +121,7 @@
   /**
    * This class is the super all-in-one validator used by the parser.
    *
  - * @version $Id: XMLValidator.java,v 1.126 2001/03/07 22:21:49 elena Exp $
  + * @version $Id: XMLValidator.java,v 1.127 2001/03/13 19:33:15 lmartin Exp $
    */
   public final class XMLValidator
       implements DefaultEntityHandler.EventHandler,
  @@ -3154,10 +3154,46 @@
                                                     "unresolved type : "+uri+","+localpart 
                                                     +" found  in xsi:type handling");
                     } else
  +
  +                     //
  +                     // The type must not be abstract
  +                     //
  +                     if (typeInfo.isAbstract) {
  +                        reportRecoverableXMLError(XMLMessages.MSG_GENERIC_SCHEMA_ERROR,
  +                               XMLMessages.SCHEMA_GENERIC_ERROR, 
  +                               "Abstract type " + xsiType + " should not be used in xsi:type"); 
  +                     }
  +
                        elementIndex = typeInfo.templateElementIndex;
                  }
   
                  fXsiTypeAttValue = -1;
  +            }
  +
  +            else {
  +               //
  +               // xsi:type was not specified...
  +               // If the corresponding type is abstract, detect an error
  +               //
  +               TraverseSchema.ComplexTypeInfo typeInfo =
  +                 ((SchemaGrammar) fGrammar).getElementComplexTypeInfo(elementIndex);
  +
  +               if (typeInfo != null && typeInfo.isAbstract) {
  +                  reportRecoverableXMLError(XMLMessages.MSG_GENERIC_SCHEMA_ERROR,
  +                   XMLMessages.SCHEMA_GENERIC_ERROR,
  +                   "Element " + fStringPool.toString(element.rawname) + " is declared with a type that is abstract.  Use xsi:type to specify a non-abstract type");
  +               }
  +            }
  +               
  +
  +            //
  +            // Check whether this element is abstract.  If so, an error
  +            //
  +            int miscFlags = ((SchemaGrammar) fGrammar).getElementDeclMiscFlags(elementIndex);
  +            if ((miscFlags & SchemaSymbols.ABSTRACT) != 0) {
  +              reportRecoverableXMLError(XMLMessages.MSG_GENERIC_SCHEMA_ERROR,
  +                XMLMessages.SCHEMA_GENERIC_ERROR,
  +                "A member of abstract element " + fStringPool.toString(element.rawname) + "'s substitution group must be specified");
               }
   
               //Change the current scope to be the one defined by this element.
  
  
  

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