diff --git a/src/internal/XMLScanner2.cpp b/src/internal/XMLScanner2.cpp index 81c91bd1b2de6a85759e926c04024232afcd3c84..03d44325acaaff8816f2790df7fbb567b1fb7c62 100644 --- a/src/internal/XMLScanner2.cpp +++ b/src/internal/XMLScanner2.cpp @@ -2664,21 +2664,18 @@ bool XMLScanner::laxElementValidation(QName* element, ContentLeafNameTypeVector* && !(XMLString::compareString(fElemMap->getLocalPart(), element->getLocalPart()))) break; } else if (type == ContentSpecNode::Any) { - if (uri == fEmptyNamespaceId || uri == elementURI) - break; - } else if (type == ContentSpecNode::Any_Local) { - if (elementURI == fEmptyNamespaceId) + break; + } else if (type == ContentSpecNode::Any_NS) { + if (uri == elementURI) break; } else if (type == ContentSpecNode::Any_Other) { if (uri != elementURI) break; } else if (type == ContentSpecNode::Any_Skip) { - if (uri == fEmptyNamespaceId || uri == elementURI) { - skipThisOne = true; - break; - } - } else if (type == ContentSpecNode::Any_Local_Skip) { - if (elementURI == fEmptyNamespaceId) { + skipThisOne = true; + break; + } else if (type == ContentSpecNode::Any_NS_Skip) { + if (uri == elementURI) { skipThisOne = true; break; } @@ -2688,12 +2685,10 @@ bool XMLScanner::laxElementValidation(QName* element, ContentLeafNameTypeVector* break; } } else if (type == ContentSpecNode::Any_Lax) { - if (uri == fEmptyNamespaceId || uri == elementURI) { - laxThisOne = true; - break; - } - } else if (type == ContentSpecNode::Any_Local_Lax) { - if (elementURI == fEmptyNamespaceId) { + laxThisOne = true; + break; + } else if (type == ContentSpecNode::Any_NS_Lax) { + if (uri == elementURI) { laxThisOne = true; break; } diff --git a/src/validators/common/CMAny.cpp b/src/validators/common/CMAny.cpp index a5fafbd71181cbf3425bde0b460138c640b658c2..389bc8ef5081bbbc32f2f6774fa1b2d620d8728c 100644 --- a/src/validators/common/CMAny.cpp +++ b/src/validators/common/CMAny.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2001/07/09 15:22:35 knoaman + * complete <any> declaration. + * * Revision 1.4 2001/06/07 20:58:38 tng * Fix no newline at the end warning. By Pei Yong Zhang. * @@ -90,7 +93,7 @@ CMAny::CMAny( const ContentSpecNode::NodeTypes type { if ((type != ContentSpecNode::Any) && (type != ContentSpecNode::Any_Other) - && (type != ContentSpecNode::Any_Local)) + && (type != ContentSpecNode::Any_NS)) { ThrowXML1(RuntimeException, XMLExcepts::CM_NotValidSpecTypeForNode, diff --git a/src/validators/common/ContentSpecNode.hpp b/src/validators/common/ContentSpecNode.hpp index df55b26b9408bf4bb2eb044cb91464a34ac02d02..a95d32777f8d34c843c563b885ccf19fc64503b3 100644 --- a/src/validators/common/ContentSpecNode.hpp +++ b/src/validators/common/ContentSpecNode.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2001/07/09 15:22:36 knoaman + * complete <any> declaration. + * * Revision 1.7 2001/05/11 13:27:18 tng * Copyright update. * @@ -124,13 +127,13 @@ public : , Sequence , Any , Any_Other - , Any_Local = 8 + , Any_NS = 8 , Any_Lax = 22 , Any_Other_Lax = 23 - , Any_Local_Lax = 24 + , Any_NS_Lax = 24 , Any_Skip = 38 , Any_Other_Skip = 39 - , Any_Local_Skip = 40 + , Any_NS_Skip = 40 , UnknownType = -1 }; diff --git a/src/validators/common/DFAContentModel.cpp b/src/validators/common/DFAContentModel.cpp index 38585a06294da5995da4067915a783ecb3d228bd..8388304f81a487b556d57ba1d784a72424a26839 100644 --- a/src/validators/common/DFAContentModel.cpp +++ b/src/validators/common/DFAContentModel.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.15 2001/07/09 15:22:36 knoaman + * complete <any> declaration. + * * Revision 1.14 2001/06/13 20:50:56 peiyongz * fIsMixed: to handle mixed Content Model * @@ -276,16 +279,13 @@ DFAContentModel::validateContent( QName** const children } else if ((type & 0x0f)== ContentSpecNode::Any) { - unsigned int uri = inElem->getURI(); - if ((uri == emptyNamespaceId) || (uri == curElem->getURI())) { - nextState = fTransTable[curState][elemIndex]; - if (nextState != XMLContentModel::gInvalidTrans) + nextState = fTransTable[curState][elemIndex]; + if (nextState != XMLContentModel::gInvalidTrans) break; - } } - else if ((type & 0x0f) == ContentSpecNode::Any_Local) + else if ((type & 0x0f) == ContentSpecNode::Any_NS) { - if (curElem->getURI() == emptyNamespaceId) + if (inElem->getURI() == curElem->getURI()) { nextState = fTransTable[curState][elemIndex]; if (nextState != XMLContentModel::gInvalidTrans) @@ -376,17 +376,13 @@ int DFAContentModel::validateContentSpecial(QName** const children } else if ((type & 0x0f)== ContentSpecNode::Any) { - unsigned int uri = inElem->getURI(); - if ((uri == emptyNamespaceId) || (uri == curElem->getURI())) - { - nextState = fTransTable[curState][elemIndex]; - if (nextState != XMLContentModel::gInvalidTrans) + nextState = fTransTable[curState][elemIndex]; + if (nextState != XMLContentModel::gInvalidTrans) break; - } } - else if ((type & 0x0f) == ContentSpecNode::Any_Local) + else if ((type & 0x0f) == ContentSpecNode::Any_NS) { - if (curElem->getURI() == emptyNamespaceId) + if (inElem->getURI() == curElem->getURI()) { nextState = fTransTable[curState][elemIndex]; if (nextState != XMLContentModel::gInvalidTrans) @@ -860,18 +856,12 @@ CMNode* DFAContentModel::buildSyntaxTree(ContentSpecNode* const curNode) // Get the spec type of the passed node const ContentSpecNode::NodeTypes curType = curNode->getType(); - if ((curType & 0x0f) == ContentSpecNode::Any) + if ((curType & 0x0f) == ContentSpecNode::Any + || (curType & 0x0f) == ContentSpecNode::Any_Other + || (curType & 0x0f) == ContentSpecNode::Any_NS) { retNode = new CMAny(curType, curNode->getElement()->getURI(), fLeafCount++); } - else if ((curType & 0x0f) == ContentSpecNode::Any_Other) - { - retNode = new CMAny(curType, curNode->getElement()->getURI(), fLeafCount++); - } - else if ((curType & 0x0f) == ContentSpecNode::Any_Local) - { - retNode = new CMAny(curType, 0, fLeafCount++); - } else if (curType == ContentSpecNode::Leaf) { // @@ -1014,7 +1004,7 @@ int DFAContentModel::postTreeBuildInit( CMNode* const nodeCur // Recurse as required if ( ((curType & 0x0f) == ContentSpecNode::Any) || - ((curType & 0x0f) == ContentSpecNode::Any_Local) || + ((curType & 0x0f) == ContentSpecNode::Any_NS) || ((curType & 0x0f) == ContentSpecNode::Any_Other) ) { QName* qname = new QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, ((CMAny*) nodeCur)->getURI()); diff --git a/src/validators/common/MixedContentModel.cpp b/src/validators/common/MixedContentModel.cpp index 398cd1d674d89d3d4778df6e8445995eb5aca13c..1dc8897d3ff5329125457b97fa8c7ceac99a23d7 100644 --- a/src/validators/common/MixedContentModel.cpp +++ b/src/validators/common/MixedContentModel.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.11 2001/07/09 15:22:37 knoaman + * complete <any> declaration. + * * Revision 1.10 2001/06/12 22:13:33 peiyongz * validateContentSpecial() : apply SubstitutionGroupComparator.isEquivalentTo() * @@ -254,12 +257,9 @@ MixedContentModel::validateContent( QName** const children } } else if (type == ContentSpecNode::Any) { - unsigned int uri = inChild->getURI(); - if ((uri != emptyNamespaceId) && (uri != curChild->getURI())) - return outIndex; } - else if (type == ContentSpecNode::Any_Local) { - if (curChild->getURI() != emptyNamespaceId) + else if (type == ContentSpecNode::Any_NS) { + if (inChild->getURI() != curChild->getURI()) return outIndex; } else if (type == ContentSpecNode::Any_Other) { @@ -303,12 +303,10 @@ MixedContentModel::validateContent( QName** const children } } else if (type == ContentSpecNode::Any) { - unsigned int uri = inChild->getURI(); - if ((uri == emptyNamespaceId) || (uri == curChild->getURI())) - break; + break; } - else if (type == ContentSpecNode::Any_Local) { - if (curChild->getURI() == emptyNamespaceId) + else if (type == ContentSpecNode::Any_NS) { + if (inChild->getURI() == curChild->getURI()) break; } else if (type == ContentSpecNode::Any_Other) { @@ -348,7 +346,7 @@ MixedContentModel::buildChildList( ContentSpecNode* const curNode if ((curType == ContentSpecNode::Leaf) || (curType == ContentSpecNode::Any) || (curType == ContentSpecNode::Any_Other) || - (curType == ContentSpecNode::Any_Local) ) + (curType == ContentSpecNode::Any_NS) ) { toFill.addElement(curNode->getElement()); toType.addElement(curType); @@ -408,12 +406,9 @@ int MixedContentModel::validateContentSpecial(QName** const children return outIndex; } else if (type == ContentSpecNode::Any) { - unsigned int uri = inChild->getURI(); - if ((uri != emptyNamespaceId) && (uri != curChild->getURI())) - return outIndex; } - else if (type == ContentSpecNode::Any_Local) { - if (curChild->getURI() != emptyNamespaceId) + else if (type == ContentSpecNode::Any_NS) { + if (inChild->getURI() != curChild->getURI()) return outIndex; } else if (type == ContentSpecNode::Any_Other) { @@ -448,12 +443,10 @@ int MixedContentModel::validateContentSpecial(QName** const children break; } else if (type == ContentSpecNode::Any) { - unsigned int uri = inChild->getURI(); - if ((uri == emptyNamespaceId) || (uri == curChild->getURI())) - break; + break; } - else if (type == ContentSpecNode::Any_Local) { - if (curChild->getURI() == emptyNamespaceId) + else if (type == ContentSpecNode::Any_NS) { + if (inChild->getURI() == curChild->getURI()) break; } else if (type == ContentSpecNode::Any_Other) { diff --git a/src/validators/schema/SchemaElementDecl.cpp b/src/validators/schema/SchemaElementDecl.cpp index b840d2cfad949510b126c35687064d3cba9e8e0e..66e1ce01bf107d3bd48f43ebbcf668afd8b753cf 100644 --- a/src/validators/schema/SchemaElementDecl.cpp +++ b/src/validators/schema/SchemaElementDecl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2001/07/09 15:22:43 knoaman + * complete <any> declaration. + * * Revision 1.9 2001/06/13 20:51:18 peiyongz * fIsMixed: to handle mixed Content Model * @@ -308,9 +311,15 @@ SchemaElementDecl::formatContentModel() const // pretty long, but very few will be longer than one K. The buffer // will expand to handle the more pathological ones. // - XMLBuffer bufFmt; - getContentSpec()->formatSpec(bufFmt); - newValue = XMLString::replicate(bufFmt.getRawBuffer()); + const ContentSpecNode* specNode = getContentSpec(); + + if (specNode) { + XMLBuffer bufFmt; + + + specNode->formatSpec(bufFmt); + newValue = XMLString::replicate(bufFmt.getRawBuffer()); + } } return newValue; } @@ -327,7 +336,17 @@ XMLContentModel* SchemaElementDecl::makeContentModel() // Just create a mixel content model object. This type of // content model is optimized for mixed content validation. // - cmRet = createChildModel(true); + ContentSpecNode* specNode = getContentSpec(); + + if(!specNode) + ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); + + if (specNode->getElement()->getURI() == XMLElementDecl::fgPCDataElemId) { + cmRet = new MixedContentModel(false, this); + } + else { + cmRet = createChildModel(true); + } } else if (fModelType == Children) { @@ -373,7 +392,7 @@ XMLContentModel* SchemaElementDecl::createChildModel(const bool isMixed) // if (((specNode->getType() & 0x0f) == ContentSpecNode::Any) || ((specNode->getType() & 0x0f) == ContentSpecNode::Any_Other) || - ((specNode->getType() & 0x0f) == ContentSpecNode::Any_Local)) { + ((specNode->getType() & 0x0f) == ContentSpecNode::Any_NS)) { // let fall through to build a DFAContentModel } else if (isMixed) diff --git a/src/validators/schema/TraverseSchema.cpp b/src/validators/schema/TraverseSchema.cpp index f298bc4dbc5b5638ad36f391810c9fa4b442827a..720e812135aa1a4af22bb2d850d076197462d052 100644 --- a/src/validators/schema/TraverseSchema.cpp +++ b/src/validators/schema/TraverseSchema.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.27 2001/07/09 15:22:45 knoaman + * complete <any> declaration. + * * Revision 1.26 2001/07/09 14:29:44 knoaman * Fixes for import/include declarations * @@ -1185,25 +1188,23 @@ TraverseSchema::traverseAny(const DOM_Element& elem) { // Set default node type based on 'processContents' value // ------------------------------------------------------------------ ContentSpecNode::NodeTypes anyType = ContentSpecNode::Any; - ContentSpecNode::NodeTypes anyLocalType = ContentSpecNode::Any_Local; + ContentSpecNode::NodeTypes anyLocalType = ContentSpecNode::Any_NS; ContentSpecNode::NodeTypes anyOtherType = ContentSpecNode::Any_Other; - if (XMLString::stringLen(processContents) != 0) { + if (XMLString::stringLen(processContents) > 0 + && XMLString::compareString(processContents, fgStrict)) { - if (XMLString::compareString(processContents, fgStrict) != 0) { - // Do nothing - } - else if (XMLString::compareString(processContents, fgLax) == 0) { + if (!XMLString::compareString(processContents, fgLax)) { anyType = ContentSpecNode::Any_Lax; anyOtherType = ContentSpecNode::Any_Other_Lax; - anyLocalType = ContentSpecNode::Any_Local_Lax; + anyLocalType = ContentSpecNode::Any_NS_Lax; } - else if (XMLString::compareString(processContents, fgSkip) == 0) { + else if (!XMLString::compareString(processContents, fgSkip)) { anyType = ContentSpecNode::Any_Skip; anyOtherType = ContentSpecNode::Any_Other_Skip; - anyLocalType = ContentSpecNode::Any_Local_Skip; + anyLocalType = ContentSpecNode::Any_NS_Skip; } } @@ -1213,22 +1214,24 @@ TraverseSchema::traverseAny(const DOM_Element& elem) { int emptyURI = fURIStringPool->addOrFind(XMLUni::fgZeroLenString); ContentSpecNode* retSpecNode = 0; QName elemName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, - fTargetNSURI); + emptyURI); if (XMLString::stringLen(nameSpace) == 0 - || XMLString::compareString(nameSpace, SchemaSymbols::fgATTVAL_TWOPOUNDANY) == 0) { + || !XMLString::compareString(nameSpace, SchemaSymbols::fgATTVAL_TWOPOUNDANY)) { retSpecNode = new ContentSpecNode(&elemName); retSpecNode->setType(anyType); } - else if (XMLString::compareString(nameSpace, SchemaSymbols::fgATTVAL_TWOPOUNDOTHER) == 0) { + else if (!XMLString::compareString(nameSpace, SchemaSymbols::fgATTVAL_TWOPOUNDOTHER)) { + elemName.setURI(fTargetNSURI); retSpecNode = new ContentSpecNode(&elemName); retSpecNode->setType(anyOtherType); } else { RefVectorOf<XMLCh>* nameSpaceTokens = XMLString::tokenizeString(nameSpace); + ValueVectorOf<unsigned int> uriList(8); ContentSpecNode* firstNode = 0; ContentSpecNode* secondNode = 0; unsigned int tokensSize = nameSpaceTokens->size(); @@ -1238,26 +1241,25 @@ TraverseSchema::traverseAny(const DOM_Element& elem) { const XMLCh* tokenElem = nameSpaceTokens->elementAt(i); int uriIndex = emptyURI; - if (XMLString::compareString(tokenElem, - SchemaSymbols::fgATTVAL_TWOPOUNDLOCAL) == 0) { - - elemName.setURI(uriIndex); - firstNode = new ContentSpecNode(&elemName); - firstNode->setType(anyLocalType); - } - else { + if (XMLString::compareString(tokenElem,SchemaSymbols::fgATTVAL_TWOPOUNDLOCAL)) { // not ##local - if (XMLString::compareString(tokenElem, - SchemaSymbols::fgATTVAL_TWOPOUNDTRAGETNAMESPACE) == 0) { + if (!XMLString::compareString(tokenElem,SchemaSymbols::fgATTVAL_TWOPOUNDTRAGETNAMESPACE)) { uriIndex = fTargetNSURI; } + else { + uriIndex = fURIStringPool->addOrFind(tokenElem); + } + } - uriIndex = fURIStringPool->addOrFind(tokenElem); - elemName.setURI(uriIndex); - firstNode = new ContentSpecNode(&elemName); - firstNode->setType(anyType); + if (locationsContain(&uriList, uriIndex)) { + continue; } + uriList.addElement(uriIndex); + elemName.setURI(uriIndex); + firstNode = new ContentSpecNode(&elemName); + firstNode->setType(anyLocalType); + if (secondNode == 0) { secondNode = firstNode; }