cargilld 2004/09/27 19:14:14 Modified: c/src/xercesc/framework MemBufInputSource.cpp MemBufInputSource.hpp c/src/xercesc/framework/psvi XSAnnotation.cpp c/src/xercesc/internal XMLScanner.cpp XMLScanner.hpp c/src/xercesc/parsers AbstractDOMParser.cpp AbstractDOMParser.hpp DOMBuilderImpl.cpp SAX2XMLReaderImpl.cpp SAXParser.cpp SAXParser.hpp c/src/xercesc/util XMLUni.cpp XMLUni.hpp c/src/xercesc/validators/schema SchemaGrammar.hpp TraverseSchema.cpp TraverseSchema.hpp Log: Add support for validating annotations. Revision Changes Path 1.7 +9 -0 xml-xerces/c/src/xercesc/framework/MemBufInputSource.cpp Index: MemBufInputSource.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/MemBufInputSource.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- MemBufInputSource.cpp 8 Sep 2004 13:55:57 -0000 1.6 +++ MemBufInputSource.cpp 28 Sep 2004 02:14:13 -0000 1.7 @@ -16,6 +16,9 @@ /** * $Log$ + * Revision 1.7 2004/09/28 02:14:13 cargilld + * Add support for validating annotations. + * * Revision 1.6 2004/09/08 13:55:57 peiyongz * Apache License Version 2.0 * @@ -93,6 +96,12 @@ delete [] (XMLByte*)fSrcBytes; } +void MemBufInputSource::resetMemBufInputSource(const XMLByte* const srcDocBytes + , const unsigned int byteCount) +{ + fByteCount = byteCount; + fSrcBytes = srcDocBytes; +} // --------------------------------------------------------------------------- // MemBufInputSource: InputSource interface implementation 1.9 +14 -0 xml-xerces/c/src/xercesc/framework/MemBufInputSource.hpp Index: MemBufInputSource.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/MemBufInputSource.hpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- MemBufInputSource.hpp 8 Sep 2004 13:55:57 -0000 1.8 +++ MemBufInputSource.hpp 28 Sep 2004 02:14:13 -0000 1.9 @@ -16,6 +16,9 @@ /* * $Log$ + * Revision 1.9 2004/09/28 02:14:13 cargilld + * Add support for validating annotations. + * * Revision 1.8 2004/09/08 13:55:57 peiyongz * Apache License Version 2.0 * @@ -217,6 +220,17 @@ */ void setCopyBufToStream(const bool newState); + /** + * This methods allows the MemBufInputSource to be used for more than + * one input source, instead of destructing/constructing another + * MemBufInputSource. + * + * @param srcDocBytes The actual data buffer to be parsed from. + * @param byteCount The count of bytes (not characters, bytes!) + * in the buffer. + */ + void resetMemBufInputSource(const XMLByte* const srcDocBytes + , const unsigned int byteCount); //@} 1.11 +5 -0 xml-xerces/c/src/xercesc/framework/psvi/XSAnnotation.cpp Index: XSAnnotation.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSAnnotation.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- XSAnnotation.cpp 8 Sep 2004 13:56:07 -0000 1.10 +++ XSAnnotation.cpp 28 Sep 2004 02:14:13 -0000 1.11 @@ -16,6 +16,9 @@ /* * $Log$ + * Revision 1.11 2004/09/28 02:14:13 cargilld + * Add support for validating annotations. + * * Revision 1.10 2004/09/08 13:56:07 peiyongz * Apache License Version 2.0 * @@ -114,6 +117,7 @@ , fMemoryManager ); memBufIS->setEncoding(XMLUni::fgXMLChEncodingString); + memBufIS->setCopyBufToStream(false); try { @@ -148,6 +152,7 @@ , fMemoryManager ); memBufIS->setEncoding(XMLUni::fgXMLChEncodingString); + memBufIS->setCopyBufToStream(false); try { 1.70 +3 -1 xml-xerces/c/src/xercesc/internal/XMLScanner.cpp Index: XMLScanner.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.cpp,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- XMLScanner.cpp 23 Sep 2004 01:09:55 -0000 1.69 +++ XMLScanner.cpp 28 Sep 2004 02:14:13 -0000 1.70 @@ -141,6 +141,7 @@ , fLoadExternalDTD(true) , fNormalizeData(true) , fGenerateSyntheticAnnotations(false) + , fValidateAnnotations(false) , fErrorCount(0) , fEntityExpansionLimit(0) , fEntityExpansionCount(0) @@ -220,6 +221,7 @@ , fLoadExternalDTD(true) , fNormalizeData(true) , fGenerateSyntheticAnnotations(false) + , fValidateAnnotations(false) , fErrorCount(0) , fEntityExpansionLimit(0) , fEntityExpansionCount(0) 1.39 +16 -0 xml-xerces/c/src/xercesc/internal/XMLScanner.hpp Index: XMLScanner.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.hpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- XMLScanner.hpp 23 Sep 2004 01:09:55 -0000 1.38 +++ XMLScanner.hpp 28 Sep 2004 02:14:13 -0000 1.39 @@ -16,6 +16,9 @@ /* * $Log$ + * Revision 1.39 2004/09/28 02:14:13 cargilld + * Add support for validating annotations. + * * Revision 1.38 2004/09/23 01:09:55 cargilld * Add support for generating synthetic XSAnnotations. When a schema component has non-schema attributes and no child attributes create a synthetic XSAnnotation (under feature control) so the non-schema attributes can be recovered under PSVI. * @@ -517,6 +520,7 @@ const XMLCh* getPrefixForId(unsigned int prefId) const; bool getGenerateSyntheticAnnotations() const; + bool getValidateAnnotations() const; // ----------------------------------------------------------------------- // Getter methods @@ -612,6 +616,7 @@ void setStandardUriConformant(const bool newValue); void setGenerateSyntheticAnnotations(const bool newValue); + void setValidateAnnotations(const bool newValue); // ----------------------------------------------------------------------- // Mutator methods @@ -965,6 +970,7 @@ bool fLoadExternalDTD; bool fNormalizeData; bool fGenerateSyntheticAnnotations; + bool fValidateAnnotations; int fErrorCount; unsigned int fEntityExpansionLimit; unsigned int fEntityExpansionCount; @@ -1315,6 +1321,11 @@ return fGenerateSyntheticAnnotations; } +inline bool XMLScanner::getValidateAnnotations() const +{ + return fValidateAnnotations; +} + // --------------------------------------------------------------------------- // XMLScanner: Setter methods // --------------------------------------------------------------------------- @@ -1471,6 +1482,11 @@ inline void XMLScanner::setGenerateSyntheticAnnotations(const bool newValue) { fGenerateSyntheticAnnotations = newValue; +} + +inline void XMLScanner::setValidateAnnotations(const bool newValue) +{ + fValidateAnnotations = newValue; } // --------------------------------------------------------------------------- 1.68 +11 -1 xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.cpp Index: AbstractDOMParser.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.cpp,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- AbstractDOMParser.cpp 23 Sep 2004 01:09:55 -0000 1.67 +++ AbstractDOMParser.cpp 28 Sep 2004 02:14:13 -0000 1.68 @@ -235,6 +235,11 @@ return fScanner->getGenerateSyntheticAnnotations(); } +bool AbstractDOMParser::getValidateAnnotations() const +{ + return fScanner->getValidateAnnotations(); +} + bool AbstractDOMParser::getExitOnFirstFatalError() const { return fScanner->getExitOnFirstFatal(); @@ -331,6 +336,11 @@ void AbstractDOMParser::setGenerateSyntheticAnnotations(const bool newState) { fScanner->setGenerateSyntheticAnnotations(newState); +} + +void AbstractDOMParser::setValidateAnnotations(const bool newState) +{ + fScanner->setValidateAnnotations(newState); } void AbstractDOMParser::setExitOnFirstFatalError(const bool newState) 1.35 +21 -3 xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.hpp Index: AbstractDOMParser.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.hpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- AbstractDOMParser.hpp 23 Sep 2004 01:09:55 -0000 1.34 +++ AbstractDOMParser.hpp 28 Sep 2004 02:14:14 -0000 1.35 @@ -408,7 +408,7 @@ */ bool getCreateSchemaInfo() const; - /** Get the 'generate synthetic validations' flag + /** Get the 'generate synthetic annotations' flag * * @return true, if the parser is currently configured to * generate synthetic annotations, false otherwise. @@ -421,6 +421,15 @@ */ bool getGenerateSyntheticAnnotations() const; + /** Get the 'validate annotations' flag + * + * @return true, if the parser is currently configured to + * validate annotations, false otherwise. + * + * @see #setValidateAnnotations + */ + bool getValidateAnnotations() const; + //@} @@ -430,7 +439,7 @@ /** @name Setter methods */ //@{ - /** set the 'generate synthetic validations' flag + /** set the 'generate synthetic annotations' flag * * @param newValue The value for specifying whether Synthetic Annotations * should be generated or not. @@ -442,6 +451,15 @@ * @see #getGenerateSyntheticAnnotations */ void setGenerateSyntheticAnnotations(const bool newValue); + + /** set the 'validlate annotations' flag + * + * @param newValue The value for specifying whether Annotations + * should be validated or not. + * + * @see #getValidateAnnotations + */ + void setValidateAnnotations(const bool newValue); /** Set the 'do namespaces' flag * 1.40 +9 -1 xml-xerces/c/src/xercesc/parsers/DOMBuilderImpl.cpp Index: DOMBuilderImpl.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/DOMBuilderImpl.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- DOMBuilderImpl.cpp 23 Sep 2004 01:09:55 -0000 1.39 +++ DOMBuilderImpl.cpp 28 Sep 2004 02:14:14 -0000 1.40 @@ -235,6 +235,10 @@ { getScanner()->setGenerateSyntheticAnnotations(state); } + else if (XMLString::compareIString(name, XMLUni::fgXercesValidateAnnotations) == 0) + { + getScanner()->setValidateAnnotations(state); + } else { throw DOMException(DOMException::NOT_FOUND_ERR, 0, getMemoryManager()); } @@ -328,6 +332,10 @@ else if (XMLString::compareIString(name, XMLUni::fgXercesGenerateSyntheticAnnotations) == 0) { return getScanner()->getGenerateSyntheticAnnotations(); + } + else if (XMLString::compareIString(name, XMLUni::fgXercesValidateAnnotations) == 0) + { + return getScanner()->getValidateAnnotations(); } else { throw DOMException(DOMException::NOT_FOUND_ERR, 0, getMemoryManager()); 1.37 +9 -0 xml-xerces/c/src/xercesc/parsers/SAX2XMLReaderImpl.cpp Index: SAX2XMLReaderImpl.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAX2XMLReaderImpl.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- SAX2XMLReaderImpl.cpp 23 Sep 2004 01:09:55 -0000 1.36 +++ SAX2XMLReaderImpl.cpp 28 Sep 2004 02:14:14 -0000 1.37 @@ -16,6 +16,9 @@ /* * $Log$ + * Revision 1.37 2004/09/28 02:14:14 cargilld + * Add support for validating annotations. + * * Revision 1.36 2004/09/23 01:09:55 cargilld * Add support for generating synthetic XSAnnotations. When a schema component has non-schema attributes and no child attributes create a synthetic XSAnnotation (under feature control) so the non-schema attributes can be recovered under PSVI. * @@ -1564,6 +1567,10 @@ { fScanner->setGenerateSyntheticAnnotations(value); } + else if (XMLString::compareIString(name, XMLUni::fgXercesValidateAnnotations) == 0) + { + fScanner->setValidateAnnotations(value); + } else throw SAXNotRecognizedException("Unknown Feature", fMemoryManager); } @@ -1600,6 +1607,8 @@ return fScanner->getStandardUriConformant(); else if (XMLString::compareIString(name, XMLUni::fgXercesGenerateSyntheticAnnotations) == 0) return fScanner->getGenerateSyntheticAnnotations(); + else if (XMLString::compareIString(name, XMLUni::fgXercesValidateAnnotations) == 0) + return fScanner->getValidateAnnotations(); else throw SAXNotRecognizedException("Unknown Feature", fMemoryManager); 1.35 +13 -0 xml-xerces/c/src/xercesc/parsers/SAXParser.cpp Index: SAXParser.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAXParser.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- SAXParser.cpp 23 Sep 2004 01:09:55 -0000 1.34 +++ SAXParser.cpp 28 Sep 2004 02:14:14 -0000 1.35 @@ -16,6 +16,9 @@ /* * $Log$ + * Revision 1.35 2004/09/28 02:14:14 cargilld + * Add support for validating annotations. + * * Revision 1.34 2004/09/23 01:09:55 cargilld * Add support for generating synthetic XSAnnotations. When a schema component has non-schema attributes and no child attributes create a synthetic XSAnnotation (under feature control) so the non-schema attributes can be recovered under PSVI. * @@ -454,6 +457,11 @@ return fScanner->getGenerateSyntheticAnnotations(); } +bool SAXParser::getValidateAnnotations() const +{ + return fScanner->getValidateAnnotations(); +} + bool SAXParser::getExitOnFirstFatalError() const { return fScanner->getExitOnFirstFatal(); @@ -568,6 +576,11 @@ void SAXParser::setGenerateSyntheticAnnotations(const bool newState) { fScanner->setGenerateSyntheticAnnotations(newState); +} + +void SAXParser::setValidateAnnotations(const bool newState) +{ + fScanner->setValidateAnnotations(newState); } void SAXParser::setExitOnFirstFatalError(const bool newState) 1.34 +23 -2 xml-xerces/c/src/xercesc/parsers/SAXParser.hpp Index: SAXParser.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAXParser.hpp,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- SAXParser.hpp 23 Sep 2004 01:09:55 -0000 1.33 +++ SAXParser.hpp 28 Sep 2004 02:14:14 -0000 1.34 @@ -16,6 +16,9 @@ /* * $Log$ + * Revision 1.34 2004/09/28 02:14:14 cargilld + * Add support for validating annotations. + * * Revision 1.33 2004/09/23 01:09:55 cargilld * Add support for generating synthetic XSAnnotations. When a schema component has non-schema attributes and no child attributes create a synthetic XSAnnotation (under feature control) so the non-schema attributes can be recovered under PSVI. * @@ -645,7 +648,7 @@ */ unsigned int getSrcOffset() const; - /** Get the 'generate synthetic validations' flag + /** Get the 'generate synthetic annotations' flag * * @return true, if the parser is currently configured to * generate synthetic annotations, false otherwise. @@ -658,6 +661,15 @@ */ bool getGenerateSyntheticAnnotations() const; + /** Get the 'validate annotations' flag + * + * @return true, if the parser is currently configured to + * validate annotations, false otherwise. + * + * @see #setValidateAnnotations + */ + bool getValidateAnnotations() const; + //@} @@ -667,7 +679,7 @@ /** @name Setter methods */ //@{ - /** set the 'generate synthetic validations' flag + /** set the 'generate synthetic annotations' flag * * @param newValue The value for specifying whether Synthetic Annotations * should be generated or not. @@ -678,6 +690,15 @@ * @see #getGenerateSyntheticAnnotations */ void setGenerateSyntheticAnnotations(const bool newValue); + + /** set the 'validate annotations' flag + * + * @param newValue The value for specifying whether annotations + * should be validate or not. + * + * @see #getValidateAnnotations + */ + void setValidateAnnotations(const bool newValue); /** * This method allows users to enable or disable the parser's 1.45 +22 -1 xml-xerces/c/src/xercesc/util/XMLUni.cpp Index: XMLUni.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- XMLUni.cpp 23 Sep 2004 01:09:56 -0000 1.44 +++ XMLUni.cpp 28 Sep 2004 02:14:14 -0000 1.45 @@ -683,6 +683,13 @@ , chLatin_c, chLatin_a, chLatin_n, chLatin_n, chLatin_e, chLatin_r, chNull }; +const XMLCh XMLUni::fgXSAXMLScanner[] = +{ + chLatin_X, chLatin_S, chLatin_A + , chLatin_X, chLatin_M, chLatin_L, chLatin_S + , chLatin_c, chLatin_a, chLatin_n, chLatin_n, chLatin_e, chLatin_r, chNull +}; + const XMLCh XMLUni::fgCDataStart[] = { chOpenAngle, chBang, chOpenSquare, chLatin_C, chLatin_D @@ -1106,6 +1113,20 @@ , chForwardSlash, chLatin_g, chLatin_e, chLatin_n, chLatin_e, chLatin_r , chLatin_a, chLatin_t, chLatin_e, chDash, chLatin_s, chLatin_y, chLatin_n , chLatin_t, chLatin_h, chLatin_e, chLatin_t, chLatin_i, chLatin_c, chDash + , chLatin_a, chLatin_n, chLatin_n, chLatin_o, chLatin_t, chLatin_a, chLatin_t + , chLatin_i, chLatin_o, chLatin_n, chLatin_s, chNull +}; + +const XMLCh XMLUni::fgXercesValidateAnnotations[] = +//Xerces: http://apache.org/xml/features/validate-annotations +{ + chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash + , chForwardSlash, chLatin_a, chLatin_p, chLatin_a, chLatin_c, chLatin_h + , chLatin_e, chPeriod, chLatin_o, chLatin_r, chLatin_g, chForwardSlash + , chLatin_x, chLatin_m, chLatin_l, chForwardSlash, chLatin_f, chLatin_e + , chLatin_a, chLatin_t, chLatin_u, chLatin_r, chLatin_e, chLatin_s + , chForwardSlash, chLatin_v, chLatin_a, chLatin_l, chLatin_i, chLatin_d + , chLatin_a, chLatin_t, chLatin_e, chDash , chLatin_a, chLatin_n, chLatin_n, chLatin_o, chLatin_t, chLatin_a, chLatin_t , chLatin_i, chLatin_o, chLatin_n, chLatin_s, chNull }; 1.40 +4 -1 xml-xerces/c/src/xercesc/util/XMLUni.hpp Index: XMLUni.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.hpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- XMLUni.hpp 23 Sep 2004 01:09:56 -0000 1.39 +++ XMLUni.hpp 28 Sep 2004 02:14:14 -0000 1.40 @@ -164,6 +164,7 @@ static const XMLCh fgIGXMLScanner[]; static const XMLCh fgSGXMLScanner[]; static const XMLCh fgDGXMLScanner[]; + static const XMLCh fgXSAXMLScanner[]; static const XMLCh fgCDataStart[]; static const XMLCh fgCDataEnd[]; @@ -221,6 +222,8 @@ static const XMLCh fgXercesStandardUriConformant[]; static const XMLCh fgXercesDOMHasPSVIInfo[]; static const XMLCh fgXercesGenerateSyntheticAnnotations[]; + static const XMLCh fgXercesValidateAnnotations[]; + // SAX2 features/properties names static const XMLCh fgSAX2CoreValidation[]; 1.17 +18 -0 xml-xerces/c/src/xercesc/validators/schema/SchemaGrammar.hpp Index: SchemaGrammar.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaGrammar.hpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- SchemaGrammar.hpp 8 Sep 2004 13:56:56 -0000 1.16 +++ SchemaGrammar.hpp 28 Sep 2004 02:14:14 -0000 1.17 @@ -16,6 +16,9 @@ /* * $Log$ + * Revision 1.17 2004/09/28 02:14:14 cargilld + * Add support for validating annotations. + * * Revision 1.16 2004/09/08 13:56:56 peiyongz * Apache License Version 2.0 * @@ -325,6 +328,12 @@ XSAnnotation* getAnnotation(); const XSAnnotation* getAnnotation() const; + /** + * Get annotation hash table, to enumerate through them + */ + RefHashTableOf<XSAnnotation>* getAnnotations(); + const RefHashTableOf<XSAnnotation>* getAnnotations() const; + /*** * Support for Serialization/De-serialization ***/ @@ -508,6 +517,15 @@ return fAnnotations->get(this); } +inline RefHashTableOf<XSAnnotation>* SchemaGrammar::getAnnotations() +{ + return fAnnotations; +} + +inline const RefHashTableOf<XSAnnotation>* SchemaGrammar::getAnnotations() const +{ + return fAnnotations; +} // ----------------------------------------------------------------------- // Setter methods // ----------------------------------------------------------------------- 1.118 +140 -19 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.117 retrieving revision 1.118 diff -u -r1.117 -r1.118 --- TraverseSchema.cpp 23 Sep 2004 11:25:17 -0000 1.117 +++ TraverseSchema.cpp 28 Sep 2004 02:14:14 -0000 1.118 @@ -56,6 +56,8 @@ #include <xercesc/util/XMLEntityResolver.hpp> #include <xercesc/util/XMLUri.hpp> #include <xercesc/framework/psvi/XSAnnotation.hpp> +#include <xercesc/framework/MemBufInputSource.hpp> +#include <xercesc/internal/XSAXMLScanner.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -141,19 +143,6 @@ SchemaSymbols::fgELT_KEYREF }; -const XMLCh fgAnnotation[] = -{ - chLatin_a, chLatin_n, chLatin_n, chLatin_o, chLatin_t, chLatin_a, chLatin_t - , chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh fgDocumentation[] = -{ - chLatin_d, chLatin_o, chLatin_c, chLatin_u, chLatin_m, chLatin_e - , chLatin_n, chLatin_t, chLatin_a, chLatin_t - , chLatin_i, chLatin_o, chLatin_n, chNull -}; - const XMLCh fgSynthetic_Annotation[] = { chLatin_S, chLatin_y, chLatin_n, chLatin_t, chLatin_h, chLatin_e, chLatin_t @@ -293,6 +282,10 @@ } } + if (fScanner->getValidateAnnotations() && !fSchemaGrammar->getAnnotations()->isEmpty()) + { + validateAnnotations(); + } fSchemaInfo->setProcessed(); } @@ -4655,7 +4648,7 @@ } // for each child node - if (fSchemaInfo->getNonXSAttList()->size() && !sawAnnotation) + if (fScanner->getGenerateSyntheticAnnotations() && fSchemaInfo->getNonXSAttList()->size() && !sawAnnotation) { // synthesize a global annotation here. fSchemaGrammar->addAnnotation( @@ -8743,7 +8736,7 @@ fBuffer.append(prefix); fBuffer.append(chColon); } - fBuffer.append(fgAnnotation); + fBuffer.append(SchemaSymbols::fgELT_ANNOTATION); // next is the nonXSAttList names & values unsigned int nonXSAttSize = nonXSAttList->size(); @@ -8841,7 +8834,7 @@ fBuffer.append(prefix); fBuffer.append(chColon); } - fBuffer.append(fgDocumentation); + fBuffer.append(SchemaSymbols::fgELT_DOCUMENTATION); fBuffer.append(chCloseAngle); fBuffer.append(fgSynthetic_Annotation); fBuffer.append(chOpenAngle); @@ -8851,7 +8844,7 @@ fBuffer.append(prefix); fBuffer.append(chColon); } - fBuffer.append(fgDocumentation); + fBuffer.append(SchemaSymbols::fgELT_DOCUMENTATION); fBuffer.append(chCloseAngle); fBuffer.append(chLF); fBuffer.append(chOpenAngle); @@ -8861,7 +8854,7 @@ fBuffer.append(prefix); fBuffer.append(chColon); } - fBuffer.append(fgAnnotation); + fBuffer.append(SchemaSymbols::fgELT_ANNOTATION); fBuffer.append(chCloseAngle); XSAnnotation* annot = new (fGrammarPoolMemoryManager) XSAnnotation(fBuffer.getRawBuffer(), fGrammarPoolMemoryManager); @@ -8869,6 +8862,134 @@ , ((XSDElementNSImpl*)elem)->getColumnNo() ); annot->setSystemId(fSchemaInfo->getCurrentSchemaURL()); return annot; +} + +void TraverseSchema::validateAnnotations() { + + MemoryManager *memMgr = fMemoryManager; + RefHashTableOfEnumerator<XSAnnotation> xsAnnotationEnum = RefHashTableOfEnumerator<XSAnnotation> (fSchemaGrammar->getAnnotations(), false, memMgr); + XSAnnotation& xsAnnot = xsAnnotationEnum.nextElement(); + + // create schema grammar + SchemaGrammar *grammar = new (memMgr) SchemaGrammar(memMgr); + NamespaceScope *nsScope; + grammar->setComplexTypeRegistry(new (memMgr) RefHashTableOf<ComplexTypeInfo>(29, memMgr)); + grammar->setGroupInfoRegistry(new (memMgr) RefHashTableOf<XercesGroupInfo>(13, memMgr)); + grammar->setAttGroupInfoRegistry(new (memMgr) RefHashTableOf<XercesAttGroupInfo>(13, memMgr)); + grammar->setAttributeDeclRegistry(new (memMgr) RefHashTableOf<XMLAttDef>(29, memMgr)); + nsScope = new (memMgr) NamespaceScope(memMgr); + nsScope->reset(fEmptyNamespaceURI); + grammar->setNamespaceScope(nsScope); + grammar->setValidSubstitutionGroups(new (memMgr) RefHash2KeysTableOf<ElemVector>(29, memMgr)); + grammar->setTargetNamespace(SchemaSymbols::fgURI_SCHEMAFORSCHEMA); + XMLSchemaDescription* gramDesc = (XMLSchemaDescription*) grammar->getGrammarDescription(); + gramDesc->setTargetNamespace(SchemaSymbols::fgURI_SCHEMAFORSCHEMA); + + // setup components of annotation grammar + SchemaElementDecl* annotElemDecl = new (memMgr) SchemaElementDecl + ( + XMLUni::fgZeroLenString , SchemaSymbols::fgELT_ANNOTATION + , fURIStringPool->addOrFind(SchemaSymbols::fgURI_SCHEMAFORSCHEMA) + , SchemaElementDecl::Mixed_Complex, Grammar::TOP_LEVEL_SCOPE , memMgr + ); + annotElemDecl->setCreateReason(XMLElementDecl::Declared); + grammar->putElemDecl(annotElemDecl); + + ComplexTypeInfo* complexType = new (memMgr) ComplexTypeInfo(memMgr); + complexType->setAnonymous(); + complexType->setContentType(SchemaElementDecl::Mixed_Complex); + annotElemDecl->setComplexTypeInfo(complexType); + + // Revisit: is this okay for a key? + fBuffer.set(SchemaSymbols::fgURI_SCHEMAFORSCHEMA); + fBuffer.append(chComma); + fBuffer.append(chLatin_C); + fBuffer.append(chDigit_0); + grammar->getComplexTypeRegistry()->put((void*) fBuffer.getRawBuffer(), complexType); + + SchemaElementDecl* appInfoElemDecl = new (memMgr) SchemaElementDecl + ( + XMLUni::fgZeroLenString , SchemaSymbols::fgELT_APPINFO + , fURIStringPool->addOrFind(SchemaSymbols::fgURI_SCHEMAFORSCHEMA) + , SchemaElementDecl::Any, Grammar::TOP_LEVEL_SCOPE , memMgr + ); + + appInfoElemDecl->setCreateReason(XMLElementDecl::Declared); + appInfoElemDecl->setAttWildCard + ( + new (memMgr) SchemaAttDef + ( + XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, + fEmptyNamespaceURI, XMLAttDef::Any_Any, + XMLAttDef::ProcessContents_Lax, memMgr + ) + ); + grammar->putElemDecl(appInfoElemDecl); + complexType->addElement(appInfoElemDecl); + + SchemaElementDecl* docElemDecl = new (memMgr) SchemaElementDecl + ( + XMLUni::fgZeroLenString , SchemaSymbols::fgELT_DOCUMENTATION + , fURIStringPool->addOrFind(SchemaSymbols::fgURI_SCHEMAFORSCHEMA) + , SchemaElementDecl::Any, Grammar::TOP_LEVEL_SCOPE , memMgr + ); + + docElemDecl->setCreateReason(XMLElementDecl::Declared); + docElemDecl->setAttWildCard + ( + new (memMgr) SchemaAttDef + ( + XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, + fEmptyNamespaceURI, XMLAttDef::Any_Any, + XMLAttDef::ProcessContents_Lax, memMgr + ) + ); + grammar->putElemDecl(docElemDecl); + complexType->addElement(docElemDecl); + + ContentSpecNode* left = new (memMgr) ContentSpecNode(appInfoElemDecl, memMgr); + ContentSpecNode* right = new (memMgr) ContentSpecNode(docElemDecl, memMgr); + ContentSpecNode* root = new (memMgr) ContentSpecNode(ContentSpecNode::ModelGroupChoice + , left + , right + , true + , true + , memMgr); + root->setMinOccurs(0); + root->setMaxOccurs(SchemaSymbols::XSD_UNBOUNDED); + complexType->setContentSpec(root); + + // create input source to scan + MemBufInputSource* memBufIS = new (memMgr) MemBufInputSource + ( + (const XMLByte*)xsAnnot.getAnnotationString() + , XMLString::stringLen(xsAnnot.getAnnotationString())*sizeof(XMLCh) + , SchemaSymbols::fgELT_ANNOTATION + , false + , memMgr + ); + memBufIS->setEncoding(XMLUni::fgXMLChEncodingString); + memBufIS->setCopyBufToStream(false); + + XSAXMLScanner *scanner = new (memMgr) XSAXMLScanner + ( + fGrammarResolver, fURIStringPool, grammar, memMgr + ); + + scanner->setErrorReporter(fErrorReporter); + + scanner->scanDocument(*memBufIS); + + while (xsAnnotationEnum.hasMoreElements()) + { + XSAnnotation& xsAnnot = xsAnnotationEnum.nextElement(); + memBufIS->resetMemBufInputSource((const XMLByte*)xsAnnot.getAnnotationString() + , XMLString::stringLen(xsAnnot.getAnnotationString())*sizeof(XMLCh)); + //scanner->scanDocument(*memBufIS); + } + + delete scanner; + delete memBufIS; } XERCES_CPP_NAMESPACE_END 1.37 +5 -1 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.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- TraverseSchema.hpp 23 Sep 2004 01:09:56 -0000 1.36 +++ TraverseSchema.hpp 28 Sep 2004 02:14:14 -0000 1.37 @@ -686,6 +686,10 @@ // routine to generate synthetic annotations XSAnnotation* generateSyntheticAnnotation(const DOMElement* const elem , ValueVectorOf<DOMNode*>* nonXSAttList); + + // routine to validate annotations + void validateAnnotations(); + // ----------------------------------------------------------------------- // Private constants // -----------------------------------------------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]