You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2002/03/21 16:41:48 UTC
cvs commit: xml-xerces/c/src/xercesc/validators/common ContentSpecNode.hpp ContentSpecNode.cpp
knoaman 02/03/21 07:41:48
Modified: c/src/xercesc/validators/common ContentSpecNode.hpp
ContentSpecNode.cpp
Log:
Move behavior from TraverseSchema.
Revision Changes Path
1.2 +18 -0 xml-xerces/c/src/xercesc/validators/common/ContentSpecNode.hpp
Index: ContentSpecNode.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/ContentSpecNode.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ContentSpecNode.hpp 1 Feb 2002 22:22:38 -0000 1.1
+++ ContentSpecNode.hpp 21 Mar 2002 15:41:48 -0000 1.2
@@ -56,8 +56,11 @@
/*
* $Log: ContentSpecNode.hpp,v $
- * 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 @@
// Miscellaneous
// -----------------------------------------------------------------------
void formatSpec (XMLBuffer& bufToFill) const;
+ bool hasAllContent();
+ int getMinTotalRange() const;
+ int getMaxTotalRange() const;
private :
@@ -499,6 +505,18 @@
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
1.3 +74 -1 xml-xerces/c/src/xercesc/validators/common/ContentSpecNode.cpp
Index: ContentSpecNode.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/ContentSpecNode.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContentSpecNode.cpp 18 Feb 2002 20:25:48 -0000 1.2
+++ ContentSpecNode.cpp 21 Mar 2002 15:41:48 -0000 1.3
@@ -55,7 +55,7 @@
*/
/*
- * $Id: ContentSpecNode.cpp,v 1.2 2002/02/18 20:25:48 peiyongz Exp $
+ * $Id: ContentSpecNode.cpp,v 1.3 2002/03/21 15:41:48 knoaman Exp $
*/
@@ -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 @@
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;
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org