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/11 22:06:21 UTC

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

neilg       01/06/11 13:06:20

  Modified:    java/src/org/apache/xerces/validators/common
                        XMLValidator.java
  Log:
  fix for Bugzilla bug #2035
  
  Revision  Changes    Path
  1.158     +51 -4     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.157
  retrieving revision 1.158
  diff -u -r1.157 -r1.158
  --- XMLValidator.java	2001/06/06 22:42:35	1.157
  +++ XMLValidator.java	2001/06/11 20:06:18	1.158
  @@ -124,7 +124,7 @@
   /**
    * This class is the super all-in-one validator used by the parser.
    *
  - * @version $Id: XMLValidator.java,v 1.157 2001/06/06 22:42:35 sandygao Exp $
  + * @version $Id: XMLValidator.java,v 1.158 2001/06/11 20:06:18 neilg Exp $
    */
   public final class XMLValidator
       implements DefaultEntityHandler.EventHandler,
  @@ -3214,7 +3214,16 @@
                                       "Type : "+uri+","+localpart
                                       +" does not derive from the type of element " + fStringPool.toString(tempElementDecl.name.localpart));
                               }
  -                        } else { // check if element has block set
  +                        } else { 
  +                            // if we have an attribute but xsi:type's type is simple, we have a problem...
  +                            if (tempVal != null && fXsiTypeValidator != null &&
  +                                    (fGrammar.getFirstAttributeDeclIndex(elementIndex) != -1)) {
  +                                reportRecoverableXMLError(XMLMessages.MSG_GENERIC_SCHEMA_ERROR,
  +                                    XMLMessages.SCHEMA_GENERIC_ERROR,
  +                                    "Type : "+uri+","+localpart
  +                                    +" does not derive from the type of element " + fStringPool.toString(tempElementDecl.name.localpart));
  +                            }
  +                            // check if element has block set
                               if((((SchemaGrammar)fGrammar).getElementDeclBlockSet(elementIndex) & SchemaSymbols.RESTRICTION) != 0) {
                                   reportRecoverableXMLError(XMLMessages.MSG_GENERIC_SCHEMA_ERROR,
                                       XMLMessages.SCHEMA_GENERIC_ERROR,
  @@ -3249,8 +3258,46 @@
                                       "Type : "+uri+","+localpart
                                       +" does not derive from the type " + destType.typeName);
                            } else if (destType == null) {
  -                         // TO BE DONE:
  -                         // if the original type is a simple type, check derivation ok.
  +                            // if the original type is a simple type, check derivation ok.
  +                            XMLElementDecl tempElementDecl = new XMLElementDecl();
  +                            fGrammar.getElementDecl(elementIndex, tempElementDecl);
  +                            DatatypeValidator ancestorValidator = tempElementDecl.datatypeValidator;
  +                            DatatypeValidator tempVal = fXsiTypeValidator;
  +                            for(; tempVal != null; tempVal = tempVal.getBaseValidator())
  +                                // WARNING!!!  Comparison by reference.
  +                                if(tempVal == ancestorValidator) break;
  +                            if(tempVal == null) {
  +                                // now if ancestorValidator is a union, then we must
  +                                // look through its members to see whether we derive from any of them.
  +			                    if(ancestorValidator instanceof UnionDatatypeValidator) {
  +			                        // fXsiTypeValidator must derive from one of its members...
  +			                        Vector subUnionMemberDV = ((UnionDatatypeValidator)ancestorValidator).getBaseValidators();
  +			                        int subUnionSize = subUnionMemberDV.size();
  +			                        boolean found = false;
  +			                        for (int i=0; i<subUnionSize && !found; i++) {
  +			                            DatatypeValidator dTempSub = (DatatypeValidator)subUnionMemberDV.elementAt(i);
  +			                            DatatypeValidator dTemp = fXsiTypeValidator;
  +			                            for(; dTemp != null; dTemp = dTemp.getBaseValidator()) {
  +			                                // WARNING!!!  This uses comparison by reference andTemp is thus inherently suspect!
  +			                                if(dTempSub == dTemp) {
  +			                                    found = true;
  +			                                    break;
  +			                                }
  +			                            }
  +			                        }
  +			                        if(!found) {
  +                                        reportRecoverableXMLError(XMLMessages.MSG_GENERIC_SCHEMA_ERROR,
  +                                            XMLMessages.SCHEMA_GENERIC_ERROR,
  +                                            "Type : "+uri+","+localpart
  +                                            +" does not derive from the type of element " + fStringPool.toString(tempElementDecl.name.localpart));
  +			                        }
  +			                    } else {
  +                                    reportRecoverableXMLError(XMLMessages.MSG_GENERIC_SCHEMA_ERROR,
  +                                        XMLMessages.SCHEMA_GENERIC_ERROR,
  +                                        "Type : "+uri+","+localpart
  +                                        +" does not derive from the type of element " + fStringPool.toString(tempElementDecl.name.localpart));
  +                                }
  +                            }
                            } else if (typeInfo != destType) { // now check whether the element or typeInfo's baseType blocks us.
                               int derivationMethod = typeInfo.derivedBy;
                               if((((SchemaGrammar)fGrammar).getElementDeclBlockSet(elementIndex) & derivationMethod) != 0) {
  
  
  

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