Skip to content
Snippets Groups Projects
Commit 7c50a526 authored by Khaled Noaman's avatar Khaled Noaman
Browse files

Move behavior from TraverseSchema.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@173586 13f79535-47bb-0310-9956-ffa450edef68
parent e1e7c10f
No related branches found
No related tags found
No related merge requests found
......@@ -69,6 +69,7 @@
#include <xercesc/framework/XMLBuffer.hpp>
#include <xercesc/validators/common/ContentSpecNode.hpp>
#include <xercesc/validators/DTD/DTDValidator.hpp>
#include <xercesc/validators/schema/SchemaSymbols.hpp>
// ---------------------------------------------------------------------------
// ContentSpecNode: Copy Constructor
......@@ -228,3 +229,75 @@ void ContentSpecNode::formatSpec(XMLBuffer& bufToFill) const
if (fType == ContentSpecNode::Leaf)
bufToFill.append(chCloseParen);
}
int ContentSpecNode::getMinTotalRange() const {
int min = fMinOccurs;
if (fType == ContentSpecNode::Sequence
|| fType == ContentSpecNode::All
|| fType == ContentSpecNode::Choice) {
int minFirst = fFirst->getMinTotalRange();
if (fSecond) {
int minSecond = fSecond->getMinTotalRange();
if (fType == ContentSpecNode::Choice) {
min = min * ((minFirst < minSecond)? minFirst : minSecond);
}
else {
min = min * (minFirst + minSecond);
}
}
else
min = min * minFirst;
}
return min;
}
int ContentSpecNode::getMaxTotalRange() const {
int max = fMaxOccurs;
if (max == SchemaSymbols::UNBOUNDED) {
return SchemaSymbols::UNBOUNDED;
}
if (fType == ContentSpecNode::Sequence
|| fType == ContentSpecNode::All
|| fType == ContentSpecNode::Choice) {
int maxFirst = fFirst->getMaxTotalRange();
if (maxFirst == SchemaSymbols::UNBOUNDED) {
return SchemaSymbols::UNBOUNDED;
}
if (fSecond) {
int maxSecond = fSecond->getMaxTotalRange();
if (maxSecond == SchemaSymbols::UNBOUNDED) {
return SchemaSymbols::UNBOUNDED;
}
else {
if (fType == ContentSpecNode::Choice) {
max = max * (maxFirst > maxSecond) ? maxFirst : maxSecond;
}
else {
max = max * (maxFirst + maxSecond);
}
}
}
else {
max = max * maxFirst;
}
}
return max;
}
......@@ -56,8 +56,11 @@
/*
* $Log$
* Revision 1.1 2002/02/01 22:22:38 peiyongz
* Initial revision
* Revision 1.2 2002/03/21 15:41:48 knoaman
* Move behavior from TraverseSchema.
*
* Revision 1.1.1.1 2002/02/01 22:22:38 peiyongz
* sane_include
*
* Revision 1.19 2001/12/06 17:50:42 tng
* Performance Enhancement. The ContentSpecNode constructor always copied the QName
......@@ -234,6 +237,9 @@ public :
// Miscellaneous
// -----------------------------------------------------------------------
void formatSpec (XMLBuffer& bufToFill) const;
bool hasAllContent();
int getMinTotalRange() const;
int getMaxTotalRange() const;
private :
......@@ -501,4 +507,16 @@ inline void ContentSpecNode::setAdoptSecond(bool newState)
fAdoptSecond = newState;
}
// ---------------------------------------------------------------------------
// ContentSpecNode: Miscellaneous
// ---------------------------------------------------------------------------
inline bool ContentSpecNode::hasAllContent() {
if (fType == ContentSpecNode::ZeroOrOne) {
return (fFirst->getType() == ContentSpecNode::All);
}
return (fType == ContentSpecNode::All);
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment