diff --git a/src/internal/XMLScanner.cpp b/src/internal/XMLScanner.cpp index 4a067571f75838718a52aa9cd58e135e8931d98d..f9d55d292a33ef80417eb1e61f818c9645309353 100644 --- a/src/internal/XMLScanner.cpp +++ b/src/internal/XMLScanner.cpp @@ -2752,7 +2752,8 @@ bool XMLScanner::scanStartTagNS(bool& gotData) SchemaElementDecl* tempElement = (SchemaElementDecl*) fElemStack.topElement()->fThisElement; SchemaElementDecl::ModelTypes modelType = tempElement->getModelType(); - if ((modelType == SchemaElementDecl::Mixed) + if ((modelType == SchemaElementDecl::Mixed_Simple) + || (modelType == SchemaElementDecl::Mixed_Complex) || (modelType == SchemaElementDecl::Children)) { cm = tempElement->getContentModel(); diff --git a/src/validators/DTD/DTDElementDecl.cpp b/src/validators/DTD/DTDElementDecl.cpp index 10821c92f24f18961c5a10d0881035a6af2c2c9c..9e105799a57cdaaa6f596b3d4202fdfcbde51bbb 100644 --- a/src/validators/DTD/DTDElementDecl.cpp +++ b/src/validators/DTD/DTDElementDecl.cpp @@ -323,7 +323,7 @@ DTDElementDecl::formatContentModel() const XMLContentModel* DTDElementDecl::makeContentModel() { XMLContentModel* cmRet = 0; - if (fModelType == Mixed) + if (fModelType == Mixed_Simple) { // // Just create a mixel content model object. This type of diff --git a/src/validators/DTD/DTDElementDecl.hpp b/src/validators/DTD/DTDElementDecl.hpp index 7160052ae8056a7be27bfe0303852ee21a95257a..cd8d577df3691c5b41d2db2de559cd96d2441781 100644 --- a/src/validators/DTD/DTDElementDecl.hpp +++ b/src/validators/DTD/DTDElementDecl.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.12 2001/09/05 20:49:10 knoaman + * Fix for complexTypes with mixed content model. + * * Revision 1.11 2001/08/21 16:06:11 tng * Schema: Unique Particle Attribution Constraint Checking. * @@ -130,7 +133,7 @@ public : { Empty , Any - , Mixed + , Mixed_Simple , Children , ModelTypes_Count diff --git a/src/validators/DTD/DTDScanner.cpp b/src/validators/DTD/DTDScanner.cpp index d01b4e99aee843bdfd5212485dc3fd745d9e4133..9b22f2121e94c5a29305800ef26312b0dbec9750 100644 --- a/src/validators/DTD/DTDScanner.cpp +++ b/src/validators/DTD/DTDScanner.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.20 2001/09/05 20:49:10 knoaman + * Fix for complexTypes with mixed content model. + * * Revision 1.19 2001/08/02 16:54:39 tng * Reset some Scanner flags in scanReset(). * @@ -1488,7 +1491,7 @@ bool DTDScanner::scanContentSpec(DTDElementDecl& toFill) if (fReaderMgr->skippedString(XMLUni::fgPCDATAString)) { // Set the model to mixed - toFill.setModelType(DTDElementDecl::Mixed); + toFill.setModelType(DTDElementDecl::Mixed_Simple); status = scanMixed(toFill); // diff --git a/src/validators/DTD/DTDValidator.cpp b/src/validators/DTD/DTDValidator.cpp index 615a2fb38d2c37f3f5dffd1d0dceb9a65b81a3ca..4d202008f2eda392172df8eb62b2da7b779ee286 100644 --- a/src/validators/DTD/DTDValidator.cpp +++ b/src/validators/DTD/DTDValidator.cpp @@ -118,7 +118,7 @@ int DTDValidator::checkContent(XMLElementDecl* const elemDecl { // We pass no judgement on this one, anything goes } - else if ((modelType == DTDElementDecl::Mixed) + else if ((modelType == DTDElementDecl::Mixed_Simple) || (modelType == DTDElementDecl::Children)) { // Get the element's content model or fault it in diff --git a/src/validators/datatype/UnionDatatypeValidator.hpp b/src/validators/datatype/UnionDatatypeValidator.hpp index 334946cf12f8099e0ee996cf93638157cd309e8a..60487df97c1c4edd222d8b61e36e3b9de6852cbf 100644 --- a/src/validators/datatype/UnionDatatypeValidator.hpp +++ b/src/validators/datatype/UnionDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2001/09/05 20:49:10 knoaman + * Fix for complexTypes with mixed content model. + * * Revision 1.7 2001/08/31 16:53:41 knoaman * Misc. fixes. * @@ -279,10 +282,17 @@ RefVectorOf<DatatypeValidator>* UnionDatatypeValidator::getMemberTypeValidators( inline bool UnionDatatypeValidator::isAtomic() const { - unsigned int memberSize = (fMemberTypeValidators) ? fMemberTypeValidators->size() : 0; + + RefVectorOf<DatatypeValidator>* memberDVs = getMemberTypeValidators(); + + if (!memberDVs) { + return false; + } + + unsigned int memberSize = memberDVs->size(); for (unsigned int i=0; i < memberSize; i++) { - if (!fMemberTypeValidators->elementAt(i)->isAtomic()) { + if (!memberDVs->elementAt(i)->isAtomic()) { return false; } } diff --git a/src/validators/schema/ComplexTypeInfo.cpp b/src/validators/schema/ComplexTypeInfo.cpp index c7d3a7d53dc9e7d89adce2e5e4781468fcf75782..6c2ff0ff6901f443cc69454411b96ef787506187 100644 --- a/src/validators/schema/ComplexTypeInfo.cpp +++ b/src/validators/schema/ComplexTypeInfo.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.18 2001/09/05 20:49:11 knoaman + * Fix for complexTypes with mixed content model. + * * Revision 1.17 2001/08/29 21:27:07 knoaman * no message * @@ -373,23 +376,19 @@ XMLContentModel* ComplexTypeInfo::makeContentModel(const bool checkUPA, ContentS if (fContentType == SchemaElementDecl::Simple) { // just return nothing } - else if (fContentType == SchemaElementDecl::Mixed) + else if (fContentType == SchemaElementDecl::Mixed_Simple) { // // Just create a mixel content model object. This type of // content model is optimized for mixed content validation. // - if(!specNode) - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); + cmRet = new MixedContentModel(false, specNode); + } + else if (fContentType == SchemaElementDecl::Mixed_Complex) { - if (specNode->getElement()->getURI() == XMLElementDecl::fgPCDataElemId) { - cmRet = new MixedContentModel(false, specNode); - } - else { cmRet = createChildModel(specNode, true); - } } - else if (fContentType == SchemaElementDecl::Children) + else if (fContentType == SchemaElementDecl::Children) { // // This method will create an optimal model for the complexity @@ -436,23 +435,19 @@ XMLContentModel* ComplexTypeInfo::createChildModel(ContentSpecNode* specNode, co } else if (isMixed) { - ContentSpecNode* rightNode = specNode->getSecond(); - if (rightNode) { - ContentSpecNode::NodeTypes rightType = rightNode->getType(); - - if (rightType == ContentSpecNode::All) { - // All the nodes under an ALL must be additional ALL nodes and - // ELEMENTs (or ELEMENTs under ZERO_OR_ONE nodes.) - // We collapse the ELEMENTs into a single vector. - return new AllContentModel(rightNode, true); - } - else if (rightType == ContentSpecNode::ZeroOrOne) { - // An ALL node can appear under a ZERO_OR_ONE node. - if (rightNode->getFirst()->getType() == ContentSpecNode::All) { - return new AllContentModel(rightNode->getFirst(), true); - } + if (specType == ContentSpecNode::All) { + // All the nodes under an ALL must be additional ALL nodes and + // ELEMENTs (or ELEMENTs under ZERO_OR_ONE nodes.) + // We collapse the ELEMENTs into a single vector. + return new AllContentModel(specNode, true); + } + else if (specType == ContentSpecNode::ZeroOrOne) { + // An ALL node can appear under a ZERO_OR_ONE node. + if (specNode->getFirst()->getType() == ContentSpecNode::All) { + return new AllContentModel(specNode->getFirst(), true); } } + // otherwise, let fall through to build a DFAContentModel } else if (specType == ContentSpecNode::Leaf) diff --git a/src/validators/schema/SchemaElementDecl.hpp b/src/validators/schema/SchemaElementDecl.hpp index f356e8075e2f7b1c3503e06bcfba024a9e36b1b2..730aeb92e4956de336f7bf6609e31469579ebc07 100644 --- a/src/validators/schema/SchemaElementDecl.hpp +++ b/src/validators/schema/SchemaElementDecl.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.13 2001/09/05 20:49:11 knoaman + * Fix for complexTypes with mixed content model. + * * Revision 1.12 2001/08/29 20:52:35 tng * Schema: xsi:type support * @@ -124,7 +127,8 @@ public : { Empty , Any - , Mixed + , Mixed_Simple + , Mixed_Complex , Children , Simple diff --git a/src/validators/schema/SchemaValidator.cpp b/src/validators/schema/SchemaValidator.cpp index 6fde03fb8100aea000f639defcd6b99facde2b0c..f1a4a853cc10e10476c90decfe1341c5fce83856 100644 --- a/src/validators/schema/SchemaValidator.cpp +++ b/src/validators/schema/SchemaValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.17 2001/09/05 20:49:11 knoaman + * Fix for complexTypes with mixed content model. + * * Revision 1.16 2001/08/30 15:47:46 tng * Schema: xsi:type fixes * @@ -179,7 +182,8 @@ int SchemaValidator::checkContent (XMLElementDecl* const elemDecl { // We pass no judgement on this one, anything goes } - else if ((modelType == SchemaElementDecl::Mixed) + else if ((modelType == SchemaElementDecl::Mixed_Simple) + || (modelType == SchemaElementDecl::Mixed_Complex) || (modelType == SchemaElementDecl::Children)) { // if nillable, it's an error to have value diff --git a/src/validators/schema/TraverseSchema.cpp b/src/validators/schema/TraverseSchema.cpp index aa5d48c73c3c6e8ff8f41dbf3423d244d5eb8f4a..1684c4cceef1ab96bf377d9793e5cc7f91122316 100644 --- a/src/validators/schema/TraverseSchema.cpp +++ b/src/validators/schema/TraverseSchema.cpp @@ -2372,14 +2372,16 @@ QName* TraverseSchema::traverseElementDecl(const DOM_Element& elem) { } if(typeInfo != 0 && - typeInfo->getContentType() != SchemaElementDecl::Simple && - typeInfo->getContentType() != SchemaElementDecl::Mixed) { + contentSpecType != SchemaElementDecl::Simple && + contentSpecType != SchemaElementDecl::Mixed_Simple && + contentSpecType != SchemaElementDecl::Mixed_Complex) { reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NotSimpleOrMixedElement, name); } if(typeInfo != 0 && - (typeInfo->getContentType() == SchemaElementDecl::Mixed - && !emptiableParticle(typeInfo->getContentSpec()))) { + ((contentSpecType == SchemaElementDecl::Mixed_Complex + || contentSpecType == SchemaElementDecl::Mixed_Simple) + && !emptiableParticle(contentSpecNode))) { reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::EmptiableMixedContent, name); } @@ -4719,7 +4721,7 @@ void TraverseSchema::processComplexContent(const XMLCh* const typeName, if (baseContentType != SchemaElementDecl::Empty) { if ((isMixed && baseContentType == SchemaElementDecl::Children) - || (!isMixed && baseContentType == SchemaElementDecl::Mixed)) { + || (!isMixed && baseContentType == SchemaElementDecl::Mixed_Complex)) { reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::MixedOrElementOnly, baseLocalPart, typeName); throw TraverseSchema::InvalidComplexTypeInfo; //REVISIT - should we continue @@ -4784,26 +4786,6 @@ void TraverseSchema::processComplexContent(const XMLCh* const typeName, } } - if (isMixed) { - - // add #PCDATA leaf - QName* tmpName = new QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgPCDataElemId); - Janitor<QName> janQName(tmpName); - ContentSpecNode* pcdataNode = new ContentSpecNode(tmpName); - - // If there was an element, the content spec becomes a choice of PCDATA and - // the element - if (specNode != 0) { - specNode = new ContentSpecNode(ContentSpecNode::Choice, - pcdataNode, specNode, true, adoptSpecNode); - } - else { - specNode = pcdataNode; - } - - adoptSpecNode = true; - } - typeInfo->setContentSpec(specNode); typeInfo->setAdoptContentSpec(adoptSpecNode); @@ -4818,12 +4800,9 @@ void TraverseSchema::processComplexContent(const XMLCh* const typeName, //check derivation valid - content type is empty (5.2) if (!typeInfo->getContentSpec()) { - int baseContentType = baseTypeInfo->getContentType(); - if (baseContentType != SchemaElementDecl::Empty - && ((baseContentType != SchemaElementDecl::Children - && baseContentType != SchemaElementDecl::Mixed) - || !emptiableParticle(baseSpecNode))) { + if (baseTypeInfo->getContentType() != SchemaElementDecl::Empty + && !emptiableParticle(baseSpecNode)) { reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::EmptyComplexRestrictionDerivation); } } @@ -4861,7 +4840,23 @@ void TraverseSchema::processComplexContent(const XMLCh* const typeName, // Set the content type // ------------------------------------------------------------- if (isMixed) { - typeInfo->setContentType(SchemaElementDecl::Mixed); + + if (specNode != 0) { + typeInfo->setContentType(SchemaElementDecl::Mixed_Complex); + } + else { + // add #PCDATA leaf and set its minOccurs to 0 + QName* tmpName = new QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgPCDataElemId); + Janitor<QName> janQName(tmpName); + ContentSpecNode* pcdataNode = new ContentSpecNode(tmpName); + + pcdataNode->setMinOccurs(0); + typeInfo->setContentSpec(pcdataNode); + typeInfo->setAdoptContentSpec(true); + typeInfo->setContentType(SchemaElementDecl::Mixed_Simple); + } + + } else if (typeInfo->getContentSpec() == 0) { typeInfo->setContentType(SchemaElementDecl::Empty); @@ -5165,7 +5160,7 @@ void TraverseSchema::processAttributes(const DOM_Element& attElem, // Check attributes derivation OK // ------------------------------------------------------------- bool baseWithAttributes = (baseTypeInfo && baseTypeInfo->hasAttDefs()); - bool childWithAttributes = typeInfo->hasAttDefs(); + bool childWithAttributes = (typeInfo->hasAttDefs() || typeInfo->getAttWildCard()); if (derivedBy == SchemaSymbols::RESTRICTION && childWithAttributes) {