You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2001/10/09 23:36:18 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2 SchemaValidator.java

elena       01/10/09 14:36:18

  Modified:    java/src/org/apache/xerces/impl/v2 SchemaValidator.java
  Log:
  fix NPE in default attributes. Add temporary solution to resolve xsd file locations.
  
  Revision  Changes    Path
  1.20      +18 -20    xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaValidator.java
  
  Index: SchemaValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaValidator.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- SchemaValidator.java	2001/10/04 19:57:48	1.19
  +++ SchemaValidator.java	2001/10/09 21:36:18	1.20
  @@ -109,7 +109,7 @@
    * @author Andy Clark, IBM
    * @author Jeffrey Rodriguez IBM
    *
  - * @version $Id: SchemaValidator.java,v 1.19 2001/10/04 19:57:48 elena Exp $
  + * @version $Id: SchemaValidator.java,v 1.20 2001/10/09 21:36:18 elena Exp $
    */
   public class SchemaValidator
       implements XMLComponent, XMLDocumentFilter {
  @@ -117,7 +117,7 @@
       //
       // Constants
       //
  -    private static final boolean DEBUG = false;
  +    private static final boolean DEBUG = true;
       // feature identifiers
   
       /** Feature identifier: validation. */
  @@ -142,6 +142,11 @@
       protected static final String ENTITY_RESOLVER =
           Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
   
  +
  +    // REVISIT: this is just a temporary solution for entity resolver
  +    //          while we are making a decision
  +    protected static final String ENTITY_MANAGER =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
       // recognized features and properties
   
       /** Recognized features. */
  @@ -179,6 +184,7 @@
       /** Entity resolver */
       protected XMLEntityResolver fEntityResolver;
   
  +
       // handlers
   
       /** Document handler. */
  @@ -809,17 +815,8 @@
           fSymbolTable = symbolTable;
   
           // get entity resolver. if there is no one, create a default
  -        // REVISIT: why there is no default one already?
  -        fEntityResolver = (XMLEntityResolver)componentManager.getProperty(ENTITY_RESOLVER);
  -        if (fEntityResolver == null)
  -            fEntityResolver = new XMLEntityResolver() {
  -                // REVISIT: what's the default dehavior
  -                public XMLInputSource resolveEntity(String publicId, String systemId,
  -                                                    String baseSystemId)
  -                    throws XNIException, IOException {
  -                    return new XMLInputSource(null, systemId, baseSystemId);
  -                }
  -            };
  +        // REVISIT: use default entity resolution from ENTITY MANAGER - temporary solution        
  +        fEntityResolver = (XMLEntityResolver)componentManager.getProperty(ENTITY_MANAGER);
   
           // initialize namespace support
           fNamespaceSupport.reset(fSymbolTable);
  @@ -1395,7 +1392,9 @@
           // (2) report error for PROHIBITED attrs that are present (V_TAGc)
           // (3) add default attrs (FIXED and NOT_FIXED)
           //
  -
  +        if (DEBUG) {
  +            System.out.println("addDefaultAttributes: " + element);
  +        }
           XSAttributeUse attrUses[] = attrGrp.getAttributeUses();
           int useCount = attrUses.length;
           XSAttributeUse currUse;
  @@ -1404,12 +1403,10 @@
           Object defaultValue;
           boolean isSpecified;
           QName attName;
  -
           // for each attribute use
           for (int i = 0; i < useCount; i++) {
               currUse = attrUses[i];
               currDecl = currUse.fAttrDecl;
  -
               // get value constraint
               constType = currUse.fConstraintType;
               defaultValue = currUse.fDefault;
  @@ -1417,23 +1414,24 @@
                   constType = currDecl.fConstraintType;
                   defaultValue = currDecl.fDefault;
               }
  -
               // whether this attribute is specified
               isSpecified = attributes.getValue(currDecl.fTargetNamespace, currDecl.fName) != null;
  -
  +            
               // Element Locally Valid (Complex Type)
               // 4 The {attribute declaration} of each attribute use in the {attribute uses} whose {required} is true matches one of the attribute information items in the element information item's [attributes] as per clause 3.1 above.
               if (currUse.fUse == SchemaSymbols.USE_REQUIRED) {
                   if (!isSpecified)
                       reportSchemaError("cvc-complex-type.4", new Object[]{element.rawname, currDecl.fName});
               }
  -
               // if the attribute is not specified, then apply the value constraint
               if (!isSpecified && constType != XSAttributeDecl.NO_CONSTRAINT) {
  +                
                   attName = new QName(null, currDecl.fName, currDecl.fName, currDecl.fTargetNamespace);
                   //REVISIT: what's the proper attrType?
  -                attributes.addAttribute(attName, null, defaultValue.toString());
  +                attributes.addAttribute(attName, null, (defaultValue !=null)?defaultValue.toString():"");
               }
  +
  +            
           } // for
       } // addDefaultAttributes
   
  
  
  

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