You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2002/07/17 16:02:02 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs XMLSchemaValidator.java ElementPSVImpl.java AttributePSVImpl.java

sandygao    2002/07/17 07:02:02

  Modified:    java/src/org/apache/xerces/impl/xs XMLSchemaValidator.java
                        ElementPSVImpl.java AttributePSVImpl.java
  Log:
  1. Resend 4 PSVI properties on endElement: element declaration,
  type definition, notation, and validation context. Now all element PSVI
  properties are available on endElement calls.
  2. Fixed a bug in the method getSchemaDefault().
  
  Revision  Changes    Path
  1.76      +33 -23    xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
  
  Index: XMLSchemaValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- XMLSchemaValidator.java	12 Jul 2002 15:49:49 -0000	1.75
  +++ XMLSchemaValidator.java	17 Jul 2002 14:02:01 -0000	1.76
  @@ -585,13 +585,6 @@
   
           Augmentations modifiedAugs = handleStartElement(element, attributes, augs);
   
  -        // we need to save PSVI information: because it will be reset in the
  -        // handleEndElement(): decl, type, notation, validation context
  -        XSElementDecl decl = fCurrentPSVI.fDeclaration;
  -        XSTypeDecl type = fCurrentPSVI.fTypeDecl;
  -        XSNotationDecl notation = fCurrentPSVI.fNotation;
  -        String vContext = fCurrentPSVI.fValidationContext;
  -
           // in the case where there is a {value constraint}, and the element
           // doesn't have any text content, change emptyElement call to
           // start + characters + end
  @@ -599,11 +592,6 @@
   
           // call handlers
           if (fDocumentHandler != null) {
  -            fCurrentPSVI.fDeclaration = decl;
  -            fCurrentPSVI.fTypeDecl = type;
  -            fCurrentPSVI.fNotation = notation;
  -            fCurrentPSVI.fValidationContext = vContext;
  -
               if (!fSchemaElementDefault || fDefaultValue == null) {
                   fDocumentHandler.emptyElement(element, attributes, modifiedAugs);
               } else {
  @@ -611,7 +599,7 @@
                   fDocumentHandler.characters(fDefaultValue, modifiedAugs);
                   fDocumentHandler.endElement(element, modifiedAugs);
               }
  -       }
  +        }
       } // emptyElement(QName,XMLAttributes, Augmentations)
   
       /**
  @@ -1113,6 +1101,12 @@
       /** nil value stack */
       boolean[] fNilStack = new boolean[INITIAL_STACK_SIZE];
   
  +    /** notation value of the current element */
  +    XSNotationDecl fNotation;
  +    
  +    /** notation stack */
  +    XSNotationDecl[] fNotationStack = new XSNotationDecl[INITIAL_STACK_SIZE];
  +    
       /** Current type. */
       XSTypeDecl fCurrentType;
   
  @@ -1338,6 +1332,7 @@
           // initialize state
           fCurrentElemDecl = null;
           fNil = false;
  +        fNotation = null;
           fCurrentPSVI = null;
           fCurrentType = null;
           fCurrentCM = null;
  @@ -1461,6 +1456,10 @@
               System.arraycopy(fNilStack, 0, newArrayB, 0, fElementDepth);
               fNilStack = newArrayB;
   
  +            XSNotationDecl[] newArrayN = new XSNotationDecl[newSize];
  +            System.arraycopy(fNotationStack, 0, newArrayN, 0, fElementDepth);
  +            fNotationStack = newArrayN;
  +            
               XSTypeDecl[] newArrayT = new XSTypeDecl[newSize];
               System.arraycopy(fTypeStack, 0, newArrayT, 0, fElementDepth);
               fTypeStack = newArrayT;
  @@ -1829,6 +1828,7 @@
               fChildCount = 0;
               fElemDeclStack[fElementDepth] = fCurrentElemDecl;
               fNilStack[fElementDepth] = fNil;
  +            fNotationStack[fElementDepth] = fNotation;
               fTypeStack[fElementDepth] = fCurrentType;
               fCMStack[fElementDepth] = fCurrentCM;
               fCMStateStack[fElementDepth] = fCurrCMState;
  @@ -1843,6 +1843,7 @@
           XSWildcardDecl wildcard = null;
           fCurrentType = null;
           fNil = false;
  +        fNotation = null;
   
           // and the buffer to hold the value of the element
           fBuffer.setLength(0);
  @@ -2060,6 +2061,7 @@
                   fChildCount = fChildCountStack[fElementDepth];
                   fCurrentElemDecl = fElemDeclStack[fElementDepth];
                   fNil = fNilStack[fElementDepth];
  +                fNotation = fNotationStack[fElementDepth];
                   fCurrentType = fTypeStack[fElementDepth];
                   fCurrentCM = fCMStack[fElementDepth];
                   fCurrCMState = fCMStateStack[fElementDepth];
  @@ -2091,6 +2093,11 @@
               return augs;
           }
   
  +        fCurrentPSVI.fDeclaration = this.fCurrentElemDecl;
  +        fCurrentPSVI.fTypeDecl = this.fCurrentType;
  +        fCurrentPSVI.fNotation = this.fNotation;
  +        fCurrentPSVI.fValidationContext = this.fValidationRoot;
  +
           // now validate the content of the element
           XMLString defaultValue = processElementContent(element);
   
  @@ -2175,6 +2182,7 @@
               fChildCount = fChildCountStack[fElementDepth];
               fCurrentElemDecl = fElemDeclStack[fElementDepth];
               fNil = fNilStack[fElementDepth];
  +            fNotation = fNotationStack[fElementDepth];
               fCurrentType = fTypeStack[fElementDepth];
               fCurrentCM = fCMStack[fElementDepth];
               fCurrCMState = fCMStateStack[fElementDepth];
  @@ -2611,17 +2619,19 @@
               // PSVI: element notation
               if (attDV.getVariety() == XSSimpleType.VARIETY_ATOMIC &&
                   attDV.getPrimitiveKind() == XSSimpleType.PRIMITIVE_NOTATION){
  -               QName qName = (QName)actualValue;
  -               SchemaGrammar grammar = fGrammarBucket.getGrammar(qName.uri);
  +                QName qName = (QName)actualValue;
  +                SchemaGrammar grammar = fGrammarBucket.getGrammar(qName.uri);
       
  -               //REVISIT: is it possible for the notation to be in different namespace than the attribute
  -               //with which it is associated, CHECK !!  <fof n1:att1 = "n2:notation1" ..>
  -               // should we give chance to the application to be able to  retrieve a grammar - nb
  -               //REVISIT: what would be the triggering component here.. if it is attribute value that
  -               // triggered the loading of grammar ?? -nb
  +                //REVISIT: is it possible for the notation to be in different namespace than the attribute
  +                //with which it is associated, CHECK !!  <fof n1:att1 = "n2:notation1" ..>
  +                // should we give chance to the application to be able to  retrieve a grammar - nb
  +                //REVISIT: what would be the triggering component here.. if it is attribute value that
  +                // triggered the loading of grammar ?? -nb
       
  -               if (grammar != null)
  -                   fCurrentPSVI.fNotation = grammar.getGlobalNotationDecl(qName.localpart);
  +                if (grammar != null) {
  +                    fNotation = grammar.getGlobalNotationDecl(qName.localpart);
  +                    fCurrentPSVI.fNotation = fNotation;
  +                }
               }
           }
           catch (InvalidDatatypeValueException idve) {
  
  
  
  1.17      +5 -9      xml-xerces/java/src/org/apache/xerces/impl/xs/ElementPSVImpl.java
  
  Index: ElementPSVImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/ElementPSVImpl.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ElementPSVImpl.java	17 Jun 2002 18:41:45 -0000	1.16
  +++ ElementPSVImpl.java	17 Jul 2002 14:02:01 -0000	1.17
  @@ -78,10 +78,10 @@
   public class ElementPSVImpl implements ElementPSVI {
   
       /** element declaration */
  -    protected XSElementDecl fDeclaration = null;
  +    protected XSElementDeclaration fDeclaration = null;
   
       /** type of element, could be xsi:type */
  -    protected XSTypeDecl fTypeDecl = null;
  +    protected XSTypeDefinition fTypeDecl = null;
   
       /** true if clause 3.2 of Element Locally Valid (Element) (3.3.4) 
         * is satisfied, otherwise false 
  @@ -96,10 +96,10 @@
       protected String fNormalizedValue = null;
   
       /** http://www.w3.org/TR/xmlschema-1/#e-notation*/
  -    protected XSNotationDecl fNotation = null;
  +    protected XSNotationDeclaration fNotation = null;
   
       /** member type definition against which element was validated */
  -    protected XSSimpleType fMemberType = null;
  +    protected XSSimpleTypeDefinition fMemberType = null;
   
       /** validation attempted: none, partial, full */
       protected short fValidationAttempted = ElementPSVI.VALIDATION_NONE;
  @@ -127,11 +127,7 @@
        * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
        */
       public String getSchemaDefault() {
  -        Object dValue = null;
  -        if( fDeclaration !=null ) {
  -            dValue = fDeclaration.fDefault;
  -        }
  -        return(dValue != null)?dValue.toString():null;
  +        return fDeclaration == null ? null : fDeclaration.getConstraintValue();
       }
   
       /**
  
  
  
  1.11      +5 -9      xml-xerces/java/src/org/apache/xerces/impl/xs/AttributePSVImpl.java
  
  Index: AttributePSVImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/AttributePSVImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AttributePSVImpl.java	17 Jun 2002 18:41:45 -0000	1.10
  +++ AttributePSVImpl.java	17 Jul 2002 14:02:01 -0000	1.11
  @@ -75,10 +75,10 @@
   public class AttributePSVImpl implements AttributePSVI {
   
       /** attribute declaration */
  -    protected XSAttributeDecl fDeclaration = null;
  +    protected XSAttributeDeclaration fDeclaration = null;
   
       /** type of attribute, simpleType */
  -    protected XSTypeDecl fTypeDecl = null;
  +    protected XSTypeDefinition fTypeDecl = null;
   
       /** If this attribute was explicitly given a 
        * value in the original document, this is true; otherwise, it is false  */
  @@ -88,7 +88,7 @@
       protected String fNormalizedValue = null;
   
       /** member type definition against which attribute was validated */
  -    protected XSSimpleType fMemberType = null;
  +    protected XSSimpleTypeDefinition fMemberType = null;
   
       /** validation attempted: none, partial, full */
       protected short fValidationAttempted = AttributePSVI.VALIDATION_NONE;
  @@ -112,12 +112,8 @@
        * @return The canonical lexical representation of the declaration's {value constraint} value.
        * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
        */
  -    public String   getSchemaDefault() {
  -        Object dValue = null;
  -        if( fDeclaration !=null ) {
  -            dValue = fDeclaration.fDefault;
  -        }
  -        return(dValue != null)?dValue.toString():null;
  +    public String getSchemaDefault() {
  +        return fDeclaration == null ? null : fDeclaration.getConstraintValue();
       }
   
       /**
  
  
  

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