mrglavas    2004/12/15 15:48:49

  Modified:    java/src/org/apache/xerces/parsers
                        StandardParserConfiguration.java
                        XML11Configuration.java
               java/src/org/apache/xerces/impl/xs/traversers
                        XSDHandler.java XSDAbstractTraverser.java
                        XSDocumentInfo.java XSDElementTraverser.java
               java/src/org/apache/xerces/impl/xs SchemaGrammar.java
                        XMLSchemaValidator.java XMLSchemaLoader.java
  Added:       java/src/org/apache/xerces/impl/xs/traversers
                        XSAnnotationInfo.java
  Log:
  Initial cut at support for validating annotations. This is controlled under
  a new feature: http://apache.org/xml/features/validate-annotations.
  When this feature is enabled during schema processing, all of the
  annotations from the root schema document and its subordinates
  will be validated once they've been fully traversed against all of the
  available schema grammars, including a partial schema for schemas
  containing the relevant declarations for annotations.
  
  Revision  Changes    Path
  1.35      +8 -2      
xml-xerces/java/src/org/apache/xerces/parsers/StandardParserConfiguration.java
  
  Index: StandardParserConfiguration.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/StandardParserConfiguration.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- StandardParserConfiguration.java  24 Feb 2004 23:15:56 -0000      1.34
  +++ StandardParserConfiguration.java  15 Dec 2004 23:48:47 -0000      1.35
  @@ -90,6 +90,10 @@
       /** feature identifier: XML Schema validation -- full checking */
       protected static final String XMLSCHEMA_FULL_CHECKING = 
       Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;
  +    
  +    /** Feature identifier: validate annotations */
  +    protected static final String VALIDATE_ANNOTATIONS =
  +        Constants.XERCES_FEATURE_PREFIX + 
Constants.VALIDATE_ANNOTATIONS_FEATURE;
   
       // property identifiers
   
  @@ -169,7 +173,8 @@
           final String[] recognizedFeatures = {
               NORMALIZE_DATA,
               SCHEMA_ELEMENT_DEFAULT,
  -            SCHEMA_AUGMENT_PSVI, 
  +            SCHEMA_AUGMENT_PSVI,
  +            VALIDATE_ANNOTATIONS,
               // NOTE: These shouldn't really be here but since the XML Schema
               //       validator is constructed dynamically, its recognized
               //       features might not have been set and it would cause a
  @@ -183,6 +188,7 @@
           setFeature(SCHEMA_ELEMENT_DEFAULT, true);
           setFeature(NORMALIZE_DATA, true);
           setFeature(SCHEMA_AUGMENT_PSVI, true);
  +        setFeature(VALIDATE_ANNOTATIONS, false);
   
           // add default recognized properties
       
  
  
  
  1.19      +7 -1      
xml-xerces/java/src/org/apache/xerces/parsers/XML11Configuration.java
  
  Index: XML11Configuration.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/XML11Configuration.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- XML11Configuration.java   22 Jul 2004 21:15:20 -0000      1.18
  +++ XML11Configuration.java   15 Dec 2004 23:48:47 -0000      1.19
  @@ -134,6 +134,10 @@
       /** feature identifier: XML Schema validation -- full checking */
       protected static final String XMLSCHEMA_FULL_CHECKING =
           Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;
  +    
  +    /** Feature identifier: validate annotations */
  +    protected static final String VALIDATE_ANNOTATIONS =
  +        Constants.XERCES_FEATURE_PREFIX + 
Constants.VALIDATE_ANNOTATIONS_FEATURE;
           
        // feature identifiers
   
  @@ -430,6 +434,7 @@
                                VALIDATION,                 
                                NAMESPACES,
                   NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI,
  +                VALIDATE_ANNOTATIONS,
                // NOTE: These shouldn't really be here but since the XML Schema
                //       validator is constructed dynamically, its recognized
                //       features might not have been set and it would cause a
  @@ -450,6 +455,7 @@
                fFeatures.put(SCHEMA_ELEMENT_DEFAULT, Boolean.TRUE);
                fFeatures.put(NORMALIZE_DATA, Boolean.TRUE);
                fFeatures.put(SCHEMA_AUGMENT_PSVI, Boolean.TRUE);
  +        fFeatures.put(VALIDATE_ANNOTATIONS, Boolean.FALSE);
                fFeatures.put(PARSER_SETTINGS, Boolean.TRUE);
   
           // add default recognized properties
  
  
  
  1.82      +168 -13   
xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
  
  Index: XSDHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- XSDHandler.java   6 Oct 2004 15:14:46 -0000       1.81
  +++ XSDHandler.java   15 Dec 2004 23:48:48 -0000      1.82
  @@ -17,6 +17,8 @@
   package org.apache.xerces.impl.xs.traversers;
   
   import java.io.IOException;
  +import java.io.StringReader;
  +import java.util.ArrayList;
   import java.util.Hashtable;
   import java.util.Stack;
   import java.util.Vector;
  @@ -41,12 +43,16 @@
   import org.apache.xerces.impl.xs.opti.ElementImpl;
   import org.apache.xerces.impl.xs.opti.SchemaParsingConfig;
   import org.apache.xerces.impl.xs.util.SimpleLocator;
  +import org.apache.xerces.parsers.XML11Configuration;
   import org.apache.xerces.util.DefaultErrorHandler;
   import org.apache.xerces.util.DOMUtil;
   import org.apache.xerces.util.SymbolTable;
   import org.apache.xerces.util.XMLSymbols;
   import org.apache.xerces.xni.QName;
  +import org.apache.xerces.xni.grammars.Grammar;
  +import org.apache.xerces.xni.grammars.XMLGrammarDescription;
   import org.apache.xerces.xni.grammars.XMLGrammarPool;
  +import org.apache.xerces.xni.grammars.XMLSchemaDescription;
   import org.apache.xerces.xni.parser.XMLComponentManager;
   import org.apache.xerces.xni.parser.XMLConfigurationException;
   import org.apache.xerces.xni.parser.XMLEntityResolver;
  @@ -73,6 +79,14 @@
    */
   public class XSDHandler {
   
  +    /** Feature identifier: validation. */
  +    protected static final String VALIDATION =
  +        Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
  +    
  +    /** feature identifier: XML Schema validation */
  +    protected static final String XMLSCHEMA_VALIDATION =
  +        Constants.XERCES_FEATURE_PREFIX + 
Constants.SCHEMA_VALIDATION_FEATURE;
  +    
       /** Feature identifier:  allow java encodings */
       protected static final String ALLOW_JAVA_ENCODINGS =
           Constants.XERCES_FEATURE_PREFIX + 
Constants.ALLOW_JAVA_ENCODINGS_FEATURE;
  @@ -88,6 +102,10 @@
       /** Feature: disallow doctype*/
       protected static final String DISALLOW_DOCTYPE =
           Constants.XERCES_FEATURE_PREFIX + 
Constants.DISALLOW_DOCTYPE_DECL_FEATURE;
  +    
  +    /** Feature identifier: validate annotations. */
  +    protected static final String VALIDATE_ANNOTATIONS =
  +        Constants.XERCES_FEATURE_PREFIX + 
Constants.VALIDATE_ANNOTATIONS_FEATURE;
   
       /** Property identifier: error handler. */
       protected static final String ERROR_HANDLER =
  @@ -239,6 +257,9 @@
       // a variable storing whether the last schema document
       // processed (by getSchema) was a duplicate.
       private boolean fLastSchemaWasDuplicate;
  +    
  +    // validate annotations feature
  +    private boolean fValidateAnnotations = false;
   
       // the XMLErrorReporter
       private XMLErrorReporter fErrorReporter;
  @@ -273,6 +294,8 @@
   
       //DOMParser fSchemaParser;
       SchemaParsingConfig fSchemaParser;
  +    XML11Configuration fAnnotationValidator;
  +    XSAnnotationGrammarPool fGrammarBucketAdapter;
   
       // these data members are needed for the deferred traversal
       // of local elements.
  @@ -410,7 +433,8 @@
           buildGlobalNameRegistries();
   
           // third phase:  call traversers
  -        traverseSchemas();
  +        ArrayList annotationInfo = fValidateAnnotations ? new ArrayList() : 
null;
  +        traverseSchemas(annotationInfo);
   
           // fourth phase: handle local element decls
           traverseLocalElements();
  @@ -447,10 +471,47 @@
               // set the imported grammars
               sg.setImportedGrammars(ins);
           }
  +        
  +        /** validate annotations **/
  +        if (fValidateAnnotations && annotationInfo.size() > 0) {
  +            validateAnnotations(annotationInfo);
  +        }
   
           // and return.
           return fGrammarBucket.getGrammar(fRoot.fTargetNamespace);
       } // end parseSchema
  +    
  +    private void validateAnnotations(ArrayList annotationInfo) {
  +        if (fAnnotationValidator == null) {
  +            createAnnotationValidator();
  +        }
  +        final int size = annotationInfo.size();
  +        final XMLInputSource src = new XMLInputSource(null, null, null);
  +        fGrammarBucketAdapter.refreshGrammars(fGrammarBucket);
  +        for (int i = 0; i < size; i += 2) {
  +            src.setSystemId((String) annotationInfo.get(i));
  +            XSAnnotationInfo annotation = (XSAnnotationInfo) 
annotationInfo.get(i+1);
  +            while (annotation != null) {
  +                src.setCharacterStream(new 
StringReader(annotation.fAnnotation));
  +                try {
  +                    fAnnotationValidator.parse(src);
  +                }
  +                catch (IOException exc) {}
  +                annotation = annotation.next;
  +            }
  +        }
  +    }
  +    
  +    private void createAnnotationValidator() {
  +        fAnnotationValidator = new XML11Configuration();
  +        fGrammarBucketAdapter = new XSAnnotationGrammarPool();
  +        fAnnotationValidator.setFeature(VALIDATION, true);
  +        fAnnotationValidator.setFeature(XMLSCHEMA_VALIDATION, true);
  +        fAnnotationValidator.setProperty(XMLGRAMMAR_POOL, 
fGrammarBucketAdapter);
  +        /** Set error handler. **/
  +        XMLErrorHandler errorHandler = fErrorReporter.getErrorHandler();
  +        fAnnotationValidator.setProperty(ERROR_HANDLER, (errorHandler != 
null) ? errorHandler : new DefaultErrorHandler());
  +    }
   
       /**
        * Pull the grammar out of the bucket simply using
  @@ -941,7 +1002,7 @@
       // as traversed (or hidden) in order to avoid infinite loops.  It 
completes
       // when it has visited all XSDocumentInfo objects in the
       // DependencyMap and marked them as traversed.
  -    protected void traverseSchemas() {
  +    protected void traverseSchemas(ArrayList annotationInfo) {
           // the process here is very similar to that in
           // buildGlobalRegistries, except we can't set our schemas as
           // hidden for a second time; so make them all visible again
  @@ -1028,6 +1089,17 @@
                       reportSchemaError("s4s-elt-invalid-content.1", new 
Object [] {SchemaSymbols.ELT_SCHEMA, DOMUtil.getLocalName(globalComp)}, 
globalComp);
                   }
               } // end for
  +            
  +            /** Collect annotation information for validation. **/
  +            if (annotationInfo != null) {
  +                XSAnnotationInfo info = currSchemaDoc.getAnnotations();
  +                /** Only add annotations to the list if there were any in 
this document. **/
  +                if (info != null) {
  +                    annotationInfo.add(doc2SystemId(currDoc));
  +                    annotationInfo.add(info);
  +                }
  +            }
  +            currSchemaDoc.removeAnnotations();
   
               // now we're done with this one!
               currSchemaDoc.returnSchemaAttrs();
  @@ -1038,6 +1110,7 @@
                   schemasToProcess.push(currSchemaDepends.elementAt(i));
               }
           } // while
  +        
       } // end traverseSchemas
   
       // store whether we have reported an error about that no grammar
  @@ -1554,16 +1627,16 @@
   
           // reset traversers
           fAttributeChecker.reset(fSymbolTable);
  -        fAttributeGroupTraverser.reset(fSymbolTable);
  -        fAttributeTraverser.reset(fSymbolTable);
  -        fComplexTypeTraverser.reset(fSymbolTable);
  -        fElementTraverser.reset(fSymbolTable);
  -        fGroupTraverser.reset(fSymbolTable);
  -        fKeyrefTraverser.reset(fSymbolTable);
  -        fNotationTraverser.reset(fSymbolTable);
  -        fSimpleTypeTraverser.reset(fSymbolTable);
  -        fUniqueOrKeyTraverser.reset(fSymbolTable);
  -        fWildCardTraverser.reset(fSymbolTable);
  +        fAttributeGroupTraverser.reset(fSymbolTable, fValidateAnnotations);
  +        fAttributeTraverser.reset(fSymbolTable, fValidateAnnotations);
  +        fComplexTypeTraverser.reset(fSymbolTable, fValidateAnnotations);
  +        fElementTraverser.reset(fSymbolTable, fValidateAnnotations);
  +        fGroupTraverser.reset(fSymbolTable, fValidateAnnotations);
  +        fKeyrefTraverser.reset(fSymbolTable, fValidateAnnotations);
  +        fNotationTraverser.reset(fSymbolTable, fValidateAnnotations);
  +        fSimpleTypeTraverser.reset(fSymbolTable, fValidateAnnotations);
  +        fUniqueOrKeyTraverser.reset(fSymbolTable, fValidateAnnotations);
  +        fWildCardTraverser.reset(fSymbolTable, fValidateAnnotations);
   
           fRedefinedRestrictedAttributeGroupRegistry.clear();
           fRedefinedRestrictedGroupRegistry.clear();
  @@ -1593,9 +1666,18 @@
               // property unless it's actually changed.
               if (currErrorHandler != 
fSchemaParser.getProperty(ERROR_HANDLER)) {
                   fSchemaParser.setProperty(ERROR_HANDLER, (currErrorHandler 
!= null) ? currErrorHandler : new DefaultErrorHandler());
  +                if (fAnnotationValidator != null) {
  +                    fAnnotationValidator.setProperty(ERROR_HANDLER, 
(currErrorHandler != null) ? currErrorHandler : new DefaultErrorHandler());
  +                }
               }
           } catch (XMLConfigurationException e) {
           }
  +        
  +        try {
  +            fValidateAnnotations = 
componentManager.getFeature(VALIDATE_ANNOTATIONS);
  +        } catch (XMLConfigurationException e) {
  +            fValidateAnnotations = false;
  +        }
   
           try {
               fSchemaParser.setFeature(
  @@ -2134,6 +2216,79 @@
               fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                                          key, args, 
XMLErrorReporter.SEVERITY_WARNING);
           }
  +    }
  +    
  +    /** 
  +     * Grammar pool used for validating annotations. This will return all of 
the
  +     * grammars from the grammar bucket. It will also return an object for 
the
  +     * schema for schemas which will contain at least the relevant 
declarations
  +     * for annotations.
  +     */
  +    private static class XSAnnotationGrammarPool implements XMLGrammarPool {
  +        
  +        private XSGrammarBucket fGrammarBucket;
  +        private Grammar [] fInitialGrammarSet;
  +        
  +        public Grammar[] retrieveInitialGrammarSet(String grammarType) {
  +            if (grammarType == XMLGrammarDescription.XML_SCHEMA) {
  +                if (fInitialGrammarSet == null) {
  +                    if (fGrammarBucket == null) {
  +                        fInitialGrammarSet = new Grammar [] 
{SchemaGrammar.SG_Schema4Annotations};
  +                    }
  +                    else {
  +                        SchemaGrammar [] schemaGrammars = 
fGrammarBucket.getGrammars();
  +                        /** 
  +                         * If the grammar bucket already contains the schema 
for schemas
  +                         * then we already have the definitions for the 
parts relevant
  +                         * to annotations.
  +                         */
  +                        for (int i = 0; i < schemaGrammars.length; ++i) {
  +                            if 
(SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(schemaGrammars[i].getTargetNamespace()))
 {
  +                                fInitialGrammarSet = schemaGrammars;
  +                                return fInitialGrammarSet;
  +                            }
  +                        }
  +                        Grammar [] grammars = new 
Grammar[schemaGrammars.length + 1];
  +                        System.arraycopy(schemaGrammars, 0, grammars, 0, 
schemaGrammars.length);
  +                        grammars[grammars.length - 1] = 
SchemaGrammar.SG_Schema4Annotations;
  +                        fInitialGrammarSet = grammars;
  +                    }
  +                }
  +                return fInitialGrammarSet;
  +            }
  +            return new Grammar[0];
  +        }
  +
  +        public void cacheGrammars(String grammarType, Grammar[] grammars) {
  +            
  +        }
  +
  +        public Grammar retrieveGrammar(XMLGrammarDescription desc) {
  +            if (desc.getGrammarType() == XMLGrammarDescription.XML_SCHEMA) {
  +                final String tns = ((XMLSchemaDescription) 
desc).getTargetNamespace();
  +                if (fGrammarBucket != null) {
  +                    Grammar grammar = fGrammarBucket.getGrammar(tns);
  +                    if (grammar != null) {
  +                        return grammar;
  +                    }
  +                }
  +                if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(tns)) {
  +                    return SchemaGrammar.SG_Schema4Annotations;
  +                }
  +            }
  +            return null;
  +        }
  +        
  +        public void refreshGrammars(XSGrammarBucket gBucket) {
  +            fGrammarBucket = gBucket;
  +            fInitialGrammarSet = null;
  +        }
  +
  +        public void lockPool() {}
  +
  +        public void unlockPool() {}
  +
  +        public void clear() {}
       }
   
       /**
  
  
  
  1.39      +12 -3     
xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
  
  Index: XSDAbstractTraverser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- XSDAbstractTraverser.java 28 Oct 2004 21:06:19 -0000      1.38
  +++ XSDAbstractTraverser.java 15 Dec 2004 23:48:48 -0000      1.39
  @@ -78,6 +78,7 @@
       protected XSDHandler            fSchemaHandler = null;
       protected SymbolTable           fSymbolTable = null;
       protected XSAttributeChecker    fAttrChecker = null;
  +    protected boolean               fValidateAnnotations = false;
   
       // used to validate default/fixed attribute values
       ValidationState fValidationState = new ValidationState();
  @@ -88,8 +89,9 @@
           fAttrChecker = attrChecker;
       }
   
  -    void reset(SymbolTable symbolTable) {
  +    void reset(SymbolTable symbolTable, boolean validateAnnotations) {
           fSymbolTable = symbolTable;
  +        fValidateAnnotations = validateAnnotations;
           fValidationState.setExtraChecking(false);
           fValidationState.setSymbolTable(symbolTable);
       }
  @@ -192,8 +194,15 @@
               contentBuffer.append(contents.substring(0,annotationTokenEnd));
               contentBuffer.append(localStrBuffer.toString());
               contentBuffer.append(contents.substring(annotationTokenEnd, 
contents.length()));
  -            return new XSAnnotationImpl(contentBuffer.toString(), grammar);
  +            final String annotation = contentBuffer.toString();
  +            if (fValidateAnnotations) {
  +                schemaDoc.addAnnotation(new XSAnnotationInfo(annotation, 
annotationDecl));
  +            }
  +            return new XSAnnotationImpl(annotation, grammar);
           } else {
  +            if (fValidateAnnotations) {
  +                schemaDoc.addAnnotation(new XSAnnotationInfo(contents, 
annotationDecl));
  +            }
               return new XSAnnotationImpl(contents, grammar);
           }
   
  
  
  
  1.20      +22 -1     
xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDocumentInfo.java
  
  Index: XSDocumentInfo.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDocumentInfo.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- XSDocumentInfo.java       6 Oct 2004 15:14:48 -0000       1.19
  +++ XSDocumentInfo.java       15 Dec 2004 23:48:48 -0000      1.20
  @@ -80,6 +80,10 @@
       // array of objects on the schema's root element.  This is null
       // once returnSchemaAttrs has been called.
       protected Object [] fSchemaAttrs;
  +    
  +    // list of annotations contained in the schema document. This is null
  +    // once removeAnnotations has been called.
  +    protected XSAnnotationInfo fAnnotations = null;
   
       // note that the caller must ensure to call returnSchemaAttrs()
       // to avoid memory leaks!
  @@ -182,6 +186,23 @@
       void returnSchemaAttrs () {
           fAttrChecker.returnAttrArray (fSchemaAttrs, null);
           fSchemaAttrs = null;
  +    }
  +    
  +    // adds an annotation to the list of annotations
  +    void addAnnotation(XSAnnotationInfo info) {
  +        info.next = fAnnotations;
  +        fAnnotations = info;
  +    }
  +    
  +    // returns the list of annotations conatined in the
  +    // schema document or null if the document contained no annotations.
  +    XSAnnotationInfo getAnnotations() {
  +        return fAnnotations;
  +    }
  +    
  +    // removes reference to annotation list
  +    void removeAnnotations() {
  +        fAnnotations = null;
       }
       
   } // XSDocumentInfo
  
  
  
  1.32      +3 -3      
xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
  
  Index: XSDElementTraverser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- XSDElementTraverser.java  6 Oct 2004 15:14:48 -0000       1.31
  +++ XSDElementTraverser.java  15 Dec 2004 23:48:48 -0000      1.32
  @@ -461,8 +461,8 @@
           return element;
       }
   
  -    void reset(SymbolTable symbolTable) {
  -        super.reset(symbolTable);
  +    void reset(SymbolTable symbolTable, boolean validateAnnotations) {
  +        super.reset(symbolTable, validateAnnotations);
           fDeferTraversingLocalElements = true;
       } // reset()
   
  
  
  
  1.1                  
xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSAnnotationInfo.java
  
  Index: XSAnnotationInfo.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.xerces.impl.xs.traversers;
  
  import org.w3c.dom.Element;
  import org.apache.xerces.impl.xs.opti.ElementImpl;
  
  /**
   * Objects of this class contain the textual representation of
   * an XML schema annotation as well as information on the location
   * of the annotation in the document it originated from.
   * 
   * @xerces.internal
   * 
   * @author Michael Glavassevich, IBM
   * @version $Id: XSAnnotationInfo.java,v 1.1 2004/12/15 23:48:48 mrglavas Exp 
$
   */
  final class XSAnnotationInfo {
  
      /** Textual representation of annotation. **/
      String fAnnotation;
      
      /** Line number of &lt;annotation&gt; element. **/
      int fLine;
      
      /** Column number of &lt;annotation&gt; element. **/
      int fColumn;
      
      /** Character offset of &lt;annotation&gt; element. **/
      int fCharOffset;
      
      /** Next annotation. **/
      XSAnnotationInfo next;
      
      XSAnnotationInfo(String annotation, int line, int column, int charOffset) 
{
          fAnnotation = annotation;
          fLine = line;
          fColumn = column;
          fCharOffset = charOffset;
      }
      
      XSAnnotationInfo(String annotation, Element annotationDecl) {
          fAnnotation = annotation;
          if (annotationDecl instanceof ElementImpl) {
              final ElementImpl annotationDeclImpl = (ElementImpl) 
annotationDecl;
              fLine = annotationDeclImpl.getLineNumber();
              fColumn = annotationDeclImpl.getColumnNumber();
              fCharOffset = annotationDeclImpl.getCharacterOffset();
          }
          else {
              fLine = -1;
              fColumn = -1;
              fCharOffset = -1;
          }
      }
  } // XSAnnotationInfo
  
  
  
  1.42      +3 -1      
xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java
  
  Index: SchemaGrammar.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- SchemaGrammar.java        9 Nov 2004 23:35:51 -0000       1.41
  +++ SchemaGrammar.java        15 Dec 2004 23:48:48 -0000      1.42
  @@ -902,6 +902,8 @@
   
       // the grammars to hold components of the schema namespace
       public final static BuiltinSchemaGrammar SG_SchemaNS = new 
BuiltinSchemaGrammar(GRAMMAR_XS);
  +    
  +    public final static Schema4Annotations SG_Schema4Annotations = new 
Schema4Annotations();
   
       public final static XSSimpleType fAnySimpleType = 
(XSSimpleType)SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE);
   
  
  
  
  1.162     +8 -2      
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.161
  retrieving revision 1.162
  diff -u -r1.161 -r1.162
  --- XMLSchemaValidator.java   28 Oct 2004 05:42:51 -0000      1.161
  +++ XMLSchemaValidator.java   15 Dec 2004 23:48:48 -0000      1.162
  @@ -142,6 +142,10 @@
       /** Feature identifier: standard uri conformant feature. */
       protected static final String STANDARD_URI_CONFORMANT_FEATURE =
           Constants.XERCES_FEATURE_PREFIX + 
Constants.STANDARD_URI_CONFORMANT_FEATURE;
  +    
  +    /** Feature identifier: validate annotations. */
  +    protected static final String VALIDATE_ANNOTATIONS =
  +        Constants.XERCES_FEATURE_PREFIX + 
