equal
deleted
inserted
replaced
342 return hasDuplicatedElementsInternal(particle, namePool, hash, conflictingElement); |
342 return hasDuplicatedElementsInternal(particle, namePool, hash, conflictingElement); |
343 } |
343 } |
344 |
344 |
345 bool XsdParticleChecker::isUPAConform(const XsdParticle::Ptr &particle, const NamePool::Ptr &namePool) |
345 bool XsdParticleChecker::isUPAConform(const XsdParticle::Ptr &particle, const NamePool::Ptr &namePool) |
346 { |
346 { |
|
347 |
|
348 /** |
|
349 * In case we encounter an <xsd:all> element, don't construct a state machine, but use the approach |
|
350 * described at http://www.w3.org/TR/xmlschema-1/#non-ambig |
|
351 * Reason: For n elements inside the <xsd:all>, represented in the NDA, the state machine |
|
352 * constructs n! states in the DFA, which does not scale. |
|
353 */ |
|
354 if (particle->term()->isModelGroup()) { |
|
355 const XsdModelGroup::Ptr group(particle->term()); |
|
356 if (group->compositor() == XsdModelGroup::AllCompositor) |
|
357 return isUPAConformXsdAll(particle, namePool); |
|
358 } |
|
359 |
347 /** |
360 /** |
348 * The algorithm is implemented like described in http://www.ltg.ed.ac.uk/~ht/XML_Europe_2003.html#S2.2 |
361 * The algorithm is implemented like described in http://www.ltg.ed.ac.uk/~ht/XML_Europe_2003.html#S2.2 |
349 */ |
362 */ |
350 |
363 |
351 // create a state machine for the given particle |
364 // create a state machine for the given particle |
409 return false; |
422 return false; |
410 } |
423 } |
411 } |
424 } |
412 } |
425 } |
413 |
426 |
|
427 return true; |
|
428 } |
|
429 |
|
430 bool XsdParticleChecker::isUPAConformXsdAll(const XsdParticle::Ptr &particle, const NamePool::Ptr &namePool) |
|
431 { |
|
432 /** |
|
433 * see http://www.w3.org/TR/xmlschema-1/#non-ambig |
|
434 */ |
|
435 const XsdModelGroup::Ptr group(particle->term()); |
|
436 const XsdParticle::List particles = group->particles(); |
|
437 const int count = particles.count(); |
|
438 for (int left = 0; left < count; ++left) { |
|
439 for (int right = left+1; right < count; ++right) { |
|
440 if (termMatches(particles.at(left)->term(), particles.at(right)->term(), namePool)) |
|
441 return false; |
|
442 } |
|
443 } |
414 return true; |
444 return true; |
415 } |
445 } |
416 |
446 |
417 bool XsdParticleChecker::subsumes(const XsdParticle::Ptr &particle, const XsdParticle::Ptr &derivedParticle, const XsdSchemaContext::Ptr &context, QString &errorMsg) |
447 bool XsdParticleChecker::subsumes(const XsdParticle::Ptr &particle, const XsdParticle::Ptr &derivedParticle, const XsdSchemaContext::Ptr &context, QString &errorMsg) |
418 { |
448 { |