You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2008/10/23 23:12:24 UTC
svn commit: r707475 [2/2] - in
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl: msg/
xs/ xs/models/ xs/traversers/
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XSDFACM.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XSDFACM.java?rev=707475&r1=707474&r2=707475&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XSDFACM.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XSDFACM.java Thu Oct 23 14:12:24 2008
@@ -23,6 +23,7 @@
import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.dtd.models.CMNode;
import org.apache.xerces.impl.dtd.models.CMStateSet;
+import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
import org.apache.xerces.impl.xs.SubstitutionGroupHandler;
import org.apache.xerces.impl.xs.XMLSchemaException;
@@ -268,7 +269,7 @@
*
* @exception RuntimeException thrown on error
*/
- public Object oneTransition(QName curElem, int[] state, SubstitutionGroupHandler subGroupHandler) {
+ public Object oneTransition(QName curElem, int[] state, SubstitutionGroupHandler subGroupHandler, SchemaGrammar grammar) {
int curState = state[0];
if(curState == XSCMValidator.FIRST_ERROR || curState == XSCMValidator.SUBSEQUENT_ERROR) {
@@ -282,14 +283,13 @@
}
// apply open content - suffix mode
else if (state[3] == STATE_SUFFIX) {
- if (fOpenContent.fWildcard.allowQName(curElem)) {
+ if (allowExpandedName(fOpenContent.fWildcard, curElem, subGroupHandler, grammar)) {//if (fOpenContent.fWildcard.allowQName(curElem)) {
return fOpenContent;
}
- else {
- state[1] = curState;
- state[0] = XSCMValidator.FIRST_ERROR;
- return findMatchingDecl(curElem, subGroupHandler);
- }
+
+ state[1] = curState;
+ state[0] = XSCMValidator.FIRST_ERROR;
+ return findMatchingDecl(curElem, subGroupHandler);
}
int nextState = 0;
@@ -309,15 +309,21 @@
}
}
else if (type == XSParticleDecl.PARTICLE_WILDCARD) {
- if (((XSWildcardDecl)fElemMap[elemIndex]).allowNamespace(curElem.uri)) {
+ // XML Schema 1.0
+ if (fSchemaVersion < Constants.SCHEMA_VERSION_1_1) {
+ if (((XSWildcardDecl)fElemMap[elemIndex]).allowNamespace(curElem.uri)) {
+ matchingDecl = fElemMap[elemIndex];
+ break;
+ }
+ }
+ // XML Schema 1.1
+ else if (allowExpandedName((XSWildcardDecl)fElemMap[elemIndex], curElem, subGroupHandler, grammar)) {
matchingDecl = fElemMap[elemIndex];
- // XML Schema 1.1 - and element has precedence over a wildcard
+ // Element has precedence over a wildcard
// if no occurences or we reached minOccurs, keep looking for
// and element declaration
- if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
- if (fCountingStates == null || fCountingStates[curState] == null || state[2] == fCountingStates[curState].minOccurs) {
- toMatchElementDecl = true;
- }
+ if (fCountingStates == null || fCountingStates[curState] == null || state[2] == fCountingStates[curState].minOccurs) {
+ toMatchElementDecl = true;
}
break;
}
@@ -348,30 +354,8 @@
if (matchingDecl == null) {
// XML Schema 1.1
// Validate against Open Content
- if (fOpenContent != null) {
- // if suffix mode, we should have reached a final state
- if (fOpenContent.fMode == XSOpenContentDecl.MODE_SUFFIX) {
- if (fFinalStateFlags[curState]) {
- if (fCountingStates != null) {
- Occurence o = fCountingStates[curState];
- if (o != null && state[2] < o.minOccurs) {
- // not enough loops on the current state to be considered final.
- state[1] = state[0];
- state[0] = XSCMValidator.FIRST_ERROR;
- return findMatchingDecl(curElem, subGroupHandler);
- }
- }
- state[3] = STATE_SUFFIX;
- }
- else {
- state[1] = state[0];
- state[0] = XSCMValidator.FIRST_ERROR;
- return findMatchingDecl(curElem, subGroupHandler);
- }
- }
- if (fOpenContent.fWildcard.allowQName(curElem)) {
- return fOpenContent;
- }
+ if (fOpenContent != null && matchOpenContentModel(curElem, state, subGroupHandler, curState, grammar)) {
+ return fOpenContent;
}
state[1] = state[0];
@@ -409,7 +393,7 @@
// we've already seen enough instances of the first "foo" perhaps there is
// another element declaration or wildcard deeper in the element map which
// matches.
- return findMatchingDecl(curElem, state, subGroupHandler, elemIndex);
+ return findMatchingDecl(curElem, state, subGroupHandler, elemIndex, grammar);
}
}
else if (state[2] < o.minOccurs) {
@@ -455,7 +439,7 @@
}
}
else if (type == XSParticleDecl.PARTICLE_WILDCARD) {
- if (((XSWildcardDecl)fElemMap[elemIndex]).allowNamespace(curElem.uri)) {
+ if (((XSWildcardDecl)fElemMap[elemIndex]).allowQName(curElem)) {
return fElemMap[elemIndex];
}
}
@@ -464,11 +448,12 @@
return null;
} // findMatchingDecl(QName, SubstitutionGroupHandler): Object
- Object findMatchingDecl(QName curElem, int[] state, SubstitutionGroupHandler subGroupHandler, int elemIndex) {
+ Object findMatchingDecl(QName curElem, int[] state, SubstitutionGroupHandler subGroupHandler, int elemIndex, SchemaGrammar grammar) {
int curState = state[0];
int nextState = 0;
Object matchingDecl = null;
+ boolean toMatchElementDecl = false;
while (++elemIndex < fElemMapSize) {
nextState = fTransTable[curState][elemIndex];
@@ -482,20 +467,60 @@
}
}
else if (type == XSParticleDecl.PARTICLE_WILDCARD) {
- if (((XSWildcardDecl)fElemMap[elemIndex]).allowNamespace(curElem.uri)) {
+ // XML Schema 1.0
+ if (fSchemaVersion < Constants.SCHEMA_VERSION_1_1) {
+ if (((XSWildcardDecl)fElemMap[elemIndex]).allowNamespace(curElem.uri)) {
+ matchingDecl = fElemMap[elemIndex];
+ break;
+ }
+ }
+ // XML Schema 1.1
+ else if (allowExpandedName((XSWildcardDecl)fElemMap[elemIndex], curElem, subGroupHandler, grammar)) {
matchingDecl = fElemMap[elemIndex];
+ // Element has precedence over a wildcard
+ // if no occurences or we reached minOccurs, keep looking for
+ // and element declaration
+ if (fCountingStates == null || fCountingStates[curState] == null || state[2] == fCountingStates[curState].minOccurs) {
+ toMatchElementDecl = true;
+ }
break;
}
}
}
- // if we still can't find a match, set the state to FIRST_ERROR and return null
- if (elemIndex == fElemMapSize) {
+ // XML Schema 1.1
+ // We matched against a wildcard, but need to also check
+ // if we can find a matching element declaration
+ if (toMatchElementDecl) {
+ int newState = 0;
+ Object newMatchingDecl = null;
+ while (++elemIndex < fElemMapSize) {
+ newState = fTransTable[curState][elemIndex];
+ if (newState != -1 && fElemMapType[elemIndex] == XSParticleDecl.PARTICLE_ELEMENT) {
+ newMatchingDecl = subGroupHandler.getMatchingElemDecl(curElem, (XSElementDecl)fElemMap[elemIndex]);
+ if (newMatchingDecl != null) {
+ matchingDecl = newMatchingDecl;
+ nextState = newState;
+ break;
+ }
+ }
+ }
+ }
+
+ // if we still can't find a match, set the state to first_error
+ // and return null
+ if (matchingDecl == null) {
+ // XML Schema 1.1
+ // Validate against Open Content
+ if (fOpenContent != null && matchOpenContentModel(curElem, state, subGroupHandler, curState, grammar)) {
+ return fOpenContent;
+ }
+
state[1] = state[0];
state[0] = XSCMValidator.FIRST_ERROR;
return findMatchingDecl(curElem, subGroupHandler);
}
-
+
// if we found a match, set the next state and reset the
// counter if the next state is a counting state.
state[0] = nextState;
@@ -506,6 +531,58 @@
return matchingDecl;
} // findMatchingDecl(QName, int[], SubstitutionGroupHandler, int): Object
+ XSElementDecl findMatchingElemDecl(QName curElem, SubstitutionGroupHandler subGroupHandler) {
+ XSElementDecl matchingDecl = null;
+
+ for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
+ int type = fElemMapType[elemIndex] ;
+ if (type == XSParticleDecl.PARTICLE_ELEMENT) {
+ matchingDecl = subGroupHandler.getMatchingElemDecl(curElem, (XSElementDecl)fElemMap[elemIndex]);
+ if (matchingDecl != null) {
+ return matchingDecl;
+ }
+ }
+ }
+
+ return null;
+ } // findMatchingDecl(QName, SubstitutionGroupHandler): Object
+
+ boolean allowExpandedName(XSWildcardDecl wildcard, QName curElem, SubstitutionGroupHandler subGroupHandler, SchemaGrammar grammar) {
+ if (wildcard.allowQName(curElem)) {
+ if (wildcard.fDisallowedSibling && findMatchingElemDecl(curElem, subGroupHandler) != null) {
+ return false;
+ }
+ if (wildcard.fDisallowedDefined && grammar != null && grammar.getElementDeclaration(curElem.localpart) != null) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ boolean matchOpenContentModel(QName curElem, int[] state, SubstitutionGroupHandler subGroupHandler, int curState, SchemaGrammar grammar) {
+ // if suffix mode, we should have reached a final state
+ if (fOpenContent.fMode == XSOpenContentDecl.MODE_SUFFIX) {
+ if (fFinalStateFlags[curState]) {
+ if (fCountingStates != null) {
+ Occurence o = fCountingStates[curState];
+ if (o != null && state[2] < o.minOccurs) {
+ return false;
+ }
+ }
+ state[3] = STATE_SUFFIX;
+ }
+ else {
+ return false;
+ }
+ }
+ if (allowExpandedName(fOpenContent.fWildcard, curElem, subGroupHandler, grammar)) {
+ return true;
+ }
+
+ return false;
+ }
+
// This method returns the start states of the content model.
public int[] startContentModel() {
// [0] : the current state
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XSEmptyCM.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XSEmptyCM.java?rev=707475&r1=707474&r2=707475&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XSEmptyCM.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XSEmptyCM.java Thu Oct 23 14:12:24 2008
@@ -19,6 +19,7 @@
import java.util.Vector;
+import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SubstitutionGroupHandler;
import org.apache.xerces.impl.xs.XMLSchemaException;
import org.apache.xerces.impl.xs.XSConstraints;
@@ -74,7 +75,7 @@
* @param subGroupHandler the substitution group handler
* @return element index corresponding to the element from the Schema grammar
*/
- public Object oneTransition (QName elementName, int[] currentState, SubstitutionGroupHandler subGroupHandler){
+ public Object oneTransition (QName elementName, int[] currentState, SubstitutionGroupHandler subGroupHandler, SchemaGrammar grammar){
// error state
if (currentState[0] < 0) {
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java?rev=707475&r1=707474&r2=707475&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java Thu Oct 23 14:12:24 2008
@@ -128,6 +128,8 @@
public static final int ATTIDX_DEFAULTATTRAPPLY = ATTIDX_COUNT++;
public static final int ATTIDX_DEFAULTATTRIBUTES = ATTIDX_COUNT++;
public static final int ATTIDX_MODE = ATTIDX_COUNT++;
+ public static final int ATTIDX_NOTNAMESPACE = ATTIDX_COUNT++;
+ public static final int ATTIDX_NOTQNAME = ATTIDX_COUNT++;
public static final int ATTIDX_XPATHDEFAULTNS = ATTIDX_COUNT++;
private static final XIntPool fXIntPool = new XIntPool();
@@ -224,9 +226,12 @@
protected static final int DT_BOOLEAN = -15;
protected static final int DT_NONNEGINT = -16;
protected static final int DT_POSINT = -17;
+
protected static final int DT_XPATH_DEFAULT_NS = -18;
protected static final int DT_MODE = -19;
protected static final int DT_MODE1 = -20;
+ protected static final int DT_NOTNAMESPACE = -21;
+ protected static final int DT_NOTQNAME = -22;
static {
// step 2: all possible attributes for all elements
@@ -287,6 +292,9 @@
int ATT_DEFAULT_XPATH_NS_N = attCount++;
int ATT_MODE_D = attCount++;
int ATT_MODE1_D = attCount++;
+ int ATT_NAMESPACE1_N = attCount++;
+ int ATT_NOTNAMESPACE_N = attCount++;
+ int ATT_NOTQNAME_N = attCount++;
int ATT_TEST_XPATH_R = attCount++;
// step 3: store all these attributes in an array
@@ -509,6 +517,18 @@
DT_MODE1,
ATTIDX_MODE,
INT_MODE_INTERLEAVE);
+ allAttrs[ATT_NAMESPACE1_N] = new OneAttr(SchemaSymbols.ATT_NAMESPACE,
+ DT_NAMESPACE,
+ ATTIDX_NAMESPACE,
+ null);
+ allAttrs[ATT_NOTNAMESPACE_N] = new OneAttr(SchemaSymbols.ATT_NAMESPACE,
+ DT_NOTNAMESPACE,
+ ATTIDX_NOTNAMESPACE,
+ null);
+ allAttrs[ATT_NOTQNAME_N] = new OneAttr(SchemaSymbols.ATT_NOTQNAME,
+ DT_NOTQNAME,
+ ATTIDX_NOTQNAME,
+ null);
allAttrs[ATT_TEST_XPATH_R] = new OneAttr(SchemaSymbols.ATT_TEST,
DT_XPATH1,
ATTIDX_XPATH,
@@ -721,8 +741,6 @@
// processContents = (lax | skip | strict) : strict
attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS, allAttrs[ATT_PROCESS_C_D]);
fEleAttrsMapL.put(SchemaSymbols.ELT_ANYATTRIBUTE, attrList);
- // TODO: XML Schema 1.1 different attribute list
- fEleAttrs11MapL.put(SchemaSymbols.ELT_ANYATTRIBUTE, attrList);
// for element "complexContent" - local
attrList = Container.getContainer(2);
@@ -810,8 +828,6 @@
// processContents = (lax | skip | strict) : strict
attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS, allAttrs[ATT_PROCESS_C_D]);
fEleAttrsMapL.put(SchemaSymbols.ELT_ANY, attrList);
- // TODO: XML Schema 1.1 different attribute list
- fEleAttrs11MapL.put(SchemaSymbols.ELT_ANY, attrList);
// for element "unique" - local
attrList = Container.getContainer(2);
@@ -1141,6 +1157,37 @@
attrList.put(SchemaSymbols.ATT_XPATH_DEFAULT_NS, allAttrs[ATT_DEFAULT_XPATH_NS_N]);
fEleAttrs11MapL.put(SchemaSymbols.ELT_FIELD, attrList);
+ // for element "any" - local
+ attrList = Container.getContainer(7);
+ // id = ID
+ attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
+ // maxOccurs = (nonNegativeInteger | unbounded) : 1
+ attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
+ // minOccurs = nonNegativeInteger : 1
+ attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
+ // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )
+ attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE1_N]);
+ // notNamespace = List of (anyURI | (##targetNamespace | ##local))
+ attrList.put(SchemaSymbols.ATT_NOTNAMESPACE, allAttrs[ATT_NOTNAMESPACE_N]);
+ // notQName = List of (QName | (##defined | ##definedSibling))
+ attrList.put(SchemaSymbols.ATT_NOTQNAME, allAttrs[ATT_NOTQNAME_N]);
+ // processContents = (lax | skip | strict) : strict
+ attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS, allAttrs[ATT_PROCESS_C_D]);
+ fEleAttrs11MapL.put(SchemaSymbols.ELT_ANY, attrList);
+
+ // for element "anyAttribute" - local
+ attrList = Container.getContainer(5);
+ // id = ID
+ attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
+ // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )
+ attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE1_N]);
+ // notNamespace = List of (anyURI | (##targetNamespace | ##local))
+ attrList.put(SchemaSymbols.ATT_NOTNAMESPACE, allAttrs[ATT_NOTNAMESPACE_N]);
+ // notQName = List of (QName | (##defined | ##definedSibling))
+ attrList.put(SchemaSymbols.ATT_NOTQNAME, allAttrs[ATT_NOTQNAME_N]);
+ // processContents = (lax | skip | strict) : strict
+ attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS, allAttrs[ATT_PROCESS_C_D]);
+ fEleAttrs11MapL.put(SchemaSymbols.ELT_ANYATTRIBUTE, attrList);
// new components
@@ -1737,41 +1784,7 @@
} else {
// list
retValue = INT_ANY_LIST;
-
- fNamespaceList.removeAllElements();
-
- // tokenize
- StringTokenizer tokens = new StringTokenizer(value, " \n\t\r");
- String token;
- String tempNamespace;
- try {
- while (tokens.hasMoreTokens()) {
- token = tokens.nextToken();
- if (token.equals(SchemaSymbols.ATTVAL_TWOPOUNDLOCAL)) {
- tempNamespace = null;
- } else if (token.equals(SchemaSymbols.ATTVAL_TWOPOUNDTARGETNS)) {
- tempNamespace = schemaDoc.fTargetNamespace;
- } else {
- // we have found namespace URI here
- // need to add it to the symbol table
- fExtraDVs[DT_ANYURI].validate(token, schemaDoc.fValidationContext, null);
- tempNamespace = fSymbolTable.addSymbol(token);
- }
-
- //check for duplicate namespaces in the list
- if (!fNamespaceList.contains(tempNamespace)) {
- fNamespaceList.addElement(tempNamespace);
- }
- }
- } catch (InvalidDatatypeValueException ide) {
- throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )"});
- }
-
- // convert the vector to an array
- int num = fNamespaceList.size();
- String[] list = new String[num];
- fNamespaceList.copyInto(list);
- attrValues[ATTIDX_NAMESPACE_LIST] = list;
+ attrValues[ATTIDX_NAMESPACE_LIST] = processNamespaceList(value, schemaDoc);
}
break;
case DT_PROCESSCONTENTS:
@@ -1815,6 +1828,60 @@
(dvIndex == DT_MODE1) ? new Object[]{value, "(none | interleave | suffix)"}
: new Object[]{value, "(interleave | sufix)"});
break;
+ case DT_NOTQNAME:
+ {
+ // notQName = List of (QName | (##defined| ##definedSibling))
+ if (attrValues[ATTIDX_NOTQNAME] == null) {
+ attrValues[ATTIDX_NOTQNAME] = new Vector();
+ }
+ final Vector notQNameList = (Vector)attrValues[ATTIDX_NOTQNAME];
+
+ // tokenize
+ StringTokenizer tokens = new StringTokenizer(value, " \n\t\r");
+ String token;
+ QName qname;
+ Boolean definedKeyword = Boolean.FALSE;
+ Boolean siblingKeyword = Boolean.FALSE;
+ try {
+ while (tokens.hasMoreTokens()) {
+ token = tokens.nextToken();
+ if (token.equals(SchemaSymbols.ATTVAL_TWOPOUNDDEFINED)) {
+ definedKeyword = Boolean.TRUE;
+ }
+ else if (token.equals(SchemaSymbols.ATTVAL_TWOPOUNDDEFINEDSIBLING)) {
+ siblingKeyword = Boolean.TRUE;
+ }
+ else {
+ // we have found a qname here
+ qname = (QName)fExtraDVs[DT_QNAME].validate(token, schemaDoc.fValidationContext, null);
+ // check for duplicate qnames in the list
+ if (!notQNameList.contains(qname)) {
+ notQNameList.addElement(qname);
+ }
+ }
+ }
+
+ // convert to a QName[] and add it back to the list
+ int num = notQNameList.size();
+ QName[] list = new QName[num];
+ notQNameList.copyInto(list);
+ notQNameList.clear();
+ notQNameList.add(list);
+
+ // add ##defined and ##definedSibling keyword to the list
+ notQNameList.add(definedKeyword);
+ notQNameList.add(siblingKeyword);
+ } catch (InvalidDatatypeValueException ide) {
+ throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "(List of (QName | ##defined) )"});
+ }
+
+ retValue = notQNameList;
+ }
+ break;
+ case DT_NOTNAMESPACE:
+ // notNamespace = List of (anyURI | (##targetNamespace | ##local))
+ retValue = processNamespaceList(value, schemaDoc);
+ break;
case DT_WHITESPACE:
// value = preserve | replace | collapse
if (value.equals (SchemaSymbols.ATTVAL_PRESERVE))
@@ -1853,6 +1920,43 @@
return retValue;
}
+ private String[] processNamespaceList(String value, XSDocumentInfo schemaDoc) throws InvalidDatatypeValueException {
+ fNamespaceList.removeAllElements();
+
+ // tokenize
+ StringTokenizer tokens = new StringTokenizer(value, " \n\t\r");
+ String token;
+ String tempNamespace;
+ try {
+ while (tokens.hasMoreTokens()) {
+ token = tokens.nextToken();
+ if (token.equals(SchemaSymbols.ATTVAL_TWOPOUNDLOCAL)) {
+ tempNamespace = null;
+ } else if (token.equals(SchemaSymbols.ATTVAL_TWOPOUNDTARGETNS)) {
+ tempNamespace = schemaDoc.fTargetNamespace;
+ } else {
+ // we have found namespace URI here
+ // need to add it to the symbol table
+ fExtraDVs[DT_ANYURI].validate(token, schemaDoc.fValidationContext, null);
+ tempNamespace = fSymbolTable.addSymbol(token);
+ }
+
+ //check for duplicate namespaces in the list
+ if (!fNamespaceList.contains(tempNamespace)) {
+ fNamespaceList.addElement(tempNamespace);
+ }
+ }
+ } catch (InvalidDatatypeValueException ide) {
+ throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )"});
+ }
+
+ // convert the vector to an array
+ int num = fNamespaceList.size();
+ String[] list = new String[num];
+ fNamespaceList.copyInto(list);
+ return list;
+ }
+
void reportSchemaError (String key, Object[] args, Element ele) {
fSchemaHandler.reportSchemaError(key, args, ele);
}
@@ -2019,6 +2123,9 @@
// clear the subsgroup vector
if(attrArray[ATTIDX_SUBSGROUP] != null)
((Vector)attrArray[ATTIDX_SUBSGROUP]).clear();
+ // clear notQname vector
+ if (attrArray[ATTIDX_NOTQNAME] != null)
+ ((Vector)attrArray[ATTIDX_NOTQNAME]).clear();
// and put it into the pool
fArrayPool[--fPoolPos] = attrArray;
}
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDWildcardTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDWildcardTraverser.java?rev=707475&r1=707474&r2=707475&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDWildcardTraverser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDWildcardTraverser.java Thu Oct 23 14:12:24 2008
@@ -17,6 +17,9 @@
package org.apache.xerces.impl.xs.traversers;
+import java.util.Vector;
+
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
import org.apache.xerces.impl.xs.XSAnnotationImpl;
@@ -25,6 +28,7 @@
import org.apache.xerces.impl.xs.util.XInt;
import org.apache.xerces.impl.xs.util.XSObjectListImpl;
import org.apache.xerces.util.DOMUtil;
+import org.apache.xerces.xni.QName;
import org.apache.xerces.xs.XSObjectList;
import org.w3c.dom.Element;
@@ -145,18 +149,23 @@
Object[] attrValues,
XSDocumentInfo schemaDoc,
SchemaGrammar grammar) {
-
+
//get all attributes
XSWildcardDecl wildcard = new XSWildcardDecl();
// namespace type
XInt namespaceTypeAttr = (XInt) attrValues[XSAttributeChecker.ATTIDX_NAMESPACE];
- wildcard.fType = namespaceTypeAttr.shortValue();
+ wildcard.fType = (namespaceTypeAttr != null) ? namespaceTypeAttr.shortValue() : XSWildcardDecl.NSCONSTRAINT_ANY;
// namespace list
wildcard.fNamespaceList = (String[])attrValues[XSAttributeChecker.ATTIDX_NAMESPACE_LIST];
// process contents
XInt processContentsAttr = (XInt) attrValues[XSAttributeChecker.ATTIDX_PROCESSCONTENTS];
wildcard.fProcessContents = processContentsAttr.shortValue();
-
+
+ // handle XML Schema 1.1 attributes
+ if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ processExtraAttributes(elmNode, attrValues, wildcard);
+ }
+
//check content
Element child = DOMUtil.getFirstChildElement(elmNode);
XSAnnotationImpl annotation = null;
@@ -196,4 +205,46 @@
} // traverseWildcardDecl
+ private void processExtraAttributes(Element elmNode,
+ Object[] attrValues,
+ XSWildcardDecl wildcard) {
+
+ // notNamespace
+ String[] notNamespaceTypeAttr = (String[]) attrValues[XSAttributeChecker.ATTIDX_NOTNAMESPACE];
+ if (notNamespaceTypeAttr != null) {
+ XInt namespaceTypeAttr = (XInt) attrValues[XSAttributeChecker.ATTIDX_NAMESPACE];
+ // 1 namespace and notNamespace must not both be present.
+ if (namespaceTypeAttr != null) {
+ reportSchemaError("src-wildcard.1", null, elmNode);
+ }
+ else {
+ wildcard.fType = XSWildcardDecl.NSCONSTRAINT_NOT;
+ wildcard.fNamespaceList = notNamespaceTypeAttr;
+
+ // 2 If {variety} is not, {namespaces} has at least one member.
+ if (notNamespaceTypeAttr.length == 0) {
+ reportSchemaError("wc-props-correct.2", null, elmNode);
+ }
+ }
+ }
+
+ // notQName
+ Vector notQNameAttr = (Vector) attrValues[XSAttributeChecker.ATTIDX_NOTQNAME];
+ if (notQNameAttr != null && notQNameAttr.size() > 0) {
+ // get disallowed names and keywords
+ wildcard.fDisallowedNamesList = (QName[]) notQNameAttr.get(0);
+ wildcard.fDisallowedDefined = ((Boolean)notQNameAttr.get(1)).booleanValue();
+ wildcard.fDisallowedSibling = ((Boolean)notQNameAttr.get(2)).booleanValue();
+
+ // 4 The namespace name of each QName member in {disallowed names} is allowed by
+ // the {namespace constraint}, as defined in Wildcard allows Namespace Name (3.10.4.3).
+ for (int i=0; i<wildcard.fDisallowedNamesList.length; i++) {
+ QName name = wildcard.fDisallowedNamesList[i];
+ if (!wildcard.allowNamespace(name.uri)) {
+ reportSchemaError("wc-props-correct.4", new Object[] {name.uri, name.localpart}, elmNode);
+ }
+ }
+ }
+ }
+
} // XSDWildcardTraverser
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org