You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ro...@locus.apache.org on 2000/04/13 00:58:31 UTC
cvs commit: xml-xerces/c/src/parsers DOMParser.cpp DOMParser.hpp SAXParser.cpp SAXParser.hpp
roddey 00/04/12 15:58:31
Modified: c/samples/SAXPrint SAXPrint.cpp
c/src/internal XMLScanner.cpp XMLScanner.hpp XMLScanner2.cpp
c/src/parsers DOMParser.cpp DOMParser.hpp SAXParser.cpp
SAXParser.hpp
Log:
Added support for 'auto validate' mode.
Revision Changes Path
1.10 +31 -12 xml-xerces/c/samples/SAXPrint/SAXPrint.cpp
Index: SAXPrint.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/samples/SAXPrint/SAXPrint.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SAXPrint.cpp 2000/04/06 19:09:51 1.9
+++ SAXPrint.cpp 2000/04/12 22:58:27 1.10
@@ -56,6 +56,9 @@
/*
* $Log: SAXPrint.cpp,v $
+ * Revision 1.10 2000/04/12 22:58:27 roddey
+ * Added support for 'auto validate' mode.
+ *
* Revision 1.9 2000/04/06 19:09:51 roddey
* Some more improvements to output formatting. Now it will correctly
* handle doing the 'replacement char' style of dealing with chars
@@ -113,22 +116,22 @@
// Indicates whether namespace processing should be enabled or not.
// Defaults to disabled.
//
-// doValidation
-// Indicates whether the validating or non-validating parser should be
-// used. Defaults to validating, -NV overrides.
-//
// encodingName
// The encoding we are to output in. If not set on the command line,
// then it is defaulted to UTF-8.
//
// xmlFile
// The path to the file to parser. Set via command line.
+//
+// valScheme
+// Indicates what validation scheme to use. It defaults to 'auto', but
+// can be set via the -v= command.
// ---------------------------------------------------------------------------
static bool doNamespaces = false;
-static bool doValidation = false;
static const char* encodingName = "UTF-8";
static XMLFormatter::UnRepFlags unRepFlags = XMLFormatter::UnRep_Fail;
static char* xmlFile = 0;
+static SAXParser::ValSchemes valScheme = SAXParser::Val_Auto;
@@ -142,7 +145,7 @@
<< " handlers for the specified input file.\n\n"
<< " Options:\n"
<< " -u=xxx Handle unrepresentable chars [fail* | rep | ref]\n"
- << " -v Invoke the Validating SAX Parser.\n"
+ << " -v=xxx Validation scheme [never | always | auto*]\n"
<< " -n Enable namespace processing.\n"
<< " -x=XXX Use a particular encoding for output (UTF-8*).\n"
<< " -? Show this help\n\n"
@@ -191,22 +194,36 @@
if (argV[parmInd][0] != '-')
break;
- if (!strcmp(argV[parmInd], "-v")
- || !strcmp(argV[parmInd], "-V"))
+ if (!strncmp(argV[parmInd], "-v=", 3)
+ || !strncmp(argV[parmInd], "-V=", 3))
{
- doValidation = true;
+ const char* const parm = &argV[parmInd][3];
+
+ if (!strcmp(parm, "never"))
+ valScheme = SAXParser::Val_Never;
+ else if (!strcmp(parm, "always"))
+ valScheme = SAXParser::Val_Always;
+ else if (!strcmp(parm, "auto"))
+ valScheme = SAXParser::Val_Auto;
+ else
+ {
+ cerr << "Unknown -v= value: " << parm << endl;
+ return 2;
+ }
}
else if (!strcmp(argV[parmInd], "-n")
|| !strcmp(argV[parmInd], "-N"))
{
doNamespaces = true;
}
- else if (!strncmp(argV[parmInd], "-x=", 3))
+ else if (!strncmp(argV[parmInd], "-x=", 3)
+ || !strncmp(argV[parmInd], "-X=", 3))
{
// Get out the encoding name
encodingName = &argV[parmInd][3];
}
- else if (!strncmp(argV[parmInd], "-u=", 3))
+ else if (!strncmp(argV[parmInd], "-u=", 3)
+ || !strncmp(argV[parmInd], "-U=", 3))
{
const char* const parm = &argV[parmInd][3];
@@ -245,7 +262,7 @@
// the command line, set it to validate or not.
//
SAXParser parser;
- parser.setDoValidation(doValidation);
+ parser.setValidationScheme(valScheme);
parser.setDoNamespaces(doNamespaces);
//
1.14 +45 -31 xml-xerces/c/src/internal/XMLScanner.cpp
Index: XMLScanner.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/internal/XMLScanner.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XMLScanner.cpp 2000/03/03 22:32:51 1.13
+++ XMLScanner.cpp 2000/04/12 22:58:28 1.14
@@ -56,6 +56,9 @@
/*
* $Log: XMLScanner.cpp,v $
+ * Revision 1.14 2000/04/12 22:58:28 roddey
+ * Added support for 'auto validate' mode.
+ *
* Revision 1.13 2000/03/03 22:32:51 roddey
* Fixed a bug in SimpleContentModel that allowed an <a/> to be taken
* as valid for a content model of (a,b).
@@ -211,10 +214,10 @@
fAttrList(0)
, fDocHandler(0)
, fDoNamespaces(false)
- , fDoValidation(false)
, fEntityHandler(0)
, fErrorReporter(0)
, fExitOnFirstFatal(true)
+ , fHaveSubset(false)
, fIDRefList(0)
, fInException(false)
, fRawAttrList(0)
@@ -222,7 +225,9 @@
, fScannerId(0)
, fSequenceId(0)
, fStandalone(false)
+ , fValidate(false)
, fValidator(validator)
+ , fValScheme(Val_Never)
{
commonInit();
}
@@ -235,10 +240,10 @@
fAttrList(0)
, fDocHandler(docHandler)
, fDoNamespaces(false)
- , fDoValidation(false)
, fEntityHandler(entityHandler)
, fErrorReporter(errHandler)
, fExitOnFirstFatal(true)
+ , fHaveSubset(false)
, fIDRefList(0)
, fInException(false)
, fRawAttrList(0)
@@ -246,7 +251,9 @@
, fScannerId(0)
, fSequenceId(0)
, fStandalone(false)
+ , fValidate(false)
, fValidator(validator)
+ , fValScheme(Val_Never)
{
commonInit();
}
@@ -319,6 +326,9 @@
// Store the reuse validator flag
fReuseValidator = reuseValidator;
+ // Clear some flags for new round
+ fHaveSubset = false;
+
try
{
//
@@ -358,11 +368,23 @@
}
else
{
+ //
+ // Set our validation flag at this point. If the validation
+ // scheme is not auto, then take that. Else see if we saw any
+ // subset.
+ //
+ if (fValScheme == Val_Never)
+ fValidate = false;
+ else if (fValScheme == Val_Always)
+ fValidate = true;
+ else
+ fValidate = fHaveSubset;
+
// Scan content, and tell it its not an external entity
if (scanContent(false))
{
// Do post-parse validation if required
- if (fDoValidation)
+ if (fValidate)
{
//
// We handle ID reference semantics at this level since
@@ -526,6 +548,9 @@
// Reset the scanner and its plugged in stuff for a new run
scanReset(src);
+ // Clear some flags for new round
+ fHaveSubset = false;
+
try
{
//
@@ -1040,21 +1065,6 @@
// ---------------------------------------------------------------------------
-// XMLScanner: Setter methods methods
-// ---------------------------------------------------------------------------
-void XMLScanner::setDoValidation(const bool validate)
-{
- fDoValidation = validate;
-}
-
-void XMLScanner::setValidator(XMLValidator* const validator)
-{
- fValidator = validator;
-}
-
-
-
-// ---------------------------------------------------------------------------
// XMLScanner: Private scanning methods
// ---------------------------------------------------------------------------
@@ -1572,7 +1582,7 @@
// If validation is enabled, then lets pass him the list of children and
// this element and let him validate it.
//
- if (fDoValidation)
+ if (fValidate)
{
int res = fValidator->checkContent
(
@@ -1898,6 +1908,9 @@
fValidator->scanDTD(fReuseValidator);
else
ThrowXML(RuntimeException, XMLExcepts::Gen_NoDTDValidator);
+
+ // Set the 'have subset' flag
+ fHaveSubset = true;
}
else
{
@@ -2004,7 +2017,7 @@
if (wasAdded)
{
// If validating then emit an error
- if (fDoValidation)
+ if (fValidate)
{
fValidator->emitError
(
@@ -2018,13 +2031,13 @@
// things simpler and we aren't going to do do the validation checks
// that need to know if it was really declared or not anyway.
//
- if (!fDoValidation)
+ if (!fValidate)
elemDecl->setCreateReason(XMLElementDecl::Declared);
}
else
{
// If its not marked declared and validating, then emit an error
- if (!elemDecl->isDeclared() && fDoValidation)
+ if (!elemDecl->isDeclared() && fValidate)
{
fValidator->emitError
(
@@ -2048,7 +2061,7 @@
//
if (isRoot)
{
- if (fDoValidation)
+ if (fValidate)
{
if (!fValidator->checkRootElement(elemDecl->getId()))
fValidator->emitError(XMLValid::RootElemNotLikeDocType);
@@ -2188,7 +2201,7 @@
// If there is a validation handler, then we are validating
// so emit an error.
//
- if (fDoValidation)
+ if (fValidate)
{
fValidator->emitError
(
@@ -2379,7 +2392,7 @@
if (!curDef.getProvided())
{
- if (fDoValidation)
+ if (fValidate)
{
// If we are validating and its required, then an error
if (defType == XMLAttDef::Required)
@@ -2439,7 +2452,7 @@
if (isEmpty)
{
// If validating, then insure that its legal to have no content
- if (fDoValidation)
+ if (fValidate)
{
const int res = fValidator->checkContent(elemDecl->getId(), 0, 0);
if (res >= 0)
@@ -2626,7 +2639,7 @@
if (wasAdded)
{
// If validating then emit an error
- if (fDoValidation)
+ if (fValidate)
{
fValidator->emitError
(
@@ -2640,13 +2653,13 @@
// things simpler and we aren't going to do do the validation checks
// that need to know if it was really declared or not anyway.
//
- if (!fDoValidation)
+ if (!fValidate)
elemDecl->setCreateReason(XMLElementDecl::Declared);
}
else
{
// If its not marked declared and validating, then emit an error
- if (!elemDecl->isDeclared() && fDoValidation)
+ if (!elemDecl->isDeclared() && fValidate)
{
fValidator->emitError
(
@@ -2671,7 +2684,7 @@
//
if (isRoot)
{
- if (fDoValidation)
+ if (fValidate)
{
if (!fValidator->checkRootElement(elemDecl->getId()))
fValidator->emitError(XMLValid::RootElemNotLikeDocType);
@@ -2709,7 +2722,7 @@
fElemStack.popTop();
// If validating, then insure that its legal to have no content
- if (fDoValidation)
+ if (fValidate)
{
const int res = fValidator->checkContent(elemDecl->getId(), 0, 0);
if (res >= 0)
1.9 +79 -14 xml-xerces/c/src/internal/XMLScanner.hpp
Index: XMLScanner.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/internal/XMLScanner.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XMLScanner.hpp 2000/03/03 01:29:32 1.8
+++ XMLScanner.hpp 2000/04/12 22:58:28 1.9
@@ -56,6 +56,9 @@
/*
* $Log: XMLScanner.hpp,v $
+ * Revision 1.9 2000/04/12 22:58:28 roddey
+ * Added support for 'auto validate' mode.
+ *
* Revision 1.8 2000/03/03 01:29:32 roddey
* Added a scanReset()/parseReset() method to the scanner and
* parsers, to allow for reset after early exit from a progressive parse.
@@ -147,6 +150,11 @@
// XMLTokens
// These represent the possible types of input we can get while
// scanning content.
+ //
+ // ValScheme
+ // This indicates what the scanner should do in terms of validation.
+ // 'Auto' means if there is any int/ext subset, then validate. Else,
+ // don't.
// -----------------------------------------------------------------------
enum DeclTypes
{
@@ -173,6 +181,13 @@
, Token_Unknown
};
+ enum ValSchemes
+ {
+ Val_Never
+ , Val_Always
+ , Val_Auto
+ };
+
// -----------------------------------------------------------------------
// Constructors and Destructor
@@ -219,7 +234,7 @@
const XMLDocumentHandler* getDocHandler() const;
XMLDocumentHandler* getDocHandler();
bool getDoNamespaces() const;
- bool getDoValidation() const;
+ ValSchemes getValidationScheme() const;
const XMLEntityHandler* getEntityHandler() const;
XMLEntityHandler* getEntityHandler();
const XMLErrorReporter* getErrorReporter() const;
@@ -249,14 +264,22 @@
// -----------------------------------------------------------------------
void setDocHandler(XMLDocumentHandler* const docHandler);
void setDoNamespaces(const bool doNamespaces);
- void setDoValidation(const bool validate);
void setEntityHandler(XMLEntityHandler* const docTypeHandler);
void setErrorReporter(XMLErrorReporter* const errHandler);
void setExitOnFirstFatal(const bool newValue);
+ void setValidationScheme(const ValSchemes newScheme);
void setValidator(XMLValidator* const validator);
// -----------------------------------------------------------------------
+ // Deprecated methods as of 3.2.0. Use getValidationScheme() and
+ // setValidationScheme() instead.
+ // -----------------------------------------------------------------------
+ bool getDoValidation() const;
+ void setDoValidation(const bool validate);
+
+
+ // -----------------------------------------------------------------------
// Document scanning methods
//
// scanDocument() does the entire source document. scanFirst(),
@@ -485,12 +508,6 @@
// namespaces or not. If the installed validator indicates that it
// has to do namespaces, then this is ignored.
//
- // fDoValidation
- // Indicates whether any validation should be done. A validator
- // can still be installed and it will build up all the data
- // structures for the DTD/Schema declarations, but the scanner will
- // not ask it to validate anything.
- //
// fElemStack
// This is the element stack that is used to track the elements that
// are currently being worked on.
@@ -508,6 +525,11 @@
// or not. It defaults to true, which is the strict XML way, but it
// can be changed.
//
+ // fHaveSubset
+ // Indicates whether any internal/external DTD subset has been seen
+ // so far. Its cleared before a new parse, so it is used along with
+ // fValScheme to know whether we should validate or not.
+ //
// fIDRefList
// This is a list of XMLRefInfo objects. This member lets us do all
// needed ID-IDREF balancing checks.
@@ -544,10 +566,19 @@
// Indicates whether the document is standalone or not. Defaults to
// no, but can be overridden in the XMLDecl.
//
+ // fValidate
+ // Indicates whether any validation should be done. Once we reach
+ // the point past the DOCTYPE, we check fHaveSubset and fValScheme
+ // and use them to set this flag, which is then used to control
+ // whether validation is done.
+ //
// fValidator
// The installed validator. We look at them via the abstract
// validator interface, and don't know what it actual is.
//
+ // fValScheme
+ // This is the currently set validation scheme. It defaults to
+ // 'never', but can be set by the client.
//
// fAttName
// fAttValue
@@ -566,11 +597,11 @@
XMLBufferMgr fBufMgr;
XMLDocumentHandler* fDocHandler;
bool fDoNamespaces;
- bool fDoValidation;
ElemStack fElemStack;
XMLEntityHandler* fEntityHandler;
XMLErrorReporter* fErrorReporter;
bool fExitOnFirstFatal;
+ bool fHaveSubset;
RefHashTableOf<XMLRefInfo>* fIDRefList;
bool fInException;
RefVectorOf<KVStringPair>* fRawAttrList;
@@ -579,7 +610,9 @@
XMLUInt32 fScannerId;
XMLUInt32 fSequenceId;
bool fStandalone;
+ bool fValidate;
XMLValidator* fValidator;
+ ValSchemes fValScheme;
XMLBuffer fAttNameBuf;
XMLBuffer fAttValueBuf;
@@ -610,11 +643,6 @@
return fDoNamespaces;
}
-inline bool XMLScanner::getDoValidation() const
-{
- return fDoValidation;
-}
-
inline const XMLEntityHandler* XMLScanner::getEntityHandler() const
{
return fEntityHandler;
@@ -670,6 +698,11 @@
return fStandalone;
}
+inline XMLScanner::ValSchemes XMLScanner::getValidationScheme() const
+{
+ return fValScheme;
+}
+
inline const XMLValidator* XMLScanner::getValidator() const
{
return fValidator;
@@ -708,6 +741,35 @@
inline void XMLScanner::setExitOnFirstFatal(const bool newValue)
{
fExitOnFirstFatal = newValue;
+}
+
+inline void XMLScanner::setValidationScheme(const ValSchemes newScheme)
+{
+ fValScheme = newScheme;
+}
+
+inline void XMLScanner::setValidator(XMLValidator* const validator)
+{
+ fValidator = validator;
+}
+
+
+// ---------------------------------------------------------------------------
+// XMLScanner: Deprecated methods
+// ---------------------------------------------------------------------------
+inline bool XMLScanner::getDoValidation() const
+{
+ if (fValScheme == Val_Always)
+ return true;
+ return false;
+}
+
+inline void XMLScanner::setDoValidation(const bool validate)
+{
+ if (validate)
+ fValScheme = Val_Always;
+ else
+ fValScheme = Val_Never;
}
#endif
1.12 +8 -3 xml-xerces/c/src/internal/XMLScanner2.cpp
Index: XMLScanner2.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/internal/XMLScanner2.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- XMLScanner2.cpp 2000/03/02 19:54:30 1.11
+++ XMLScanner2.cpp 2000/04/12 22:58:28 1.12
@@ -56,6 +56,9 @@
/*
* $Log: XMLScanner2.cpp,v $
+ * Revision 1.12 2000/04/12 22:58:28 roddey
+ * Added support for 'auto validate' mode.
+ *
* Revision 1.11 2000/03/02 19:54:30 roddey
* This checkin includes many changes done while waiting for the
* 1.1.0 code to be finished. I can't list them all here, but a list is
@@ -267,7 +270,7 @@
//
if (wasAdded)
{
- if (fDoValidation && !isNSAttr)
+ if (fValidate && !isNSAttr)
{
XMLBuffer bufURI;
fValidator->getURIText(uriId, bufURI);
@@ -401,7 +404,7 @@
if (!curDef.getProvided())
{
- if (fDoValidation)
+ if (fValidate)
{
// If we are validating and its required, then an error
if (defType == XMLAttDef::Required)
@@ -827,7 +830,7 @@
// not. If not, its always just characters; else, it depends on the
// current element's content model.
//
- if (fDoValidation)
+ if (fValidate)
{
// See if all the text is whitespace
const bool isSpaces = XMLReader::isAllSpaces(rawBuf, len);
1.15 +54 -9 xml-xerces/c/src/parsers/DOMParser.cpp
Index: DOMParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/parsers/DOMParser.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DOMParser.cpp 2000/03/24 21:25:28 1.14
+++ DOMParser.cpp 2000/04/12 22:58:29 1.15
@@ -60,6 +60,9 @@
* are created and added to the DOM tree.
*
* $Log: DOMParser.cpp,v $
+* Revision 1.15 2000/04/12 22:58:29 roddey
+* Added support for 'auto validate' mode.
+*
* Revision 1.14 2000/03/24 21:25:28 abagchi
* Added getElementById() from patch submitted by Jeff Lewis
*
@@ -207,16 +210,25 @@
return fScanner->getDoNamespaces();
}
-bool DOMParser::getDoValidation() const
+bool DOMParser::getExitOnFirstFatalError() const
{
- return fScanner->getDoValidation();
+ return fScanner->getExitOnFirstFatal();
}
-bool DOMParser::getExitOnFirstFatalError() const
+DOMParser::ValSchemes DOMParser::getValidationScheme() const
{
- return fScanner->getExitOnFirstFatal();
+ const XMLScanner::ValSchemes scheme = fScanner->getValidationScheme();
+
+ if (scheme == XMLScanner::Val_Always)
+ return Val_Always;
+ else if (scheme == XMLScanner::Val_Never)
+ return Val_Never;
+
+ return Val_Auto;
}
+
+
// ---------------------------------------------------------------------------
// DOMParser: Setter methods
// ---------------------------------------------------------------------------
@@ -225,11 +237,6 @@
fScanner->setDoNamespaces(newState);
}
-void DOMParser::setDoValidation(const bool newState)
-{
- fScanner->setDoValidation(newState);
-}
-
void DOMParser::setErrorHandler(ErrorHandler* const handler)
{
fErrorHandler = handler;
@@ -259,6 +266,17 @@
fScanner->setExitOnFirstFatal(newState);
}
+void DOMParser::setValidationScheme(const ValSchemes newScheme)
+{
+ if (newScheme == Val_Never)
+ fScanner->setValidationScheme(XMLScanner::Val_Never);
+ else if (newScheme == Val_Always)
+ fScanner->setValidationScheme(XMLScanner::Val_Always);
+ else
+ fScanner->setValidationScheme(XMLScanner::Val_Auto);
+}
+
+
// ---------------------------------------------------------------------------
// DOMParser: Parsing methods
@@ -659,4 +677,31 @@
, const XMLCh* const)
{
// This is not used by DOM at this time
+}
+
+
+
+// ---------------------------------------------------------------------------
+// DOMParser: Deprecated methods
+// ---------------------------------------------------------------------------
+bool DOMParser::getDoValidation() const
+{
+ //
+ // We don't want to tie the public parser classes to the enum used
+ // by the scanner, so we use a separate one and map.
+ //
+ // DON'T mix the new and old methods!!
+ //
+ const XMLScanner::ValSchemes scheme = fScanner->getValidationScheme();
+ if (scheme == XMLScanner::Val_Always)
+ return true;
+ return false;
+}
+
+void DOMParser::setDoValidation(const bool newState)
+{
+ fScanner->setDoValidation
+ (
+ newState ? XMLScanner::Val_Always : XMLScanner::Val_Never
+ );
}
1.8 +66 -28 xml-xerces/c/src/parsers/DOMParser.hpp
Index: DOMParser.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/parsers/DOMParser.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DOMParser.hpp 2000/03/24 01:31:12 1.7
+++ DOMParser.hpp 2000/04/12 22:58:29 1.8
@@ -56,6 +56,9 @@
/*
* $Log: DOMParser.hpp,v $
+ * Revision 1.8 2000/04/12 22:58:29 roddey
+ * Added support for 'auto validate' mode.
+ *
* Revision 1.7 2000/03/24 01:31:12 chchou
* Fix bug #8 to support ignorable whitespace text nodes
*
@@ -124,6 +127,17 @@
{
public :
// -----------------------------------------------------------------------
+ // Class types
+ // -----------------------------------------------------------------------
+ enum ValSchemes
+ {
+ Val_Never
+ , Val_Always
+ , Val_Auto
+ };
+
+
+ // -----------------------------------------------------------------------
// Constructors and Detructor
// -----------------------------------------------------------------------
@@ -227,6 +241,14 @@
*/
const XMLValidator& getValidator() const;
+ /**
+ * This method returns an enumerated value that indicates the current
+ * validation scheme set on this parser.
+ *
+ * @return The ValSchemes value current set on this parser.
+ */
+ ValSchemes getValidationScheme() const;
+
/** Get the 'do namespaces' flag
*
* This method returns the state of the parser's namespace processing
@@ -239,18 +261,6 @@
*/
bool getDoNamespaces() const;
- /** Get the 'do validation' flag
- *
- * This method returns the state of the parser's validation handling
- * flag which controls whether validation checks are enforced or not.
- *
- * @return true, if the parser is currently configured to
- * do validation, false otherwise.
- *
- * @see #setDoValidation
- */
- bool getDoValidation() const;
-
/** Get the 'exit on first error' flag
*
* This method returns the state of the parser's
@@ -351,22 +361,6 @@
*/
void setDoNamespaces(const bool newState);
- /** Set the 'do validation' flag
- *
- * This method allows users to enable or disable the parser's validation
- * checks.
- *
- * <p>By default, the parser does not to any validation. The default
- * value is false.</p>
- *
- * @param newState The value specifying whether the parser should
- * do validity checks or not against the DTD in the
- * input XML document.
- *
- * @see #getDoValidation
- */
- void setDoValidation(const bool newState);
-
/** Set the 'exit on first error' flag
*
* This method allows users to set the parser's behaviour when it
@@ -420,6 +414,19 @@
*/
void setIncludeIgnorableWhitespace(const bool include);
+ /**
+ * This method allows users to set the validation scheme to be used
+ * by this parser. The value is one of the ValSchemes enumerated values
+ * defined by this class.
+ *
+ * <p>The parser's default state is: Val_Auto.</p>
+ *
+ * @param newState The new validation scheme to use.
+ *
+ * @see #getValidationScheme
+ */
+ void setValidationScheme(const ValSchemes newScheme);
+
//@}
@@ -997,6 +1004,37 @@
, const XMLCh* const standaloneStr
, const XMLCh* const actualEncStr
);
+ //@}
+
+
+ /** @name Deprecated Methods */
+ //@{
+ /**
+ * This method returns the state of the parser's validation
+ * handling flag which controls whether validation checks
+ * are enforced or not.
+ *
+ * @return true, if the parser is currently configured to
+ * do validation, false otherwise.
+ *
+ * @see #setDoValidation
+ */
+ bool getDoValidation() const;
+
+ /**
+ * This method allows users to enable or disable the parser's validation
+ * checks.
+ *
+ * <p>By default, the parser does not to any validation. The default
+ * value is false.</p>
+ *
+ * @param newState The value specifying whether the parser should
+ * do validity checks or not against the DTD in the
+ * input XML document.
+ *
+ * @see #getDoValidation
+ */
+ void setDoValidation(const bool newState);
//@}
1.10 +63 -18 xml-xerces/c/src/parsers/SAXParser.cpp
Index: SAXParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/parsers/SAXParser.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SAXParser.cpp 2000/04/11 19:17:58 1.9
+++ SAXParser.cpp 2000/04/12 22:58:30 1.10
@@ -56,6 +56,9 @@
/*
* $Log: SAXParser.cpp,v $
+ * Revision 1.10 2000/04/12 22:58:30 roddey
+ * Added support for 'auto validate' mode.
+ *
* Revision 1.9 2000/04/11 19:17:58 roddey
* If a SAX error handler is installed, then the resetErrors() event handler
* should call the one on the installed SAX error handler.
@@ -242,52 +245,66 @@
// ---------------------------------------------------------------------------
-// SAXParser: Setter methods
+// SAXParser: Getter methods
// ---------------------------------------------------------------------------
-void SAXParser::setDoNamespaces(const bool newState)
+const XMLValidator& SAXParser::getValidator() const
{
- fScanner->setDoNamespaces(newState);
+ return *fValidator;
}
-void SAXParser::setDoValidation(const bool newState)
+bool SAXParser::getDoNamespaces() const
{
- fScanner->setDoValidation(newState);
+ return fScanner->getDoNamespaces();
}
-void SAXParser::setExitOnFirstFatalError(const bool newState)
+bool SAXParser::getExitOnFirstFatalError() const
{
- fScanner->setExitOnFirstFatal(newState);
+ return fScanner->getExitOnFirstFatal();
}
+SAXParser::ValSchemes SAXParser::getValidationScheme() const
+{
+ const XMLScanner::ValSchemes scheme = fScanner->getValidationScheme();
+
+ if (scheme == XMLScanner::Val_Always)
+ return Val_Always;
+ else if (scheme == XMLScanner::Val_Never)
+ return Val_Never;
+
+ return Val_Auto;
+}
+
// ---------------------------------------------------------------------------
-// SAXParser: Getter methods
+// SAXParser: Setter methods
// ---------------------------------------------------------------------------
-const XMLValidator& SAXParser::getValidator() const
+void SAXParser::setDoNamespaces(const bool newState)
{
- return *fValidator;
+ fScanner->setDoNamespaces(newState);
}
-bool SAXParser::getDoNamespaces() const
+void SAXParser::setExitOnFirstFatalError(const bool newState)
{
- return fScanner->getDoNamespaces();
+ fScanner->setExitOnFirstFatal(newState);
}
-bool SAXParser::getDoValidation() const
-{
- return fScanner->getDoValidation();
-}
-bool SAXParser::getExitOnFirstFatalError() const
+void SAXParser::setValidationScheme(const ValSchemes newScheme)
{
- return fScanner->getExitOnFirstFatal();
+ if (newScheme == Val_Never)
+ fScanner->setValidationScheme(XMLScanner::Val_Never);
+ else if (newScheme == Val_Always)
+ fScanner->setValidationScheme(XMLScanner::Val_Always);
+ else
+ fScanner->setValidationScheme(XMLScanner::Val_Auto);
}
+
// ---------------------------------------------------------------------------
// SAXParser: Overrides of the SAX Parser interface
// ---------------------------------------------------------------------------
@@ -923,4 +940,31 @@
void SAXParser::startInputSource(const InputSource&)
{
// Nothing to do for this one
+}
+
+
+
+// ---------------------------------------------------------------------------
+// SAXParser: Deprecated methods
+// ---------------------------------------------------------------------------
+bool SAXParser::getDoValidation() const
+{
+ //
+ // We don't want to tie the public parser classes to the enum used
+ // by the scanner, so we use a separate one and map.
+ //
+ // DON'T mix the new and old methods!!
+ //
+ const XMLScanner::ValSchemes scheme = fScanner->getValidationScheme();
+ if (scheme == XMLScanner::Val_Always)
+ return true;
+ return false;
+}
+
+void SAXParser::setDoValidation(const bool newState)
+{
+ fScanner->setDoValidation
+ (
+ newState ? XMLScanner::Val_Always : XMLScanner::Val_Never
+ );
}
1.8 +63 -21 xml-xerces/c/src/parsers/SAXParser.hpp
Index: SAXParser.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/parsers/SAXParser.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SAXParser.hpp 2000/03/03 01:29:34 1.7
+++ SAXParser.hpp 2000/04/12 22:58:30 1.8
@@ -56,6 +56,9 @@
/*
* $Log: SAXParser.hpp,v $
+ * Revision 1.8 2000/04/12 22:58:30 roddey
+ * Added support for 'auto validate' mode.
+ *
* Revision 1.7 2000/03/03 01:29:34 roddey
* Added a scanReset()/parseReset() method to the scanner and
* parsers, to allow for reset after early exit from a progressive parse.
@@ -125,6 +128,17 @@
{
public :
// -----------------------------------------------------------------------
+ // Class types
+ // -----------------------------------------------------------------------
+ enum ValSchemes
+ {
+ Val_Never
+ , Val_Always
+ , Val_Auto
+ };
+
+
+ // -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
@@ -211,6 +225,14 @@
const XMLValidator& getValidator() const;
/**
+ * This method returns an enumerated value that indicates the current
+ * validation scheme set on this parser.
+ *
+ * @return The ValSchemes value current set on this parser.
+ */
+ ValSchemes getValidationScheme() const;
+
+ /**
* This method returns the state of the parser's namespace
* handling capability.
*
@@ -222,18 +244,6 @@
bool getDoNamespaces() const;
/**
- * This method returns the state of the parser's validation
- * handling flag which controls whether validation checks
- * are enforced or not.
- *
- * @return true, if the parser is currently configured to
- * do validation, false otherwise.
- *
- * @see #setDoValidation
- */
- bool getDoValidation() const;
-
- /**
* This method returns the state of the parser's
* exit-on-First-Fatal-Error flag.
*
@@ -272,19 +282,17 @@
void setDoNamespaces(const bool newState);
/**
- * This method allows users to enable or disable the parser's validation
- * checks.
+ * This method allows users to set the validation scheme to be used
+ * by this parser. The value is one of the ValSchemes enumerated values
+ * defined by this class.
*
- * <p>By default, the parser does not to any validation. The default
- * value is false.</p>
+ * <p>The parser's default state is: Val_Auto.</p>
*
- * @param newState The value specifying whether the parser should
- * do validity checks or not against the DTD in the
- * input XML document.
+ * @param newState The new validation scheme to use.
*
- * @see #getDoValidation
+ * @see #getValidationScheme
*/
- void setDoValidation(const bool newState);
+ void setValidationScheme(const ValSchemes newScheme);
/**
* This method allows users to set the parser's behaviour when it
@@ -1226,6 +1234,37 @@
* being parsed.
*/
virtual void startInputSource(const InputSource& inputSource);
+ //@}
+
+
+ /** @name Deprecated Methods */
+ //@{
+ /**
+ * This method returns the state of the parser's validation
+ * handling flag which controls whether validation checks
+ * are enforced or not.
+ *
+ * @return true, if the parser is currently configured to
+ * do validation, false otherwise.
+ *
+ * @see #setDoValidation
+ */
+ bool getDoValidation() const;
+
+ /**
+ * This method allows users to enable or disable the parser's validation
+ * checks.
+ *
+ * <p>By default, the parser does not to any validation. The default
+ * value is false.</p>
+ *
+ * @param newState The value specifying whether the parser should
+ * do validity checks or not against the DTD in the
+ * input XML document.
+ *
+ * @see #getDoValidation
+ */
+ void setDoValidation(const bool newState);
//@}