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/05/22 22:54:14 UTC
cvs commit: xml-xerces/c/src/xercesc/validators/schema SchemaValidator.hpp TraverseSchema.cpp TraverseSchema.hpp XSDDOMParser.cpp XSDDOMParser.hpp XSDErrorReporter.cpp XSDErrorReporter.hpp
knoaman 02/05/22 13:54:14
Modified: c/src/xercesc/validators/schema SchemaValidator.hpp
TraverseSchema.cpp TraverseSchema.hpp
XSDDOMParser.cpp XSDDOMParser.hpp
XSDErrorReporter.cpp XSDErrorReporter.hpp
Log:
Prepare for DOM L3 :
- Make use of the XMLEntityHandler/XMLErrorReporter interfaces, instead of using
EntityHandler/ErrorHandler directly.
- Add 'AbstractDOMParser' class to provide common functionality for XercesDOMParser
and DOMBuilder.
Revision Changes Path
1.5 +15 -11 xml-xerces/c/src/xercesc/validators/schema/SchemaValidator.hpp
Index: SchemaValidator.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaValidator.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SchemaValidator.hpp 19 Apr 2002 13:33:23 -0000 1.4
+++ SchemaValidator.hpp 22 May 2002 20:54:14 -0000 1.5
@@ -56,6 +56,13 @@
/*
* $Log: SchemaValidator.hpp,v $
+ * Revision 1.5 2002/05/22 20:54:14 knoaman
+ * Prepare for DOM L3 :
+ * - Make use of the XMLEntityHandler/XMLErrorReporter interfaces, instead of using
+ * EntityHandler/ErrorHandler directly.
+ * - Add 'AbstractDOMParser' class to provide common functionality for XercesDOMParser
+ * and DOMBuilder.
+ *
* Revision 1.4 2002/04/19 13:33:23 knoaman
* Fix for bug 8236.
*
@@ -135,7 +142,7 @@
, const unsigned int uriId);
void setNillable(bool isNil);
- void setErrorHandler(ErrorHandler* const handler);
+ void setErrorReporter(XMLErrorReporter* const errorReporter);
void setExitOnFirstFatal(const bool newValue);
// -----------------------------------------------------------------------
@@ -349,6 +356,11 @@
fNil = isNil;
}
+inline void SchemaValidator::setExitOnFirstFatal(const bool newValue) {
+
+ fSchemaErrorReporter.setExitOnFirstFatal(newValue);
+}
+
// ---------------------------------------------------------------------------
// Virtual interface
// ---------------------------------------------------------------------------
@@ -360,6 +372,12 @@
fSchemaGrammar = (SchemaGrammar*) aGrammar;
}
+inline void SchemaValidator::setErrorReporter(XMLErrorReporter* const errorReporter) {
+
+ XMLValidator::setErrorReporter(errorReporter);
+ fSchemaErrorReporter.setErrorReporter(errorReporter);
+}
+
// ---------------------------------------------------------------------------
// SchemaValidator: DTD handler interface
// ---------------------------------------------------------------------------
@@ -390,16 +408,6 @@
return true;
}
return false;
-}
-
-inline void SchemaValidator::setErrorHandler(ErrorHandler* const handler) {
-
- fSchemaErrorReporter.setErrorHandler(handler);
-}
-
-inline void SchemaValidator::setExitOnFirstFatal(const bool newValue) {
-
- fSchemaErrorReporter.setExitOnFirstFatal(newValue);
}
#endif
1.16 +33 -41 xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp
Index: TraverseSchema.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- TraverseSchema.cpp 21 May 2002 19:32:37 -0000 1.15
+++ TraverseSchema.cpp 22 May 2002 20:54:14 -0000 1.16
@@ -55,14 +55,14 @@
*/
/*
- * $Id: TraverseSchema.cpp,v 1.15 2002/05/21 19:32:37 tng Exp $
+ * $Id: TraverseSchema.cpp,v 1.16 2002/05/22 20:54:14 knoaman Exp $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/TraverseSchema.hpp>
-#include <xercesc/sax/EntityResolver.hpp>
+#include <xercesc/framework/XMLEntityHandler.hpp>
#include <xercesc/validators/schema/identity/IC_Key.hpp>
#include <xercesc/validators/schema/identity/IC_KeyRef.hpp>
#include <xercesc/validators/schema/identity/IC_Unique.hpp>
@@ -80,7 +80,6 @@
#include <xercesc/validators/schema/NamespaceScope.hpp>
#include <xercesc/validators/schema/SchemaAttDefList.hpp>
#include <xercesc/internal/XMLScanner.hpp>
-#include <xercesc/internal/XMLInternalErrorHandler.hpp>
#include <xercesc/framework/LocalFileInputSource.hpp>
#include <xercesc/framework/URLInputSource.hpp>
#include <xercesc/validators/schema/identity/XPathException.hpp>
@@ -185,8 +184,8 @@
, XMLScanner* const xmlScanner
, XMLValidator* const xmlValidator
, const XMLCh* const schemaURL
- , EntityResolver* const entityResolver
- , ErrorHandler* const errorHandler)
+ , XMLEntityHandler* const entityHandler
+ , XMLErrorReporter* const errorReporter)
: fFullConstraintChecking(false)
, fTargetNSURI(-1)
, fEmptyNamespaceURI(-1)
@@ -198,8 +197,8 @@
, fDatatypeRegistry(0)
, fGrammarResolver(grammarResolver)
, fSchemaGrammar(schemaGrammar)
- , fEntityResolver(entityResolver)
- , fErrorHandler(errorHandler)
+ , fEntityHandler(entityHandler)
+ , fErrorReporter(errorReporter)
, fURIStringPool(uriStringPool)
, fStringPool(0)
, fValidator(xmlValidator)
@@ -406,12 +405,12 @@
elemAttrDefaultQualified |= Elem_Def_Qualified;
}
- if (!XMLString::compareString(schemaRoot->getAttribute(SchemaSymbols::fgATT_ATTRIBUTEFORMDEFAULT),
+ if (!XMLString::compareString(schemaRoot->getAttribute(SchemaSymbols::fgATT_ATTRIBUTEFORMDEFAULT),
SchemaSymbols::fgATTVAL_QUALIFIED)) {
elemAttrDefaultQualified |= Attr_Def_Qualified;
}
- fSchemaInfo->setElemAttrDefaultQualified(elemAttrDefaultQualified);
+ fSchemaInfo->setElemAttrDefaultQualified(elemAttrDefaultQualified);
fSchemaInfo->setBlockDefault(parseBlockSet(schemaRoot, ES_Block, true));
fSchemaInfo->setFinalDefault(parseFinalSet(schemaRoot, ECS_Final, true));
}
@@ -503,26 +502,24 @@
// ------------------------------------------------------------------
// Parse input source
// ------------------------------------------------------------------
- XMLInternalErrorHandler internalErrorHandler(fErrorHandler);
-
if (!fParser)
fParser = new XSDDOMParser;
fParser->setValidationScheme(XercesDOMParser::Val_Never);
fParser->setDoNamespaces(true);
- fParser->setErrorHandler((ErrorHandler*) &internalErrorHandler);
- fParser->setEntityResolver(fEntityResolver);
+ fParser->setUserEntityHandler(fEntityHandler);
+ fParser->setUserErrorReporter(fErrorReporter);
// Should just issue warning if the schema is not found
const bool flag = srcToFill->getIssueFatalErrorIfNotFound();
srcToFill->setIssueFatalErrorIfNotFound(false);
- fParser->parse(*srcToFill) ;
+ fParser->parse(*srcToFill);
// Reset the InputSource
srcToFill->setIssueFatalErrorIfNotFound(flag);
- if (internalErrorHandler.getSawFatal() && fScanner->getExitOnFirstFatal())
+ if (fParser->getSawFatal() && fScanner->getExitOnFirstFatal())
reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::SchemaScanFatalError);
// ------------------------------------------------------------------
@@ -685,15 +682,13 @@
// ------------------------------------------------------------------
// Parse input source
// ------------------------------------------------------------------
- XMLInternalErrorHandler internalErrorHandler(fErrorHandler);
-
if (!fParser)
fParser = new XSDDOMParser;
fParser->setValidationScheme(XercesDOMParser::Val_Never);
fParser->setDoNamespaces(true);
- fParser->setErrorHandler((ErrorHandler*) &internalErrorHandler);
- fParser->setEntityResolver(fEntityResolver);
+ fParser->setUserEntityHandler(fEntityHandler);
+ fParser->setUserErrorReporter(fErrorReporter);
// Should just issue warning if the schema is not found
const bool flag = srcToFill->getIssueFatalErrorIfNotFound();
@@ -704,7 +699,7 @@
// Reset the InputSource
srcToFill->setIssueFatalErrorIfNotFound(flag);
- if (internalErrorHandler.getSawFatal() && fScanner->getExitOnFirstFatal())
+ if (fParser->getSawFatal() && fScanner->getExitOnFirstFatal())
reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::SchemaScanFatalError);
// ------------------------------------------------------------------
@@ -970,7 +965,7 @@
// Process contents
// ------------------------------------------------------------------
const XMLCh* name = getElementAttValue(childElem,SchemaSymbols::fgATT_NAME);
- bool nameEmpty = (XMLString::stringLen(name) == 0);
+ bool nameEmpty = (XMLString::stringLen(name) == 0);
if (topLevel && nameEmpty) {
reportSchemaError(childElem, XMLUni::fgXMLErrDomain, XMLErrs::NoNameGlobalElement,
@@ -1416,7 +1411,7 @@
fBuffer.set(fullName);
fBuffer.append(SchemaSymbols::fgRedefIdentifier);
- groupInfo->setBaseGroup(fGroupRegistry->get(fBuffer.getRawBuffer()));
+ groupInfo->setBaseGroup(fGroupRegistry->get(fBuffer.getRawBuffer()));
}
}
@@ -2656,7 +2651,7 @@
reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::Notation_InvalidDecl, name);
}
- fNotationRegistry->put((void*) fStringPool->getValueForId(fStringPool->addOrFind(name)),
+ fNotationRegistry->put((void*) fStringPool->getValueForId(fStringPool->addOrFind(name)),
fTargetNSURI, 0);
//we don't really care if something inside <notation> is wrong..
@@ -3331,7 +3326,7 @@
}
else {
- const XMLCh* facetNameStr =
+ const XMLCh* facetNameStr =
fStringPool->getValueForId(fStringPool->addOrFind(facetName));
facets->put((void*) facetNameStr, new KVStringPair(facetNameStr, attValue));
@@ -3918,7 +3913,7 @@
fBuffer.reset();
unsigned int startIndex = 0;
-
+
while (startIndex < xpathLen) {
if (!XMLString::startsWith(xpathExpr + startIndex, fgForwardSlash)
@@ -3932,7 +3927,7 @@
break;
fBuffer.append(xpathExpr + startIndex, chOffset + 1 - startIndex);
- startIndex = chOffset + 1;
+ startIndex = chOffset + 1;
}
if (startIndex < xpathLen)
@@ -5458,7 +5453,7 @@
}
// Check for derivation valid (extension) - 1.4.2.2
- if (baseContentType != SchemaElementDecl::Empty
+ if (baseContentType != SchemaElementDecl::Empty
&& baseContentType != SchemaElementDecl::Simple) {
if ((isMixed && baseContentType == SchemaElementDecl::Children)
|| (!isMixed && baseContentType != SchemaElementDecl::Children)) {
@@ -6090,9 +6085,8 @@
// ------------------------------------------------------------------
InputSource* srcToFill = 0;
- if (fEntityResolver){
- srcToFill = fEntityResolver->resolveEntity(XMLUni::fgZeroLenString,
- loc);
+ if (fEntityHandler){
+ srcToFill = fEntityHandler->resolveEntity(XMLUni::fgZeroLenString, loc);
}
// If they didn't create a source via the entity resolver, then we
@@ -7218,15 +7212,13 @@
// ------------------------------------------------------------------
// Parse input source
// ------------------------------------------------------------------
- XMLInternalErrorHandler internalErrorHandler(fErrorHandler);
-
if (!fParser)
fParser = new XSDDOMParser;
fParser->setValidationScheme(XercesDOMParser::Val_Never);
fParser->setDoNamespaces(true);
- fParser->setErrorHandler((ErrorHandler*) &internalErrorHandler);
- fParser->setEntityResolver(fEntityResolver);
+ fParser->setUserEntityHandler(fEntityHandler);
+ fParser->setUserErrorReporter(fErrorReporter);
// Should just issue warning if the schema is not found
const bool flag = srcToFill->getIssueFatalErrorIfNotFound();
@@ -7237,7 +7229,7 @@
// Reset the InputSource
srcToFill->setIssueFatalErrorIfNotFound(flag);
- if (internalErrorHandler.getSawFatal() && fScanner->getExitOnFirstFatal())
+ if (fParser->getSawFatal() && fScanner->getExitOnFirstFatal())
reportSchemaError(redefineElem, XMLUni::fgXMLErrDomain, XMLErrs::SchemaScanFatalError);
// ------------------------------------------------------------------
@@ -7666,7 +7658,7 @@
const XMLCh* const msgDomain,
const int errorCode) {
- fErrorReporter.emitError(errorCode, msgDomain, aLocator);
+ fXSDErrorReporter.emitError(errorCode, msgDomain, aLocator);
}
void TraverseSchema::reportSchemaError(const XSDLocator* const aLocator,
@@ -7677,7 +7669,7 @@
const XMLCh* const text3,
const XMLCh* const text4) {
- fErrorReporter.emitError(errorCode, msgDomain, aLocator, text1, text2, text3, text4);
+ fXSDErrorReporter.emitError(errorCode, msgDomain, aLocator, text1, text2, text3, text4);
}
void TraverseSchema::reportSchemaError(const DOMElement* const elem,
@@ -7688,7 +7680,7 @@
((XSDElementNSImpl*) elem)->getLineNo(),
((XSDElementNSImpl*) elem)->getColumnNo());
- fErrorReporter.emitError(errorCode, msgDomain, fLocator);
+ fXSDErrorReporter.emitError(errorCode, msgDomain, fLocator);
}
void TraverseSchema::reportSchemaError(const DOMElement* const elem,
@@ -7703,7 +7695,7 @@
((XSDElementNSImpl*) elem)->getLineNo(),
((XSDElementNSImpl*) elem)->getColumnNo());
- fErrorReporter.emitError(errorCode, msgDomain, fLocator, text1, text2, text3, text4);
+ fXSDErrorReporter.emitError(errorCode, msgDomain, fLocator, text1, text2, text3, text4);
}
// ---------------------------------------------------------------------------
@@ -7711,12 +7703,12 @@
// ---------------------------------------------------------------------------
void TraverseSchema::init() {
- fErrorReporter.setErrorHandler(fErrorHandler);
+ fXSDErrorReporter.setErrorReporter(fErrorReporter);
if (fScanner && fScanner->getValidationSchemaFullChecking()) {
fFullConstraintChecking = true;
- fErrorReporter.setExitOnFirstFatal(fScanner->getExitOnFirstFatal());
+ fXSDErrorReporter.setExitOnFirstFatal(fScanner->getExitOnFirstFatal());
}
fDatatypeRegistry = fGrammarResolver->getDatatypeRegistry();
1.9 +20 -21 xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp
Index: TraverseSchema.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- TraverseSchema.hpp 21 May 2002 19:32:37 -0000 1.8
+++ TraverseSchema.hpp 22 May 2002 20:54:14 -0000 1.9
@@ -55,7 +55,7 @@
*/
/*
- * $Id: TraverseSchema.hpp,v 1.8 2002/05/21 19:32:37 tng Exp $
+ * $Id: TraverseSchema.hpp,v 1.9 2002/05/22 20:54:14 knoaman Exp $
*/
#if !defined(TRAVERSESCHEMA_HPP)
@@ -87,7 +87,7 @@
// Forward Declarations
// ---------------------------------------------------------------------------
class GrammarResolver;
-class EntityResolver;
+class XMLEntityHandler;
class XMLValidator;
class XMLScanner;
class DatatypeValidator;
@@ -98,13 +98,12 @@
class NamespaceScope;
class SchemaAttDef;
class InputSource;
-class ErrorHandler;
class XercesGroupInfo;
class XercesAttGroupInfo;
class IdentityConstraint;
-class XercesDOMParser;
class XSDLocator;
class XSDDOMParser;
+class XMLErrorReporter;
class VALIDATORS_EXPORT TraverseSchema
@@ -122,8 +121,8 @@
, XMLScanner* const xmlScanner
, XMLValidator* const xmlValidator
, const XMLCh* const schemaURL
- , EntityResolver* const entityResolver
- , ErrorHandler* const errorHandler
+ , XMLEntityHandler* const entityHandler
+ , XMLErrorReporter* const errorReporter
);
~TraverseSchema();
@@ -241,7 +240,7 @@
const int errorCode);
void reportSchemaError(const XSDLocator* const aLocator,
const XMLCh* const msgDomain,
- const int errorCode,
+ const int errorCode,
const XMLCh* const text1,
const XMLCh* const text2 = 0,
const XMLCh* const text3 = 0,
@@ -251,7 +250,7 @@
const int errorCode);
void reportSchemaError(const DOMElement* const elem,
const XMLCh* const msgDomain,
- const int errorCode,
+ const int errorCode,
const XMLCh* const text1,
const XMLCh* const text2 = 0,
const XMLCh* const text3 = 0,
@@ -280,13 +279,13 @@
* Parameters:
* rootElem - top element for a given type declaration
* contentElem - content must be annotation? or some other simple content
- * isEmpty: - true if (annotation?, smth_else), false if (annotation?)
+ * isEmpty: - true if (annotation?, smth_else), false if (annotation?)
*
* Check for Annotation if it is present, traverse it. If a sibling is
* found and it is not an annotation return it, otherwise return 0.
* Used by traverseSimpleTypeDecl.
*/
- DOMElement* checkContent(const DOMElement* const rootElem,
+ DOMElement* checkContent(const DOMElement* const rootElem,
DOMElement* const contentElem,
const bool isEmpty);
@@ -571,7 +570,7 @@
* Attribute wild card intersection.
*
* Note:
- * The first parameter will be the result of the intersection, so
+ * The first parameter will be the result of the intersection, so
* we need to make sure that first parameter is a copy of the
* actual attribute definition we need to intersect with.
*
@@ -585,7 +584,7 @@
* Attribute wild card union.
*
* Note:
- * The first parameter will be the result of the union, so
+ * The first parameter will be the result of the union, so
* we need to make sure that first parameter is a copy of the
* actual attribute definition we need to intersect with.
*
@@ -654,12 +653,12 @@
SchemaInfo* const redefiningSchemaInfo);
/**
- * This function looks among the children of 'redefineChildElem' for a
+ * This function looks among the children of 'redefineChildElem' for a
* component of type 'redefineChildComponentName'. If it finds one, it
* evaluates whether its ref attribute contains a reference to
* 'refChildTypeName'. If it does, it returns 1 + the value returned by
* calls to itself on all other children. In all other cases it returns
- * 0 plus the sum of the values returned by calls to itself on
+ * 0 plus the sum of the values returned by calls to itself on
* redefineChildElem's children. It also resets the value of ref so that
* it will refer to the renamed type from the schema being redefined.
*/
@@ -740,8 +739,8 @@
DatatypeValidatorFactory* fDatatypeRegistry;
GrammarResolver* fGrammarResolver;
SchemaGrammar* fSchemaGrammar;
- EntityResolver* fEntityResolver;
- ErrorHandler* fErrorHandler;
+ XMLEntityHandler* fEntityHandler;
+ XMLErrorReporter* fErrorReporter;
XMLStringPool* fURIStringPool;
XMLStringPool* fStringPool;
XMLBuffer fBuffer;
@@ -773,7 +772,7 @@
RefHashTableOf<ValueVectorOf<unsigned int> >* fIC_NamespaceDepthNS;
XSDDOMParser* fParser;
RefHashTableOf<SchemaInfo>* fPreprocessedNodes;
- XSDErrorReporter fErrorReporter;
+ XSDErrorReporter fXSDErrorReporter;
XSDLocator* fLocator;
friend class GeneralAttributeCheck;
@@ -824,7 +823,7 @@
|| XMLString::stringLen(elem->getAttribute(SchemaSymbols::fgATT_BLOCK)) != 0
|| XMLString::stringLen(elem->getAttribute(SchemaSymbols::fgATT_FINAL)) != 0
|| XMLString::stringLen(elem->getAttribute(SchemaSymbols::fgATT_TYPE)) != 0
- || XMLString::stringLen(elem->getAttribute(SchemaSymbols::fgATT_DEFAULT)) != 0
+ || XMLString::stringLen(elem->getAttribute(SchemaSymbols::fgATT_DEFAULT)) != 0
|| XMLString::stringLen(elem->getAttribute(SchemaSymbols::fgATT_FIXED)) != 0
|| XMLString::stringLen(elem->getAttribute(SchemaSymbols::fgATT_SUBSTITUTIONGROUP)) != 0);
}
@@ -858,7 +857,7 @@
return attValue;
}
-inline const XMLCh*
+inline const XMLCh*
TraverseSchema::getTargetNamespaceString(const DOMElement* const elem) {
const XMLCh* targetNS = getElementAttValue(elem, SchemaSymbols::fgATT_TARGETNAMESPACE);
@@ -875,7 +874,7 @@
if (XMLString::compareString(baseURI,fTargetNSURIString) != 0
&& XMLString::compareString(baseURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) != 0
&& XMLString::stringLen(baseURI) != 0) {
- //REVISIT, !!!! a hack: for schema that has no
+ //REVISIT, !!!! a hack: for schema that has no
//target namespace, e.g. personal-schema.xml
return true;
}
@@ -918,7 +917,7 @@
return value;
}
-inline void
+inline void
TraverseSchema::copyWildCardData(const SchemaAttDef* const srcWildCard,
SchemaAttDef* const destWildCard) {
1.3 +50 -3 xml-xerces/c/src/xercesc/validators/schema/XSDDOMParser.cpp
Index: XSDDOMParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/XSDDOMParser.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSDDOMParser.cpp 21 May 2002 19:34:24 -0000 1.2
+++ XSDDOMParser.cpp 22 May 2002 20:54:14 -0000 1.3
@@ -55,7 +55,7 @@
*/
/**
- * $Id: XSDDOMParser.cpp,v 1.2 2002/05/21 19:34:24 tng Exp $
+ * $Id: XSDDOMParser.cpp,v 1.3 2002/05/22 20:54:14 knoaman Exp $
*/
@@ -73,6 +73,8 @@
// ---------------------------------------------------------------------------
XSDDOMParser::XSDDOMParser(XMLValidator* const valToAdopt) :
XercesDOMParser(valToAdopt)
+ , fSawFatal(false)
+ , fUserErrorReporter(0)
{
}
@@ -87,11 +89,56 @@
// XSDDOMParser: Helper methods
// ---------------------------------------------------------------------------
DOMElement* XSDDOMParser::createElementNSNode(const XMLCh *namespaceURI,
- const XMLCh *qualifiedName)
+ const XMLCh *qualifiedName)
{
ReaderMgr::LastExtEntityInfo lastInfo;
- ((ReaderMgr*) fScanner->getLocator())->getLastExtEntityInfo(lastInfo);
+ ((ReaderMgr*) getScanner()->getLocator())->getLastExtEntityInfo(lastInfo);
return getDocument()->createElementNS(namespaceURI, qualifiedName,
lastInfo.lineNumber, lastInfo.colNumber);
}
+
+
+// ---------------------------------------------------------------------------
+// XSDDOMParser: Setter methods
+// ---------------------------------------------------------------------------
+inline void XSDDOMParser::setUserErrorReporter(XMLErrorReporter* const errorReporter)
+{
+ fUserErrorReporter = errorReporter;
+ getScanner()->setErrorReporter(this);
+}
+
+inline void XSDDOMParser::setUserEntityHandler(XMLEntityHandler* const entityHandler)
+{
+ fUserEntityHandler = entityHandler;
+ getScanner()->setEntityHandler(this);
+}
+
+// ---------------------------------------------------------------------------
+// XSDDOMParser: Implementation of the XMLErrorReporter interface
+// ---------------------------------------------------------------------------
+void XSDDOMParser::error(const unsigned int code
+ , const XMLCh* const msgDomain
+ , const XMLErrorReporter::ErrTypes errType
+ , const XMLCh* const errorText
+ , const XMLCh* const systemId
+ , const XMLCh* const publicId
+ , const unsigned int lineNum
+ , const unsigned int colNum)
+{
+ if (errType >= XMLErrorReporter::ErrType_Fatal)
+ fSawFatal = true;
+
+ if (fUserErrorReporter)
+ fUserErrorReporter->error(code, msgDomain, errType, errorText,
+ systemId, publicId, lineNum, colNum);
+}
+
+InputSource* XSDDOMParser::resolveEntity(const XMLCh* const publicId,
+ const XMLCh* const systemId)
+{
+ if (fUserEntityHandler)
+ return fUserEntityHandler->resolveEntity(publicId, systemId);
+
+ return 0;
+}
\ No newline at end of file
1.3 +52 -2 xml-xerces/c/src/xercesc/validators/schema/XSDDOMParser.hpp
Index: XSDDOMParser.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/XSDDOMParser.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSDDOMParser.hpp 21 May 2002 19:34:24 -0000 1.2
+++ XSDDOMParser.hpp 22 May 2002 20:54:14 -0000 1.3
@@ -55,7 +55,7 @@
*/
/*
- * $Id: XSDDOMParser.hpp,v 1.2 2002/05/21 19:34:24 tng Exp $
+ * $Id: XSDDOMParser.hpp,v 1.3 2002/05/22 20:54:14 knoaman Exp $
*
*/
@@ -101,12 +101,62 @@
//@}
+
+ // -----------------------------------------------------------------------
+ // Get methods
+ // -----------------------------------------------------------------------
+ bool getSawFatal() const;
+
+
+ // -----------------------------------------------------------------------
+ // Set methods
+ // -----------------------------------------------------------------------
+ void setUserErrorReporter(XMLErrorReporter* const errorReporter);
+ void setUserEntityHandler(XMLEntityHandler* const entityHandler);
+
+
+ // -----------------------------------------------------------------------
+ // XMLErrorReporter interface
+ // -----------------------------------------------------------------------
+ virtual void error
+ (
+ const unsigned int errCode
+ , const XMLCh* const errDomain
+ , const ErrTypes type
+ , const XMLCh* const errorText
+ , const XMLCh* const systemId
+ , const XMLCh* const publicId
+ , const unsigned int lineNum
+ , const unsigned int colNum
+ );
+
+ // -----------------------------------------------------------------------
+ // XMLEntityHandler interface
+ // -----------------------------------------------------------------------
+ virtual InputSource* resolveEntity
+ (
+ const XMLCh* const publicId
+ , const XMLCh* const systemId
+ );
+
protected :
// -----------------------------------------------------------------------
// Protected Helper methods
// -----------------------------------------------------------------------
virtual DOMElement* createElementNSNode(const XMLCh *fNamespaceURI,
- const XMLCh *qualifiedName);
+ const XMLCh *qualifiedName);
+
+private:
+ bool fSawFatal;
+ XMLErrorReporter* fUserErrorReporter;
+ XMLEntityHandler* fUserEntityHandler;
};
+
+
+inline bool XSDDOMParser::getSawFatal() const
+{
+ return fSawFatal;
+}
+
#endif
1.2 +18 -54 xml-xerces/c/src/xercesc/validators/schema/XSDErrorReporter.cpp
Index: XSDErrorReporter.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/XSDErrorReporter.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSDErrorReporter.cpp 21 Mar 2002 15:34:40 -0000 1.1
+++ XSDErrorReporter.cpp 22 May 2002 20:54:14 -0000 1.2
@@ -56,6 +56,13 @@
/**
* $Log: XSDErrorReporter.cpp,v $
+ * Revision 1.2 2002/05/22 20:54:14 knoaman
+ * Prepare for DOM L3 :
+ * - Make use of the XMLEntityHandler/XMLErrorReporter interfaces, instead of using
+ * EntityHandler/ErrorHandler directly.
+ * - Add 'AbstractDOMParser' class to provide common functionality for XercesDOMParser
+ * and DOMBuilder.
+ *
* Revision 1.1 2002/03/21 15:34:40 knoaman
* Add support for reporting line/column numbers of schema errors.
*
@@ -67,10 +74,10 @@
// ---------------------------------------------------------------------------
#include <xercesc/util/Mutexes.hpp>
#include <xercesc/util/PlatformUtils.hpp>
-#include <xercesc/sax/SAXParseException.hpp>
-#include <xercesc/sax/ErrorHandler.hpp>
+#include <xercesc/util/XMLString.hpp>
#include <xercesc/framework/XMLErrorCodes.hpp>
#include <xercesc/framework/XMLValidityCodes.hpp>
+#include <xercesc/framework/XMLErrorReporter.hpp>
#include <xercesc/util/XMLRegisterCleanup.hpp>
#include <xercesc/validators/schema/XSDErrorReporter.hpp>
#include <xercesc/validators/schema/XSDLocator.hpp>
@@ -137,9 +144,9 @@
// ---------------------------------------------------------------------------
// XSDErrorReporter: Constructors and Destructor
// ---------------------------------------------------------------------------
-XSDErrorReporter::XSDErrorReporter(ErrorHandler* const handler) :
+XSDErrorReporter::XSDErrorReporter(XMLErrorReporter* const errorReporter) :
fExitOnFirstFatal(false)
- , fErrorHandler(handler)
+ , fErrorReporter(errorReporter)
{
//
@@ -171,47 +178,6 @@
// ---------------------------------------------------------------------------
-// XSDErrorReporter: Error Handler
-// ---------------------------------------------------------------------------
-void XSDErrorReporter::error(const unsigned int errCode,
- const XMLCh* const errDomain,
- const ErrTypes errType,
- const XMLCh* const errorText,
- const XMLCh* const systemId,
- const XMLCh* const publicId,
- const unsigned int lineNum,
- const unsigned int colNum)
-{
- SAXParseException toThrow = SAXParseException
- (
- errorText
- , publicId
- , systemId
- , lineNum
- , colNum
- );
-
- //
- // If there is an error handler registered, call it, otherwise ignore
- // all but the fatal errors.
- //
- if (!fErrorHandler)
- {
- if (errType == XMLErrorReporter::ErrType_Fatal)
- throw toThrow;
- return;
- }
-
- if (errType == XMLErrorReporter::ErrType_Warning)
- fErrorHandler->warning(toThrow);
- else if (errType >= XMLErrorReporter::ErrType_Fatal)
- fErrorHandler->fatalError(toThrow);
- else
- fErrorHandler->error(toThrow);
-}
-
-
-// ---------------------------------------------------------------------------
// XSDErrorReporter: Error reporting
// ---------------------------------------------------------------------------
void XSDErrorReporter::emitError(const unsigned int toEmit,
@@ -229,7 +195,7 @@
const unsigned int msgSize = 1023;
XMLCh errText[msgSize + 1];
XMLMsgLoader* msgLoader = gErrMsgLoader;
- ErrTypes errType = XMLErrs::errorType((XMLErrs::Codes) toEmit);
+ XMLErrorReporter::ErrTypes errType = XMLErrs::errorType((XMLErrs::Codes) toEmit);
if (!XMLString::compareString(msgDomain, XMLUni::fgValidityDomain)) {
@@ -247,9 +213,10 @@
}
}
- error(toEmit, msgDomain, errType, errText, aLocator->getSystemId(),
- aLocator->getPublicId(), aLocator->getLineNumber(),
- aLocator->getColumnNumber());
+ if (fErrorReporter)
+ fErrorReporter->error(toEmit, msgDomain, errType, errText, aLocator->getSystemId(),
+ aLocator->getPublicId(), aLocator->getLineNumber(),
+ aLocator->getColumnNumber());
// Bail out if its fatal an we are to give up on the first fatal error
if (errType == XMLErrorReporter::ErrType_Fatal && fExitOnFirstFatal)
@@ -275,7 +242,7 @@
const unsigned int maxChars = 2047;
XMLCh errText[maxChars + 1];
XMLMsgLoader* msgLoader = gErrMsgLoader;
- ErrTypes errType = XMLErrs::errorType((XMLErrs::Codes) toEmit);
+ XMLErrorReporter::ErrTypes errType = XMLErrs::errorType((XMLErrs::Codes) toEmit);
if (!XMLString::compareString(msgDomain, XMLUni::fgValidityDomain)) {
@@ -293,9 +260,10 @@
}
}
- error(toEmit, msgDomain, errType, errText, aLocator->getSystemId(),
- aLocator->getPublicId(), aLocator->getLineNumber(),
- aLocator->getColumnNumber());
+ if (fErrorReporter)
+ fErrorReporter->error(toEmit, msgDomain, errType, errText, aLocator->getSystemId(),
+ aLocator->getPublicId(), aLocator->getLineNumber(),
+ aLocator->getColumnNumber());
// Bail out if its fatal an we are to give up on the first fatal error
if (errType == XMLErrorReporter::ErrType_Fatal && fExitOnFirstFatal)
1.2 +9 -35 xml-xerces/c/src/xercesc/validators/schema/XSDErrorReporter.hpp
Index: XSDErrorReporter.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/XSDErrorReporter.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSDErrorReporter.hpp 21 Mar 2002 15:34:40 -0000 1.1
+++ XSDErrorReporter.hpp 22 May 2002 20:54:14 -0000 1.2
@@ -55,30 +55,28 @@
*/
/*
- * $Id: XSDErrorReporter.hpp,v 1.1 2002/03/21 15:34:40 knoaman Exp $
+ * $Id: XSDErrorReporter.hpp,v 1.2 2002/05/22 20:54:14 knoaman Exp $
*/
#if !defined(XSDERRORREPORTER_HPP)
#define XSDERRORREPORTER_HPP
-#include <xercesc/framework/XMLErrorReporter.hpp>
-
class Locator;
-class ErrorHandler;
+class XMLErrorReporter;
/**
* This class reports schema errors
*/
-class VALIDATORS_EXPORT XSDErrorReporter: public XMLErrorReporter
+class VALIDATORS_EXPORT XSDErrorReporter
{
public:
// -----------------------------------------------------------------------
// Constructors are hidden, only the virtual destructor is exposed
// -----------------------------------------------------------------------
- XSDErrorReporter(ErrorHandler* const handler = 0);
+ XSDErrorReporter(XMLErrorReporter* const errorReporter = 0);
virtual ~XSDErrorReporter()
{
@@ -92,27 +90,10 @@
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
- void setErrorHandler(ErrorHandler* const handler);
+ void setErrorReporter(XMLErrorReporter* const errorReporter);
void setExitOnFirstFatal(const bool newValue);
// -----------------------------------------------------------------------
- // The error handler interface
- // -----------------------------------------------------------------------
- virtual void error
- (
- const unsigned int errCode
- , const XMLCh* const errDomain
- , const ErrTypes type
- , const XMLCh* const errorText
- , const XMLCh* const systemId
- , const XMLCh* const publicId
- , const unsigned int lineNum
- , const unsigned int colNum
- );
-
- virtual void resetErrors();
-
- // -----------------------------------------------------------------------
// Notification that lazy data has been deleted
// -----------------------------------------------------------------------
static void reinitErrMsgMutex();
@@ -142,8 +123,8 @@
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
- bool fExitOnFirstFatal;
- ErrorHandler* fErrorHandler;
+ bool fExitOnFirstFatal;
+ XMLErrorReporter* fErrorReporter;
};
@@ -163,16 +144,9 @@
fExitOnFirstFatal = newValue;
}
-inline void XSDErrorReporter::setErrorHandler(ErrorHandler* const handler)
-{
- fErrorHandler = handler;
-}
-
-// ---------------------------------------------------------------------------
-// XSDErrorReporter: Error Handler
-// ---------------------------------------------------------------------------
-inline void XSDErrorReporter::resetErrors()
+inline void XSDErrorReporter::setErrorReporter(XMLErrorReporter* const errorReporter)
{
+ fErrorReporter = errorReporter;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org