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 2001/06/05 15:59:58 UTC
cvs commit: xml-xerces/c/src/validators/schema ComplexTypeInfo.cpp TraverseSchema.cpp TraverseSchema.hpp
knoaman 01/06/05 06:59:57
Modified: c/src/validators/schema ComplexTypeInfo.cpp
TraverseSchema.cpp TraverseSchema.hpp
Log:
Fixes to include and import.
Revision Changes Path
1.6 +5 -2 xml-xerces/c/src/validators/schema/ComplexTypeInfo.cpp
Index: ComplexTypeInfo.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/ComplexTypeInfo.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ComplexTypeInfo.cpp 2001/05/11 13:27:32 1.5
+++ ComplexTypeInfo.cpp 2001/06/05 13:59:53 1.6
@@ -56,6 +56,9 @@
/*
* $Log: ComplexTypeInfo.cpp,v $
+ * Revision 1.6 2001/06/05 13:59:53 knoaman
+ * Fixes to include and import.
+ *
* Revision 1.5 2001/05/11 13:27:32 tng
* Copyright update.
*
@@ -107,7 +110,7 @@
{
delete [] fTypeName;
- if (fAdoptContentSpec) {
+ if (fAdoptContentSpec) {
delete fContentSpec;
}
@@ -133,7 +136,7 @@
void ComplexTypeInfo::setContentSpec(ContentSpecNode* const toAdopt) {
- if (fContentSpec) {
+ if (fContentSpec && fAdoptContentSpec) {
delete fContentSpec;
}
1.16 +59 -40 xml-xerces/c/src/validators/schema/TraverseSchema.cpp
Index: TraverseSchema.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/TraverseSchema.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- TraverseSchema.cpp 2001/05/30 21:13:50 1.15
+++ TraverseSchema.cpp 2001/06/05 13:59:54 1.16
@@ -56,6 +56,9 @@
/*
* $Log: TraverseSchema.cpp,v $
+ * Revision 1.16 2001/06/05 13:59:54 knoaman
+ * Fixes to include and import.
+ *
* Revision 1.15 2001/05/30 21:13:50 knoaman
* Typo fix
*
@@ -196,17 +199,19 @@
// ---------------------------------------------------------------------------
// TraverseSchema: Constructors and Destructor
// ---------------------------------------------------------------------------
-TraverseSchema::TraverseSchema( const DOM_Element& schemaRoot
- , XMLStringPool* const uriStringPool
- , SchemaGrammar* const schemaGrammar
- , GrammarResolver* const grammarResolver
- , XMLScanner* const xmlScanner
- , XMLValidator* const xmlValidator
- , const XMLCh* const schemaURL
- , EntityResolver* const entityResolver
- , ErrorHandler* const errorHandler)
+TraverseSchema::TraverseSchema( const DOM_Element& schemaRoot
+ , XMLStringPool* const uriStringPool
+ , SchemaGrammar* const schemaGrammar
+ , GrammarResolver* const grammarResolver
+ , XMLScanner* const xmlScanner
+ , XMLValidator* const xmlValidator
+ , const XMLCh* const schemaURL
+ , EntityResolver* const entityResolver
+ , ErrorHandler* const errorHandler
+ , ValueVectorOf<unsigned int>* const importLocations)
: fElementDefaultQualified(false)
, fAttributeDefaultQualified(false)
+ , fAdoptImportLocations(false)
, fTargetNSURI(-1)
, fCurrentScope(Grammar::TOP_LEVEL_SCOPE)
, fSimpleTypeAnonCount(0)
@@ -230,7 +235,7 @@
, fComplexTypeRegistry(0)
, fSchemaInfoRoot(0)
, fCurrentSchemaInfo(0)
- , fImportLocations(0)
+ , fImportLocations(importLocations)
, fIncludeLocations(0)
, fCurrentTypeNameStack(0)
, fAttributeCheck(0)
@@ -262,11 +267,21 @@
fDatatypeRegistry = fGrammarResolver->getDatatypeRegistry();
fDatatypeRegistry->expandRegistryToFullSchemaSet();
+ if (!fImportLocations) {
+ fAdoptImportLocations = true;
+ fImportLocations = new ValueVectorOf<unsigned int>(8);
+ }
+
+ unsigned int schemaURLId = fURIStringPool->addOrFind(fCurrentSchemaURL);
+ fImportLocations->addElement(schemaURLId);
+
if (fSchemaRootElement.isNull()) {
// REVISIT: Anything to do?
return;
}
+ fIncludeLocations = new ValueVectorOf<unsigned int>(8);
+ fIncludeLocations->addElement(schemaURLId);
fAttributeCheck = GeneralAttributeCheck::instance();
fCurrentTypeNameStack = new ValueVectorOf<unsigned int>(8);
fGlobalTypes = new RefHash2KeysTableOf<XMLCh>(29, false);
@@ -433,10 +448,6 @@
const XMLCh* includeURL = srcToFill->getSystemId();
unsigned int locationId = fURIStringPool->addOrFind(includeURL);
- if (fIncludeLocations == 0) {
- fIncludeLocations = new ValueVectorOf<unsigned int>(8);
- }
-
if (locationsContain(fIncludeLocations, locationId)) {
return;
}
@@ -573,7 +584,7 @@
getElementAttValue(elem, SchemaSymbols::fgATT_SCHEMALOCATION);
if (XMLString::stringLen(schemaLocation) == 0) {
- reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ImportNoSchemaLocation);
+// reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ImportNoSchemaLocation);
return;
}
@@ -591,23 +602,13 @@
const XMLCh* importURL = srcToFill->getSystemId();
unsigned int locationId = fURIStringPool->addOrFind(importURL);
- if (fImportLocations == 0) {
- fImportLocations = new ValueVectorOf<unsigned int>(8);
- }
-
if (locationsContain(fImportLocations, locationId)) {
return;
}
- fImportLocations->addElement(locationId);
-
const XMLCh* nameSpace = getElementAttValue(elem, SchemaSymbols::fgATT_NAMESPACE);
SchemaGrammar* importedGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(nameSpace);
- if (importedGrammar == 0) {
- importedGrammar = new SchemaGrammar();
- }
-
// ------------------------------------------------------------------
// Parse input source
// ------------------------------------------------------------------
@@ -653,9 +654,15 @@
schemaLocation, targetNSURIString, nameSpace);
}
else {
+
+ if (importedGrammar == 0) {
+ importedGrammar = new SchemaGrammar();
+ }
+
TraverseSchema traverseSchema(root, fURIStringPool, importedGrammar,
fGrammarResolver, fScanner, fValidator,
- importURL, fEntityResolver, fErrorHandler);
+ importURL, fEntityResolver, fErrorHandler,
+ fImportLocations);
}
}
else {
@@ -2131,11 +2138,12 @@
SchemaSymbols::fgELT_PATTERN) == 0) {
if (isFirstPattern) { // fBuffer.isEmpty() - overhead call
+
+ isFirstPattern = false;
pattern.set(attValue.rawBuffer(), attValueLen);
}
else { //datatypes: 5.2.4 pattern
- isFirstPattern = false;
pattern.append(chPipe);
pattern.append(attValue.rawBuffer(), attValueLen);
}
@@ -2539,11 +2547,12 @@
SchemaSymbols::fgELT_PATTERN) == 0) {
if (isFirstPattern) { // fBuffer.isEmpty() - overhead call
+
+ isFirstPattern = false;
pattern.set(fBuffer.getRawBuffer());
}
else { //datatypes: 5.2.4 pattern
- isFirstPattern = false;
pattern.append(chPipe);
pattern.append(fBuffer.getRawBuffer());
}
@@ -2961,7 +2970,10 @@
traverseAnnotationDecl(child);
}
else if (name.equals(SchemaSymbols::fgELT_INCLUDE)) {
+
+ fNamespaceScope->increaseDepth();
traverseInclude(child);
+ fNamespaceScope->decreaseDepth();
}
else if (name.equals(SchemaSymbols::fgELT_IMPORT)) {
traverseImport(child);
@@ -4568,20 +4580,23 @@
// If they didn't create a source via the entity resolver, then we
// have to create one on our own.
- try {
+ if (!srcToFill) {
+
+ try {
- XMLURL urlTmp(fCurrentSchemaURL, loc);
+ XMLURL urlTmp(fCurrentSchemaURL, loc);
- if (urlTmp.isRelative()) {
- ThrowXML(MalformedURLException,
- XMLExcepts::URL_NoProtocolPresent);
- }
+ if (urlTmp.isRelative()) {
+ ThrowXML(MalformedURLException,
+ XMLExcepts::URL_NoProtocolPresent);
+ }
- srcToFill = new URLInputSource(urlTmp);
- }
- catch(const MalformedURLException&) {
- // Its not a URL, so lets assume its a local file name.
- srcToFill = new LocalFileInputSource(fCurrentSchemaURL,loc);
+ srcToFill = new URLInputSource(urlTmp);
+ }
+ catch(const MalformedURLException&) {
+ // Its not a URL, so lets assume its a local file name.
+ srcToFill = new LocalFileInputSource(fCurrentSchemaURL,loc);
+ }
}
return srcToFill;
@@ -4691,11 +4706,15 @@
delete [] fTargetNSURIString;
delete [] fCurrentSchemaURL;
delete fSchemaInfoRoot;
- delete fImportLocations;
delete fIncludeLocations;
delete fCurrentTypeNameStack;
delete fGlobalTypes;
+
+ if (fAdoptImportLocations) {
+ delete fImportLocations;
+ }
}
+
/**
* End of file TraverseSchema.cpp
*/
1.10 +31 -29 xml-xerces/c/src/validators/schema/TraverseSchema.hpp
Index: TraverseSchema.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/TraverseSchema.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TraverseSchema.hpp 2001/05/22 19:22:47 1.9
+++ TraverseSchema.hpp 2001/06/05 13:59:55 1.10
@@ -55,7 +55,7 @@
*/
/*
- * $Id: TraverseSchema.hpp,v 1.9 2001/05/22 19:22:47 knoaman Exp $
+ * $Id: TraverseSchema.hpp,v 1.10 2001/06/05 13:59:55 knoaman Exp $
*/
#if !defined(TRAVERSESCHEMA_HPP)
@@ -103,23 +103,24 @@
class VALIDATORS_EXPORT TraverseSchema
{
public:
- // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
// Public Constructors/Destructor
// -----------------------------------------------------------------------
TraverseSchema
(
- const DOM_Element& schemaRoot
- , XMLStringPool* const stringPool
- , SchemaGrammar* const schemaGrammar
- , GrammarResolver* const grammarResolver
- , XMLScanner* const xmlScanner
- , XMLValidator* const xmlValidator
- , const XMLCh* const schemaURL
- , EntityResolver* const entityResolver
- , ErrorHandler* const errorHandler
+ const DOM_Element& schemaRoot
+ , XMLStringPool* const stringPool
+ , SchemaGrammar* const schemaGrammar
+ , GrammarResolver* const grammarResolver
+ , XMLScanner* const xmlScanner
+ , XMLValidator* const xmlValidator
+ , const XMLCh* const schemaURL
+ , EntityResolver* const entityResolver
+ , ErrorHandler* const errorHandler
+ , ValueVectorOf<unsigned int>* const importLocations = 0
);
- ~TraverseSchema();
+ ~TraverseSchema();
// -----------------------------------------------------------------------
// Setter methods
@@ -136,13 +137,13 @@
// -----------------------------------------------------------------------
// CleanUp methods
// -----------------------------------------------------------------------
- void cleanUp();
+ void cleanUp();
// -----------------------------------------------------------------------
// Traversal methods
// -----------------------------------------------------------------------
/**
- * Traverse the Schema DOM tree
+ * Traverse the Schema DOM tree
*/
void doTraverseSchema();
void traverseSchemaHeader();
@@ -174,7 +175,7 @@
const int typeNameIndex,
const int finalSet);
QName* traverseElementDecl(const DOM_Element& childElem);
- XMLCh* traverseNotationDecl(const DOM_Element& childElem);
+ XMLCh* traverseNotationDecl(const DOM_Element& childElem);
ContentSpecNode* traverseChoiceSequence(const DOM_Element& elemDecl,
const int modelGroupType);
ContentSpecNode* traverseAny(const DOM_Element& anyDecl);
@@ -205,7 +206,7 @@
* Extract all top-level attribute, attributeGroup, and group Decls and
* put them in the 3 hash tables in the SchemaGrammar.
*/
- void extractTopLevel3Components(const DOM_Element& rootElem);
+ void extractTopLevel3Components(const DOM_Element& rootElem);
/**
* Loop through the children, and traverse the corresponding schema type
@@ -213,7 +214,7 @@
*/
void processChildren(const DOM_Element& root);
- /**
+ /**
* Parameters:
* rootElem - top element for a given type declaration
* contentElem - content must be annotation? or some other simple content
@@ -222,18 +223,18 @@
* 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.
- */
- DOM_Element checkContent(const DOM_Element& rootElem,
+ */
+ DOM_Element checkContent(const DOM_Element& rootElem,
const DOM_Element& contentElem,
const bool isEmpty);
- /**
+ /**
* Parameters:
* contentElem - content element to check
*
* Check for identity constraints content.
- */
- DOM_Element checkIdentityConstraintContent(const DOM_Element& contentElem);
+ */
+ DOM_Element checkIdentityConstraintContent(const DOM_Element& contentElem);
DatatypeValidator* getDatatypeValidator(const XMLCh* const uriStr,
const XMLCh* const localPartStr);
@@ -266,7 +267,7 @@
const XMLCh* const baseTypeStr,
const int baseRefContext);
- /**
+ /**
* Return a compenent defined as a top level in a schema grammar
*
* In redefine we've not only got to look at the space of the thing we
@@ -333,7 +334,7 @@
*/
bool isValidRefDeclaration(const DOM_Element& elem);
- /**
+ /**
* If 'typeStr' belongs to a different schema, return that schema URI,
* otherwise return 0;
*/
@@ -374,7 +375,7 @@
* Check validity constraint of a substitutionGroup attribute in
* an element declaration
*/
- bool isSubstitutionGroupValid(const SchemaElementDecl* const elemDecl,
+ bool isSubstitutionGroupValid(const SchemaElementDecl* const elemDecl,
const ComplexTypeInfo* const typeInfo,
const DatatypeValidator* const validator,
const XMLCh* const elemName);
@@ -489,6 +490,7 @@
// -----------------------------------------------------------------------
bool fElementDefaultQualified;
bool fAttributeDefaultQualified;
+ bool fAdoptImportLocations;
int fTargetNSURI;
int fCurrentScope;
int fSimpleTypeAnonCount;
@@ -510,7 +512,7 @@
XMLScanner* fScanner;
NamespaceScope* fNamespaceScope;
RefHashTableOf<XMLAttDef>* fAttributeDeclRegistry;
- RefHashTableOf<ComplexTypeInfo>* fComplexTypeRegistry;
+ RefHashTableOf<ComplexTypeInfo>* fComplexTypeRegistry;
SchemaInfo* fSchemaInfoRoot;
SchemaInfo* fCurrentSchemaInfo;
ValueVectorOf<unsigned int>* fImportLocations;
@@ -593,7 +595,7 @@
const XMLCh* TraverseSchema::getElementAttValue(const DOM_Element& elem,
const XMLCh* const attName) {
- DOMString attValue = elem.getAttribute(attName);
+ DOMString attValue = elem.getAttribute(attName);
if (attValue.length() > 0) {
@@ -616,7 +618,7 @@
return true;
}
- return false;
+ return false;
}
inline bool TraverseSchema::isAttrOrAttrGroup(const DOM_Element& elem) {
@@ -639,7 +641,7 @@
XMLString::binToText(anonCount++, anonCountStr, 15, 10);
fBuffer.set(prefix);
- fBuffer.append(anonCountStr);
+ fBuffer.append(anonCountStr);
int anonTypeId = fStringPool.addOrFind(fBuffer.getRawBuffer());
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org