Author: sandygao
Date: Mon Dec  5 21:34:37 2011
New Revision: 1210650

URL: http://svn.apache.org/viewvc?rev=1210650&view=rev
Log:
Fix the last few schema 1.1 failures: a) unrecognized block names in regular 
expressions are not errors; they match all characters. b) new rules about '-' 
in regular expressions. c) wildcard unions are always expressible d) override 
allows simple type and complex type have the same name. Only the actual match 
will be used. The other is ignored.

Modified:
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/ParserForXMLSchema.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/REUtil.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/RegexParser.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/RegularExpression.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/Token.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS11Constraints.java

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java?rev=1210650&r1=1210649&r2=1210650&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
 Mon Dec  5 21:34:37 2011
@@ -889,8 +889,11 @@ public class XSSimpleTypeDecl implements
             } else {
                 patternAnnotations = facets.patternAnnotations;
                 RegularExpression regex = null;
+                // In schema 1.1, enable the new behavior for '-' and
+                // unrecognized block names.
+                final String options = 
context.getTypeValidatorHelper().isXMLSchema11() ? "Xbh" : "X";
                 try {
-                    regex = new RegularExpression(facets.pattern, "X", 
context.getLocale(), context.getDatatypeXMLVersion());
+                    regex = new RegularExpression(facets.pattern, options, 
context.getLocale(), context.getDatatypeXMLVersion());
                 } catch (Exception e) {
                     reportError("InvalidRegex", new Object[]{facets.pattern, 
e.getLocalizedMessage()});
                 }

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties?rev=1210650&r1=1210649&r2=1210650&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
 Mon Dec  5 21:34:37 2011
@@ -154,7 +154,6 @@
         src-import.3.2 = src-import.3.2: An <import> element information item 
that had no namespace attribute was found, so the imported document cannot have 
a targetNamespace attribute. However, the targetNamespace ''{1}'' was found in 
the imported document.
         src-include.1 = src-include.1: The root element of document ''{0}'' 
has to have the namespace name ''http://www.w3.org/2001/XMLSchema'' and the 
local name ''schema''.
         src-override.2.1 = src-override.2.1: The targetNamespace of the 
overridden schema, currently ''{1}'', must be identical to that of the 
overriding schema, currently ''{0}''.
-        src-override-transformation.1 = src-override-transformation.1: A 
''{0}'' definition with the name ''{2}'' cannot override a ''{1}'' definition 
with the same name.
         src-override-collision.1 = src-override-collision.1: The schema id 
''{0}'' referenced by <{1}> is colliding with an already overridden schema. 
Referenced schema is being ignored.
         src-override-collision.2 = src-override-collision.2: The override 
transformation of schema id ''{0}'' collides with an existing schema that was 
previously included, redefined, or overridden. Transformed schema is being 
ignored and override will not take place.
         src-include.2.1 = src-include.2.1: The targetNamespace of the 
referenced schema, currently ''{1}'', must be identical to that of the 
including schema, currently ''{0}''.

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/ParserForXMLSchema.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/ParserForXMLSchema.java?rev=1210650&r1=1210649&r2=1210650&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/ParserForXMLSchema.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/ParserForXMLSchema.java
 Mon Dec  5 21:34:37 2011
@@ -175,6 +175,7 @@ class ParserForXMLSchema extends RegexPa
      * @return This returns no NrageToken.
      */
     protected RangeToken parseCharacterClass(boolean useNrange) throws 
ParseException {
+        boolean hyphen11 = isSet(RegularExpression.HYPHEN_IN_SCHEMA_11);
         this.setContext(S_INBRACKETS);
         this.next();                            // '['
         boolean nrange = false;
@@ -224,7 +225,14 @@ class ParserForXMLSchema extends RegexPa
                   case 'P':
                     int pstart = this.offset;
                     RangeToken tok2 = this.processBacksolidus_pP(c);
-                    if (tok2 == null)  throw this.ex("parser.atom.5", pstart);
+                    if (tok2 == null) {
+                        if 
(this.isSet(RegularExpression.ALLOW_UNRECOGNIZED_BLOCK_NAME)) {
+                            tok2 = Token.token_all;
+                        }
+                        else {
+                            throw this.ex("parser.atom.5", pstart);
+                        }
+                    }
                     tok.mergeRanges(tok2);
                     end = true;
                     break;
@@ -255,9 +263,9 @@ class ParserForXMLSchema extends RegexPa
                 if (type == T_CHAR) {
                     if (c == '[')  throw this.ex("parser.cc.6", this.offset-2);
                     if (c == ']')  throw this.ex("parser.cc.7", this.offset-2);
-                    if (c == '-' && this.chardata != ']' && !firstloop)  throw 
this.ex("parser.cc.8", this.offset-2);  // if regex = '[-]' then invalid
+                    if (!hyphen11 && c == '-' && this.chardata != ']' && 
!firstloop)  throw this.ex("parser.cc.8", this.offset-2);     // if regex = 
'[-]' then invalid
                 }
-                if (this.read() != T_CHAR || this.chardata != '-' || c == '-' 
&& !wasDecoded && firstloop) { // Here is no '-'.
+                if (this.read() != T_CHAR || this.chardata != '-' || !hyphen11 
&& c == '-' && !wasDecoded && firstloop) { // Here is no '-'.
                     if (!this.isSet(RegularExpression.IGNORE_CASE) || c > 
0xffff) {
                         tok.addRange(c, c);
                     }
@@ -269,7 +277,8 @@ class ParserForXMLSchema extends RegexPa
                     this.next(); // Skips '-'
                     if ((type = this.read()) == T_EOF)  throw 
this.ex("parser.cc.2", this.offset);
                                                 // c '-' ']' -> '-' is a 
single-range.
-                    if(type == T_CHAR && this.chardata == ']') {               
                // if - is at the last position of the group
+                    if(type == T_CHAR && this.chardata == ']' ||
+                       hyphen11 && type == T_XMLSCHEMA_CC_SUBTRACTION) {       
                        // if - is at the last position of the group
                         if (!this.isSet(RegularExpression.IGNORE_CASE) || c > 
0xffff) {
                            tok.addRange(c, c);
                         }
@@ -281,6 +290,9 @@ class ParserForXMLSchema extends RegexPa
                     else if (type == T_XMLSCHEMA_CC_SUBTRACTION) {
                         throw this.ex("parser.cc.8", this.offset-1);
                     } else {
+                        if (hyphen11 && c == '-' && !wasDecoded) {
+                            throw this.ex("parser.cc.4", this.offset-2);
+                        }
                        
                         int rangeend = this.chardata;
                         if (type == T_CHAR) {

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/REUtil.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/REUtil.java?rev=1210650&r1=1210649&r2=1210650&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/REUtil.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/REUtil.java
 Mon Dec  5 21:34:37 2011
@@ -90,6 +90,11 @@ public final class REUtil {
           case ',':
             ret = RegularExpression.SPECIAL_COMMA;
             break;
+          case 'b':
+            ret = RegularExpression.ALLOW_UNRECOGNIZED_BLOCK_NAME;
+            break;
+          case 'h':
+            ret = RegularExpression.HYPHEN_IN_SCHEMA_11;
           default:
         }
         return ret;

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/RegexParser.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/RegexParser.java?rev=1210650&r1=1210649&r2=1210650&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/RegexParser.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/RegexParser.java
 Mon Dec  5 21:34:37 2011
@@ -805,7 +805,14 @@ class RegexParser {
               case 'p':
                 int pstart = this.offset;
                 tok = processBacksolidus_pP(this.chardata);
-                if (tok == null)  throw this.ex("parser.atom.5", pstart);
+                if (tok == null) {
+                    if 
(this.isSet(RegularExpression.ALLOW_UNRECOGNIZED_BLOCK_NAME)) {
+                        tok = Token.token_all;
+                    }
+                    else {
+                        throw this.ex("parser.atom.5", pstart);
+                    }
+                }
                 break;
 
               default:
@@ -912,7 +919,14 @@ class RegexParser {
                   case 'P':
                     int pstart = this.offset;
                     RangeToken tok2 = this.processBacksolidus_pP(c);
-                    if (tok2 == null)  throw this.ex("parser.atom.5", pstart);
+                    if (tok2 == null) {
+                        if 
(this.isSet(RegularExpression.ALLOW_UNRECOGNIZED_BLOCK_NAME)) {
+                            tok2 = Token.token_all;
+                        }
+                        else {
+                            throw this.ex("parser.atom.5", pstart);
+                        }
+                    }
                     tok.mergeRanges(tok2);
                     end = true;
                     break;

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/RegularExpression.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/RegularExpression.java?rev=1210650&r1=1210649&r2=1210650&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/RegularExpression.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/RegularExpression.java
 Mon Dec  5 21:34:37 2011
@@ -2226,6 +2226,14 @@ public class RegularExpression implement
      * ",".
      */
     static final int SPECIAL_COMMA = 1<<10;
+    /**
+     * "b". Allow unrecognized block names; treat as '.'.
+     */
+    static final int ALLOW_UNRECOGNIZED_BLOCK_NAME = 1<<11;
+    /**
+     * "h". New rule about '-' in schema 1.1.
+     */
+    static final int HYPHEN_IN_SCHEMA_11 = 1<<12;
 
 
     private static final boolean isSet(int options, int flag) {

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/Token.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/Token.java?rev=1210650&r1=1210649&r2=1210650&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/Token.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xpath/regex/Token.java
 Mon Dec  5 21:34:37 2011
@@ -59,6 +59,7 @@ class Token implements java.io.Serializa
 
     final int type;
 
+    static RangeToken token_all;
     static Token token_dot;
     static Token token_0to9;
     static Token token_wordchars;
@@ -78,6 +79,9 @@ class Token implements java.io.Serializa
     static Token token_wordbeginning;
     static Token token_wordend;
     static {
+        token_all = Token.createRange();
+        token_all.addRange(0, UTF16_MAX);
+
         Token.token_empty = new Token(Token.EMPTY);
 
         Token.token_linebeginning = Token.createAnchor('^');

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS11Constraints.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS11Constraints.java?rev=1210650&r1=1210649&r2=1210650&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS11Constraints.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS11Constraints.java
 Mon Dec  5 21:34:37 2011
@@ -398,20 +398,7 @@ class XS11Constraints extends XSConstrai
         unionWildcard.fDisallowedNamesList = disallowedNamesUnion(wildcard, 
otherWildcard);
 
         // 3 The keyword defined if it is contained in both O1's and O2's 
{disallowed names}.;
-        // 4 If one {disallowed names} (assume it is from O1 without losing 
generality) contains defined and the other
-        //   one (from O2) does not, and there exists a namespace name or 
absent that is allowed by O1, as defined
-        //   in Wildcard allows Namespace Name (3.10.4.), but not by O2, then 
the wildcard union is not expressible.
         unionWildcard.fDisallowedDefined = wildcard.fDisallowedDefined && 
otherWildcard.fDisallowedDefined;
-        if (wildcard.fDisallowedDefined != otherWildcard.fDisallowedDefined) {
-            if (wildcard.fDisallowedDefined) {
-                if (disallowedNamespaces(wildcard, otherWildcard)) {
-                    return null;
-                }
-            }
-            else if (disallowedNamespaces(otherWildcard, wildcard)){
-                return null;
-            }
-        }
 
         return unionWildcard;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to