Constants.VALIDATE_ANNOTATIONS_FEATURE;
   
       /** Feature identifier: whether to continue parsing a schema after a 
fatal error is encountered */
       protected static final String CONTINUE_AFTER_FATAL_ERROR =
  @@ -201,7 +205,8 @@
               SCHEMA_FULL_CHECKING,
               ALLOW_JAVA_ENCODINGS,
               CONTINUE_AFTER_FATAL_ERROR,
  -            STANDARD_URI_CONFORMANT_FEATURE };
  +            STANDARD_URI_CONFORMANT_FEATURE,
  +            VALIDATE_ANNOTATIONS};
   
       /** Feature defaults. */
       private static final Boolean[] FEATURE_DEFAULTS = { null,
  @@ -216,6 +221,7 @@
           null, //Boolean.FALSE,
           null, //Boolean.FALSE,
           null, //Boolean.FALSE,
  +        null,
           null };
   
       /** Recognized properties. */
  
  
  
  1.32      +8 -2      
xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
  
  Index: XMLSchemaLoader.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- XMLSchemaLoader.java      8 Dec 2004 22:49:05 -0000       1.31
  +++ XMLSchemaLoader.java      15 Dec 2004 23:48:48 -0000      1.32
  @@ -109,6 +109,10 @@
       /** Feature identifier: standard uri conformant feature. */
       protected static final String STANDARD_URI_CONFORMANT_FEATURE =
           Constants.XERCES_FEATURE_PREFIX + 
