private static XSWildcardDecl getErrorWildcard() { if (fErrorWildcard == null) { XSWildcardDecl wildcard = new XSWildcardDecl(); wildcard.fProcessContents = XSWildcardDecl.PC_SKIP; fErrorWildcard = wildcard; } return fErrorWildcard; }
/** * XML Schema 1.1 * * Validation Rule: Wildcard allows Name */ final public boolean allowQName(QName name) { return allowName(name.uri, name.localpart); }
if (!o2.allowNamespace(o1.fNamespaceList[i])) { return true; if (o1.allowNamespace(o2.fNamespaceList[i])) { return true;
final public boolean allowName(String uri, String localPart) { // 1 The namespace name is valid with respect to C, as defined in Wildcard allows Namespace Name (3.10.4.3); // 2 C.{disallowed names} does not contain E. if (allowNamespace(uri)) { if (fDisallowedNamesList == null || fDisallowedNamesList.length == 0) { return true; } return isNameAllowed(uri, localPart); } // failed return false; }
return errorArgs; else if (!baseGroup.fAttributeWC.allowNamespace(attrDecl.fTargetNamespace)) { errorArgs = new Object[]{typeName, attrDecl.fName, attrDecl.fTargetNamespace==null?"":attrDecl.fTargetNamespace, return errorArgs; if (fAttributeWC.weakerProcessContents(baseGroup.fAttributeWC)) { errorArgs = new Object[]{typeName, fAttributeWC.getProcessContentsAsString(), baseGroup.fAttributeWC.getProcessContentsAsString(), "derivation-ok-restriction.4.3"}; return errorArgs;
private void checkNSSubset(XSWildcardDecl dWildcard, int min1, int max1, XSWildcardDecl bWildcard, int min2, int max2) throws XMLSchemaException { // check Occurrence ranges if (!checkOccurrenceRange(min1,max1,min2,max2)) { throw new XMLSchemaException("rcase-NSSubset.2", new Object[]{ Integer.toString(min1), max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1), Integer.toString(min2), max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)}); } // check wildcard subset if (!isSubsetOf(dWildcard, bWildcard)) { throw new XMLSchemaException("rcase-NSSubset.1", null); } if (dWildcard.weakerProcessContents(bWildcard)) { throw new XMLSchemaException("rcase-NSSubset.3", new Object[]{dWildcard.getProcessContentsAsString(), bWildcard.getProcessContentsAsString()}); } }
String ns = (String)globals.get(i++); String name = (String)globals.get(i++); if (wc.allowNamespace(ns)) { addAN(ns, name); String ns = (String)siblingsB.get(i++); String name = (String)siblingsB.get(i++); if (wc.allowNamespace(ns)) { addAN(ns, name); String ns = (String)siblingsD.get(i++); String name = (String)siblingsD.get(i++); if (wc.allowNamespace(ns)) { addAN(ns, name); if (wc.getConstraintType() == XSWildcardDecl.NSCONSTRAINT_ANY) { wType = XSWildcardDecl.NSCONSTRAINT_LIST; wNSList.clear(); if (wc.getConstraintType() == XSWildcardDecl.NSCONSTRAINT_NOT) {
if (wd.weakerProcessContents(wb)) { return false;
private boolean allowedNames(XSWildcardDecl wildcard, XSWildcardDecl superWildcard) { for (int i = 0; i < superWildcard.fDisallowedNamesList.length; i++) { if (wildcard.allowQName(superWildcard.fDisallowedNamesList[i])) { return true; } } return false; }
public String toString() { if (fDescription == null) { StringBuffer buffer = new StringBuffer(); buffer.append("OC[mode="); if (fMode == MODE_NONE) { buffer.append("none,"); } else if (fMode == MODE_INTERLEAVE) { buffer.append("interleave,"); } else { buffer.append("suffix,"); } buffer.append(fWildcard.toString()); buffer.append("]"); fDescription = buffer.toString(); } return fDescription; }
private boolean checkEWRestriction() { // 1 G is skip. if (wb.getProcessContents() == XSWildcardDecl.PC_SKIP) { return true; } qname.uri = ed.fTargetNamespace; qname.localpart = ed.fName; eb = getGlobalElementDecl(qname); if (eb == null) { // 2 G is lax and S is not skip. return wb.getProcessContents() == XSWildcardDecl.PC_LAX; } else { // 4 G and S are both Element Declarations and all of the following are true: return checkEERestriction(); } }
private QName[] disallowedNamesUnion(XSWildcardDecl one, XSWildcardDecl theOther) { final int len1 = (one.fDisallowedNamesList == null) ? 0 : one.fDisallowedNamesList.length; final int len2 = (theOther.fDisallowedNamesList == null) ? 0 : theOther.fDisallowedNamesList.length; final QName[] result = new QName[len1 + len2]; // simple implementation int count = 0; for (int i=0; i<len1; i++) { if (!theOther.allowQName(one.fDisallowedNamesList[i])) { result[count++] = one.fDisallowedNamesList[i]; } } for (int i=0; i<len2; i++) { if (!one.allowQName(theOther.fDisallowedNamesList[i])) { result[count++] = theOther.fDisallowedNamesList[i]; } } QName[] result2 = new QName[count]; System.arraycopy(result, 0, result2, 0, count); return result2; }
/** * check whether this content violates UPA constraint. * * @param subGroupHandler the substitution group handler * @param xsConstraints the XML Schema Constraint checker * @return true if this content model contains other or list wildcard */ public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler, XSConstraints xsConstraints) throws XMLSchemaException { // check whether there is conflict between any two leaves for (int i = 1; i < fNumElements; i++) { for (int j = i+1; j < fNumElements; j++) { if (xsConstraints.overlapUPA(fElements[i], fElements[j], subGroupHandler)) { // REVISIT: do we want to report all errors? or just one? throw new XMLSchemaException("cos-nonambig", new Object[]{fElements[i].toString(), fElements[j].toString()}); } } } for (int i = fNumElements; i < fNumTotal; i++) { for (int j = i+1; j < fNumTotal; j++) { if (xsConstraints.overlapUPA(fWildcards[i], fWildcards[j])) { // REVISIT: do we want to report all errors? or just one? throw new XMLSchemaException("cos-nonambig", new Object[]{fWildcards[i].toString(), fWildcards[j].toString()}); } } } return false; }
private XSAttributeGroupDecl createAttrGrp() { XSWildcardDecl wildcard = new XSWildcardDecl(); wildcard.fProcessContents = XSWildcardDecl.PC_LAX; XSAttributeGroupDecl attrGrp = new XSAttributeGroupDecl(); attrGrp.fAttributeWC = wildcard; return attrGrp; }
public boolean overlapUPA(XSElementDecl element, XSWildcardDecl wildcard, SubstitutionGroupHandler sgHandler) { // if the wildcard allows the element if (wildcard.allowNamespace(element.fTargetNamespace)) return true; // or if the wildcard allows any element in the substitution group XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(element, fSchemaVersion); for (int i = subGroup.length-1; i >= 0; i--) { if (wildcard.allowNamespace(subGroup[i].fTargetNamespace)) return true; } return false; }
public boolean allowExpandedName(XSWildcardDecl wildcard, QName curElem, SubstitutionGroupHandler subGroupHandler, XSElementDeclHelper eDeclHelper) { if (wildcard.allowQName(curElem)) { if (wildcard.fDisallowedDefined && eDeclHelper.getGlobalElementDecl(curElem) != null) { return false; } return true; } return false; } public List getDefinedNames(SubstitutionGroupHandler subGroupHandler) {
if (wc.allowName(elem.fTargetNamespace, elem.fName)) { final SchemaGrammar grammar = grammarBucket.getGrammar(elem.fTargetNamespace); if (grammar != null) {
private XSParticleDecl createAnyLaxWildcardParticle() { XSParticleDecl particle = new XSParticleDecl(); particle.fMinOccurs = 1; particle.fMaxOccurs = 1; particle.fType = XSParticleDecl.PARTICLE_WILDCARD; XSWildcardDecl anyWC = new XSWildcardDecl(); anyWC.fNamespaceList = null; anyWC.fType = XSWildcard.NSCONSTRAINT_ANY; anyWC.fProcessContents = XSWildcard.PC_LAX; particle.fValue = anyWC; return particle; } }
private void checkNSCompat(XSElementDecl elem, int min1, int max1, XSWildcardDecl wildcard, int min2, int max2, boolean checkWCOccurrence) throws XMLSchemaException { // check Occurrence ranges if (checkWCOccurrence && !checkOccurrenceRange(min1,max1,min2,max2)) { throw new XMLSchemaException("rcase-NSCompat.2", new Object[]{ elem.fName, Integer.toString(min1), max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1), Integer.toString(min2), max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)}); } // check wildcard allows namespace of element if (!wildcard.allowNamespace(elem.fTargetNamespace)) { throw new XMLSchemaException("rcase-NSCompat.1", new Object[]{elem.fName,elem.fTargetNamespace}); } }
boolean allowAttribute(XSWildcardDecl attrWildcard, QName name, SchemaGrammar grammar) { if (attrWildcard.allowQName(name)) { if (grammar == null || !attrWildcard.fDisallowedDefined) { return true; } return (grammar.getGlobalAttributeDecl(name.localpart) == null); } return false; }