internal void CopyOptimizedItems(XmlSchemaGroupBase gb) { for (int i = 0; i < Items.Count; i++) { XmlSchemaParticle p = Items [i] as XmlSchemaParticle; p = p.GetOptimizedParticle(false); if (p == XmlSchemaParticle.Empty) { continue; } gb.Items.Add(p); gb.CompiledItems.Add(p); } }
private Sequence PopulateSequence(ComplexType ct) { Particle p = PopulateParticle(ct); Sequence s = p as Sequence; if (s != null) { return(s); } else { throw Error(ct, String.Format("Target complexType contains unacceptable type of particle {0}", p)); } }
internal virtual bool ValidateOccurenceRangeOK(XmlSchemaParticle other, ValidationEventHandler h, XmlSchema schema, bool raiseError) { if ((this.ValidatedMinOccurs < other.ValidatedMinOccurs) || (other.ValidatedMaxOccurs != decimal.MaxValue && this.ValidatedMaxOccurs > other.ValidatedMaxOccurs)) { if (raiseError) { error(h, "Invalid derivation occurence range was found."); } return(false); } return(true); }
internal override XmlSchemaParticle GetOptimizedParticle(bool isTop) { if (OptimizedParticle != null) { return(OptimizedParticle); } if (Items.Count == 0 || ValidatedMaxOccurs == 0) { OptimizedParticle = XmlSchemaParticle.Empty; return(OptimizedParticle); } else if (Items.Count == 1) { if (ValidatedMinOccurs == 1 && ValidatedMaxOccurs == 1) { XmlSchemaSequence seq = new XmlSchemaSequence(); this.CopyInfo(seq); XmlSchemaParticle p = (XmlSchemaParticle)Items [0]; p = p.GetOptimizedParticle(false); if (p == XmlSchemaParticle.Empty) { OptimizedParticle = p; } else { seq.Items.Add(p); seq.CompiledItems.Add(p); seq.Compile(null, schema); OptimizedParticle = seq; } return(OptimizedParticle); } } XmlSchemaAll all = new XmlSchemaAll(); CopyInfo(all); CopyOptimizedItems(all); OptimizedParticle = all; all.ComputeEmptiable(); return(OptimizedParticle); }
internal override bool ValidateDerivationByRestriction(XmlSchemaParticle baseParticle, ValidationEventHandler h, XmlSchema schema, bool raiseError) { XmlSchemaAny baseAny = baseParticle as XmlSchemaAny; if (baseAny == null) { if (raiseError) { error(h, "Invalid particle derivation by restriction was found."); } return(false); } // 3.9.6 Particle Derivation OK (Any:Any - NSSubset) if (!ValidateOccurenceRangeOK(baseParticle, h, schema, raiseError)) { return(false); } return(wildcard.ValidateWildcardSubset(baseAny.wildcard, h, schema, raiseError)); }
void ValidateUPAOnItems(XmlSchemaObjectTable qnames, ArrayList nsNames, ValidationEventHandler h, XmlSchema schema) { // non-optional components XmlSchemaObjectTable elems = new XmlSchemaObjectTable(); ArrayList wildcards = new ArrayList(); XmlSchemaObjectTable tmpElems = new XmlSchemaObjectTable(); ArrayList tmpWildcards = new ArrayList(); for (int i = 0; i < Items.Count; i++) { XmlSchemaParticle p1 = Items [i] as XmlSchemaParticle; p1.ValidateUniqueParticleAttribution(elems, wildcards, h, schema); if (p1.ValidatedMinOccurs == p1.ValidatedMaxOccurs) { elems.Clear(); wildcards.Clear(); } else { if (p1.ValidatedMinOccurs != 0) { foreach (XmlQualifiedName n in tmpElems.Names) { elems.Set(n, null); // remove } foreach (object o in tmpWildcards) { wildcards.Remove(o); } } foreach (XmlQualifiedName n in elems.Names) { tmpElems.Set(n, elems [n]); } tmpWildcards.Clear(); tmpWildcards.AddRange(wildcards); } } }
internal override bool ValidateDerivationByRestriction(XmlSchemaParticle baseParticle, ValidationEventHandler h, XmlSchema schema, bool raiseError) { XmlSchemaAny any = baseParticle as XmlSchemaAny; if (any != null) { // NSRecurseCheckCardinality return(ValidateNSRecurseCheckCardinality(any, h, schema, raiseError)); } XmlSchemaChoice choice = baseParticle as XmlSchemaChoice; if (choice != null) { // RecurseLax if (!ValidateOccurenceRangeOK(choice, h, schema, raiseError)) { return(false); } // If it is totally optional, then ignore their contents. if (choice.ValidatedMinOccurs == 0 && choice.ValidatedMaxOccurs == 0 && this.ValidatedMinOccurs == 0 && this.ValidatedMaxOccurs == 0) { return(true); } // return ValidateRecurseLax (choice, h, schema, raiseError); return(this.ValidateSeqRecurseMapSumCommon(choice, h, schema, true, false, raiseError)); } if (raiseError) { error(h, "Invalid choice derivation by restriction was found."); } return(false); }
internal bool ValidateSeqRecurseMapSumCommon(XmlSchemaGroupBase baseGroup, ValidationEventHandler h, XmlSchema schema, bool isLax, bool isMapAndSum, bool raiseError) { int index = 0; int baseIndex = 0; decimal baseOccured = 0; if (baseGroup.CompiledItems.Count == 0 && this.CompiledItems.Count > 0) { if (raiseError) { error(h, "Invalid particle derivation by restriction was found. base particle does not contain particles."); } return(false); } for (int i = 0; i < CompiledItems.Count; i++) { // get non-empty derived particle XmlSchemaParticle pd = null; while (this.CompiledItems.Count > index) { pd = ((XmlSchemaParticle)this.CompiledItems [index]); //.GetOptimizedParticle (false); if (pd != XmlSchemaParticle.Empty) // && pd.ValidatedMaxOccurs > 0) { break; } else { index++; } } if (index >= CompiledItems.Count) { if (raiseError) { error(h, "Invalid particle derivation by restriction was found. Cannot be mapped to base particle."); } return(false); } // get non-empty base particle XmlSchemaParticle pb = null; while (baseGroup.CompiledItems.Count > baseIndex) { pb = ((XmlSchemaParticle)baseGroup.CompiledItems [baseIndex]); //.GetOptimizedParticle (false); if (pb == XmlSchemaParticle.Empty && pb.ValidatedMaxOccurs > 0) { continue; } if (!pd.ValidateDerivationByRestriction(pb, h, schema, false)) { if (!isLax && !isMapAndSum && pb.MinOccurs > baseOccured && !pb.ValidateIsEmptiable()) { if (raiseError) { error(h, "Invalid particle derivation by restriction was found. Invalid sub-particle derivation was found."); } return(false); } else { baseOccured = 0; baseIndex++; } } else { baseOccured += pb.ValidatedMinOccurs; if (baseOccured >= baseGroup.ValidatedMaxOccurs) { baseOccured = 0; baseIndex++; } index++; break; } } } if (this.CompiledItems.Count > 0 && index != this.CompiledItems.Count) { if (raiseError) { error(h, "Invalid particle derivation by restriction was found. Extraneous derived particle was found."); } return(false); } if (!isLax && !isMapAndSum) { if (baseOccured > 0) { baseIndex++; } for (int i = baseIndex; i < baseGroup.CompiledItems.Count; i++) { XmlSchemaParticle p = baseGroup.CompiledItems [i] as XmlSchemaParticle; if (!p.ValidateIsEmptiable()) { if (raiseError) { error(h, "Invalid particle derivation by restriction was found. There is a base particle which does not have mapped derived particle and is not emptiable."); } return(false); } } } return(true); }
internal override bool ValidateDerivationByRestriction(XmlSchemaParticle baseParticle, ValidationEventHandler h, XmlSchema schema, bool raiseError) { return(true); }
internal override bool ParticleEquals(XmlSchemaParticle other) { return(other == this || other == XmlSchemaParticle.Empty); }
internal virtual bool ParticleEquals(XmlSchemaParticle other) { return(false); }
internal virtual bool ValidateDerivationByRestriction(XmlSchemaParticle baseParticle, ValidationEventHandler h, XmlSchema schema, bool raiseError) { return(false); }
internal override bool ParticleEquals(XmlSchemaParticle other) { return(this.GetOptimizedParticle(true).ParticleEquals(other)); }
internal override bool ValidateDerivationByRestriction(XmlSchemaParticle baseParticle, ValidationEventHandler h, XmlSchema schema, bool raiseError) { if (this == baseParticle) // quick check { return(true); } XmlSchemaElement el = baseParticle as XmlSchemaElement; if (el != null) { // Forbidden if (raiseError) { error(h, "Invalid sequence paricle derivation."); } return(false); } XmlSchemaSequence seq = baseParticle as XmlSchemaSequence; if (seq != null) { // Recurse if (!ValidateOccurenceRangeOK(seq, h, schema, raiseError)) { return(false); } // If it is totally optional, then ignore their contents. if (seq.ValidatedMinOccurs == 0 && seq.ValidatedMaxOccurs == 0 && this.ValidatedMinOccurs == 0 && this.ValidatedMaxOccurs == 0) { return(true); } return(ValidateRecurse(seq, h, schema, raiseError)); } XmlSchemaAll all = baseParticle as XmlSchemaAll; if (all != null) { // RecurseUnordered XmlSchemaObjectCollection already = new XmlSchemaObjectCollection(); for (int i = 0; i < this.Items.Count; i++) { XmlSchemaElement de = this.Items [i] as XmlSchemaElement; if (de == null) { if (raiseError) { error(h, "Invalid sequence particle derivation by restriction from all."); } return(false); } foreach (XmlSchemaElement e in all.Items) { if (e.QualifiedName == de.QualifiedName) { if (already.Contains(e)) { if (raiseError) { error(h, "Base element particle is mapped to the derived element particle in a sequence two or more times."); } return(false); } else { already.Add(e); if (!de.ValidateDerivationByRestriction(e, h, schema, raiseError)) { return(false); } } } } } foreach (XmlSchemaElement e in all.Items) { if (!already.Contains(e)) { if (!e.ValidateIsEmptiable()) { if (raiseError) { error(h, "In base -all- particle, mapping-skipped base element which is not emptiable was found."); } return(false); } } } return(true); } XmlSchemaAny any = baseParticle as XmlSchemaAny; if (any != null) { // NSRecurseCheckCardinality return(ValidateNSRecurseCheckCardinality(any, h, schema, raiseError)); } XmlSchemaChoice choice = baseParticle as XmlSchemaChoice; if (choice != null) { // MapAndSum // In fact it is not Recurse, but it looks almost common. return(ValidateSeqRecurseMapSumCommon(choice, h, schema, false, true, raiseError)); } return(true); }