Constants.STANDARD_URI_CONFORMANT_FEATURE;
  +    
  +    /** Feature identifier: validate annotations. */
  +    protected static final String VALIDATE_ANNOTATIONS =
  +        Constants.XERCES_FEATURE_PREFIX + 
Constants.VALIDATE_ANNOTATIONS_FEATURE;
           
       /** Feature: disallow doctype*/
       protected static final String DISALLOW_DOCTYPE = 
  @@ -128,7 +132,8 @@
           CONTINUE_AFTER_FATAL_ERROR,
           ALLOW_JAVA_ENCODINGS,
           STANDARD_URI_CONFORMANT_FEATURE, 
  -        DISALLOW_DOCTYPE
  +        DISALLOW_DOCTYPE,
  +        VALIDATE_ANNOTATIONS
       };
   
       // property identifiers
  @@ -1080,6 +1085,7 @@
               boolean state = ((Boolean)value).booleanValue();
               if (name.equals(Constants.DOM_VALIDATE) ||
                   name.equals(SCHEMA_FULL_CHECKING) ||
  +                name.equals(VALIDATE_ANNOTATIONS) ||
                   name.equals(CONTINUE_AFTER_FATAL_ERROR) ||
                   name.equals(ALLOW_JAVA_ENCODINGS) ||
                   name.equals(STANDARD_URI_CONFORMANT_FEATURE)) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to