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/08/08 20:20:20 UTC

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

neilg       01/08/08 11:20:19

  Modified:    java/src/org/apache/xerces/msg XMLMessages.java
               java/src/org/apache/xerces/utils XMLMessages.java
               java/src/org/apache/xerces/framework XMLDocumentScanner.java
               java/src/org/apache/xerces/validators/common
                        XMLValidator.java
  Log:
  implementation by Jeremy Carroll of the fix for bug 2793 proposed by Glenn Marcy
  
  Revision  Changes    Path
  1.5       +2 -1      xml-xerces/java/src/org/apache/xerces/msg/XMLMessages.java
  
  Index: XMLMessages.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/msg/XMLMessages.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLMessages.java	2001/07/12 16:01:56	1.4
  +++ XMLMessages.java	2001/08/08 18:20:19	1.5
  @@ -96,7 +96,8 @@
       // 2.9 Standalone Document Declaration
           { "SDDeclInvalid", "The standalone document declaration value must be \"yes\" or \"no\", not \"{0}\"." },
       // 2.12 Language Identification
  -        { "XMLLangInvalid", "The xml:lang attribute value \"{0}\" is an invalid language identifier." },
  +    // Deleted see http://www.w3.org/XML/xml-19980210-errata#E73 and bug 2793
  +
       // 3. Logical Structures
           { "ETagRequired", "The element type \"{0}\" must be terminated by the matching end-tag \"</{0}>\"." },
       // 3.1 Start-Tags, End-Tags, and Empty-Element Tags
  
  
  
  1.5       +5 -10     xml-xerces/java/src/org/apache/xerces/utils/XMLMessages.java
  
  Index: XMLMessages.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/utils/XMLMessages.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLMessages.java	2001/07/12 16:02:01	1.4
  +++ XMLMessages.java	2001/08/08 18:20:19	1.5
  @@ -206,7 +206,7 @@
           MSG_ENTITY_NOT_DECLARED = 62,      //  entity was not declared
           MSG_REFERENCE_TO_UNPARSED_ENTITY = 63,
           MSG_REFERENCE_TO_EXTERNAL_ENTITY = 64,
  -        MSG_XML_LANG_INVALID = 65,         //  xml:lang attribute value does not match LanguageID production
  +        MSG_AVAILABLE0  = 65,         
           MSG_CDSECT_UNTERMINATED = 66,      //  CDATA sections must end with "]]>"
           MSG_DUPLICATE_TYPE_IN_MIXED_CONTENT = 67,
           MSG_ELEMENT_ENTITY_MISMATCH = 68,
  @@ -382,7 +382,7 @@
           "EntityNotDeclared",            //  62, "The entity \"{0}\" was referenced, but not declared."
           "ReferenceToUnparsedEntity",    //  63, "The unparsed entity reference \"&{0};\" is not permitted."
           "ReferenceToExternalEntity",    //  64, "The external entity reference \"&{0};\" is not permitted in an attribute value."
  -        "XMLLangInvalid",               //  65, "The xml:lang attribute value \"{0}\" is an invalid language identifier."
  +        "MSG_AVAILABLE0",               //  65, 
           "CDSectUnterminated",           //  66, "The CDATA section must end with \"]]>\"."
           "DuplicateTypeInMixedContent",  //  67, "The element type \"{0}\" was already specified in this content model."
           "ElementEntityMismatch",        //  68, "The element \"{0}\" must start and end within the same entity."
  @@ -557,6 +557,7 @@
           VC_ENTITY_DECLARED = 62,            // 4.1 [68] The entity was referenced, but not declared
           WFC_PARSED_ENTITY = 63,             // 4.1 [68] An unparsed entity was referenced
           WFC_NO_EXTERNAL_ENTITY_REFERENCES = 64, // 3.1 [42] reference to external entity in AttValue
  +        // xml:lang no longer checked http://www.w3.org/XML/xml-19980210-errata#E73
           P33_INVALID = 65,                   // 2.12 [33] xml:lang attribute value must match LanguageID production
           P18_UNTERMINATED = 66,              // 2.7 [18] CDATA sections must end with "]]>"
           VC_NO_DUPLICATE_TYPES = 67,         // 3.2.2 [51] The same type must not appear more than once in a mixed content declaration
  @@ -968,14 +969,8 @@
                          "Attribute values cannot contain direct or indirect entity references to\n" +
                          "external entities."),
       // P33_INVALID = 65
  -        new Constraint("2.12", "[33]", "2.12 [33] LanguageID ::= Langcode ('-' Subcode)*",
  -                       "[33] LanguageID ::= Langcode ('-' Subcode)*\n" +
  -                       "[34] Langcode ::= ISO639Code |  IanaCode |  UserCode\n" +
  -                       "[35] ISO639Code ::= ([a-z] | [A-Z]) ([a-z] | [A-Z])\n" +
  -                       "[36] IanaCode ::= ('i' | 'I') '-' ([a-z] | [A-Z])+\n" +
  -                       "[37] UserCode ::= ('x' | 'X') '-' ([a-z] | [A-Z])+\n" +
  -                       "[38] Subcode ::= ([a-z] | [A-Z])+\n" +
  -                       "An xml:lang attribute value must match the LanguageID production."),
  +        new Constraint("2.12", "[33]", "2.12 (Productions 33 through 38 have been removed)",
  +                       "(Productions 33 through 38 have been removed)"),
       // P18_UNTERMINATED = 66
           new Constraint("2.7", "[18]", "2.7 [18] CDSect ::= CDStart CData CDEnd",
                          "[18] CDSect ::= CDStart CData CDEnd\n" +
  
  
  
  1.12      +1 -57     xml-xerces/java/src/org/apache/xerces/framework/XMLDocumentScanner.java
  
  Index: XMLDocumentScanner.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/framework/XMLDocumentScanner.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XMLDocumentScanner.java	2001/02/23 23:49:15	1.11
  +++ XMLDocumentScanner.java	2001/08/08 18:20:19	1.12
  @@ -81,7 +81,7 @@
    * "connecting" that method to the corresponding method provided
    * by the XMLDTDScanner class.
    *
  - * @version $Id: XMLDocumentScanner.java,v 1.11 2001/02/23 23:49:15 lynnm Exp $
  + * @version $Id: XMLDocumentScanner.java,v 1.12 2001/08/08 18:20:19 neilg Exp $
    */
   public final class XMLDocumentScanner {
       //
  @@ -561,62 +561,6 @@
           }
           int value = fLiteralData.addString(dataOffset, dataLength);
           return value;
  -    }
  -
  -    /**
  -     * Check the value of an XML Language attribute
  -     * @param langValue the handle in the string pool of the value to be checked
  -     * @exception java.lang.Exception
  -     */
  -    public void checkXMLLangAttributeValue(int langValue) throws Exception {
  -        String lang = fStringPool.toString(langValue);
  -        int offset = -1;
  -        if (lang.length() >= 2) {
  -            char ch0 = lang.charAt(0);
  -            if (lang.charAt(1) == '-') {
  -                if (ch0 == 'i' || ch0 == 'I' || ch0 == 'x' || ch0 == 'X') {
  -                    offset = 1;
  -                }
  -            } else {
  -                char ch1 = lang.charAt(1);
  -                if (((ch0 >= 'a' && ch0 <= 'z') || (ch0 >= 'A' && ch0 <= 'Z')) &&
  -                    ((ch1 >= 'a' && ch1 <= 'z') || (ch1 >= 'A' && ch1 <= 'Z'))) {
  -                        offset = 2;
  -                }
  -            }
  -        }
  -        if (offset > 0 && lang.length() > offset) {
  -            char ch = lang.charAt(offset++);
  -            if (ch != '-') {
  -                offset = -1;
  -            } else {
  -                while (true) {
  -                    if (ch == '-') {
  -                        if (lang.length() == offset) {
  -                            offset = -1;
  -                            break;
  -                        }
  -                        ch = lang.charAt(offset++);
  -                        if ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z')) {
  -                            offset = -1;
  -                            break;
  -                        }
  -                        if (lang.length() == offset)
  -                            break;
  -                    } else if ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z')) {
  -                        offset = -1;
  -                        break;
  -                    } else if (lang.length() == offset)
  -                        break;
  -                    ch = lang.charAt(offset++);
  -                }
  -            }
  -        }
  -        if (offset == -1) {
  -            reportFatalXMLError(XMLMessages.MSG_XML_LANG_INVALID,
  -                                XMLMessages.P33_INVALID,
  -                                lang);
  -        }
       }
   
       //
  
  
  
  1.185     +2 -24     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.184
  retrieving revision 1.185
  diff -u -r1.184 -r1.185
  --- XMLValidator.java	2001/07/24 16:23:20	1.184
  +++ XMLValidator.java	2001/08/08 18:20:19	1.185
  @@ -127,7 +127,7 @@
   /**
    * This class is the super all-in-one validator used by the parser.
    *
  - * @version $Id: XMLValidator.java,v 1.184 2001/07/24 16:23:20 elena Exp $
  + * @version $Id: XMLValidator.java,v 1.185 2001/08/08 18:20:19 neilg Exp $
    */
   public final class XMLValidator
       implements DefaultEntityHandler.EventHandler,
  @@ -2498,11 +2498,7 @@
               int attName = attrList.getAttrName(index);
               int attPrefix = attrList.getAttrPrefix(index);
               if (fStringPool.equalNames(attName, fXMLLang)) {
  -               /***
  -               // NOTE: This check is done in the validateElementsAndAttributes
  -               //       method.
  -               fDocumentScanner.checkXMLLangAttributeValue(attrList.getAttValue(index));
  -               /***/
  +               /*  No check: http://www.w3.org/XML/xml-19980210-errata#E73 and bug 2793 */
               } else if (fStringPool.equalNames(attName, fNamespacesPrefix)) {
                  int uri = fStringPool.addSymbol(attrList.getAttValue(index));
                  fNamespacesScope.setNamespaceForPrefix(StringPool.EMPTY_STRING, uri);
  @@ -3050,14 +3046,6 @@
                                                 XMLErrorReporter.ERRORTYPE_RECOVERABLE_ERROR);
                  }
               }
  -            int index = fAttrList.getFirstAttr(fAttrListHandle);
  -            while (index != -1) {
  -               if (fStringPool.equalNames(fAttrList.getAttrName(index), fXMLLang)) {
  -                  fDocumentScanner.checkXMLLangAttributeValue(fAttrList.getAttValue(index));
  -                  break;
  -               }
  -               index = fAttrList.getNextAttr(index);
  -            }
            }
            return;
         }
  @@ -3593,21 +3581,11 @@
               }
               System.out.println(">");
            }
  -         // REVISIT: Validation. Do we need to recheck for the xml:lang
  -         //          attribute? It was already checked above -- perhaps
  -         //          this is to check values that are defaulted in? If
  -         //          so, this check could move to the attribute decl
  -         //          callback so we can check the default value before
  -         //          it is used.
            if (fAttrListHandle != -1 && !fNeedValidationOff ) {
               int index = fAttrList.getFirstAttr(fAttrListHandle);
               while (index != -1) {
                  int attrNameIndex = attrList.getAttrName(index);
   
  -               if (fStringPool.equalNames(attrNameIndex, fXMLLang)) {
  -                  fDocumentScanner.checkXMLLangAttributeValue(attrList.getAttValue(index));
  -                  // break;
  -               }
                  // here, we validate every "user-defined" attributes
                  int _xmlns = fStringPool.addSymbol("xmlns");
   
  
  
  

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