You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ca...@apache.org on 2007/11/12 02:05:13 UTC
svn commit: r594002 - in /xerces/c/trunk: samples/src/SEnumVal/
src/xercesc/framework/psvi/ src/xercesc/internal/ src/xercesc/parsers/
src/xercesc/util/ src/xercesc/validators/schema/
Author: cargilld
Date: Sun Nov 11 17:05:09 2007
New Revision: 594002
URL: http://svn.apache.org/viewvc?rev=594002&view=rev
Log:
Various schema fixes including support for importing multiple schemas with the same namespace
Modified:
xerces/c/trunk/samples/src/SEnumVal/SEnumVal.cpp
xerces/c/trunk/src/xercesc/framework/psvi/XSComplexTypeDefinition.cpp
xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp
xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp
xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp
xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp
xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.hpp
xerces/c/trunk/src/xercesc/parsers/DOMLSParserImpl.cpp
xerces/c/trunk/src/xercesc/parsers/SAX2XMLReaderImpl.cpp
xerces/c/trunk/src/xercesc/parsers/SAXParser.cpp
xerces/c/trunk/src/xercesc/parsers/SAXParser.hpp
xerces/c/trunk/src/xercesc/util/XMLDateTime.hpp
xerces/c/trunk/src/xercesc/util/XMLString.cpp
xerces/c/trunk/src/xercesc/util/XMLUni.cpp
xerces/c/trunk/src/xercesc/util/XMLUni.hpp
xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp
xerces/c/trunk/src/xercesc/validators/schema/SchemaElementDecl.cpp
xerces/c/trunk/src/xercesc/validators/schema/SchemaElementDecl.hpp
xerces/c/trunk/src/xercesc/validators/schema/SchemaInfo.hpp
xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp
xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp
xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.hpp
Modified: xerces/c/trunk/samples/src/SEnumVal/SEnumVal.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/samples/src/SEnumVal/SEnumVal.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/samples/src/SEnumVal/SEnumVal.cpp (original)
+++ xerces/c/trunk/samples/src/SEnumVal/SEnumVal.cpp Sun Nov 11 17:05:09 2007
@@ -235,6 +235,7 @@
case SchemaElementDecl::Mixed_Complex: XERCES_STD_QUALIFIER cout << "Mixed_Complex"; break;
case SchemaElementDecl::Children: XERCES_STD_QUALIFIER cout << "Children"; break;
case SchemaElementDecl::Simple: XERCES_STD_QUALIFIER cout << "Simple"; break;
+ case SchemaElementDecl::ElementOnlyEmpty: XERCES_STD_QUALIFIER cout << "ElementOnlyEmpty"; break;
default: XERCES_STD_QUALIFIER cout << "Unknown"; break;
}
Modified: xerces/c/trunk/src/xercesc/framework/psvi/XSComplexTypeDefinition.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/framework/psvi/XSComplexTypeDefinition.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/framework/psvi/XSComplexTypeDefinition.cpp (original)
+++ xerces/c/trunk/src/xercesc/framework/psvi/XSComplexTypeDefinition.cpp Sun Nov 11 17:05:09 2007
@@ -126,8 +126,9 @@
case SchemaElementDecl::Simple:
return CONTENTTYPE_SIMPLE;
case SchemaElementDecl::Empty:
+ case SchemaElementDecl::ElementOnlyEmpty:
return CONTENTTYPE_EMPTY;
- case SchemaElementDecl::Children:
+ case SchemaElementDecl::Children:
return CONTENTTYPE_ELEMENT;
default:
//case SchemaElementDecl::Mixed_Complex:
Modified: xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp Sun Nov 11 17:05:09 2007
@@ -1427,8 +1427,9 @@
ComplexTypeInfo *currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo();
if(currType)
{
- SchemaElementDecl::ModelTypes modelType = (SchemaElementDecl::ModelTypes) currType->getContentType();
- if(modelType == SchemaElementDecl::Children)
+ SchemaElementDecl::ModelTypes modelType = (SchemaElementDecl::ModelTypes) currType->getContentType();
+ if(modelType == SchemaElementDecl::Children ||
+ modelType == SchemaElementDecl::ElementOnlyEmpty)
charOpts = XMLElementDecl::SpacesOk;
else if(modelType == SchemaElementDecl::Empty)
charOpts = XMLElementDecl::NoCharData;
@@ -1440,14 +1441,14 @@
{
// They definitely cannot handle any type of char data
fValidator->emitError(XMLValid::NoCharDataInCM);
- if(fGrammarType == Grammar::SchemaGrammarType)
- {
- if (getPSVIHandler())
- {
+ //if(fGrammarType == Grammar::SchemaGrammarType)
+ //{
+ // if (getPSVIHandler())
+ // {
// REVISIT:
// PSVIElement->setValidity(PSVIItem::VALIDITY_INVALID);
- }
- }
+ // }
+ // }
}
else if (fReaderMgr.getCurrentReader()->isAllSpaces(rawBuf, len))
{
@@ -2529,8 +2530,9 @@
ComplexTypeInfo *currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo();
if(currType)
{
- SchemaElementDecl::ModelTypes modelType = (SchemaElementDecl::ModelTypes) currType->getContentType();
- if(modelType == SchemaElementDecl::Children)
+ SchemaElementDecl::ModelTypes modelType = (SchemaElementDecl::ModelTypes) currType->getContentType();
+ if(modelType == SchemaElementDecl::Children ||
+ modelType == SchemaElementDecl::ElementOnlyEmpty)
charOpts = XMLElementDecl::SpacesOk;
else if(modelType == SchemaElementDecl::Empty)
charOpts = XMLElementDecl::NoCharData;
@@ -2898,8 +2900,9 @@
ComplexTypeInfo *currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo();
if(currType)
{
- SchemaElementDecl::ModelTypes modelType = (SchemaElementDecl::ModelTypes) currType->getContentType();
- if(modelType == SchemaElementDecl::Children)
+ SchemaElementDecl::ModelTypes modelType = (SchemaElementDecl::ModelTypes) currType->getContentType();
+ if(modelType == SchemaElementDecl::Children ||
+ modelType == SchemaElementDecl::ElementOnlyEmpty)
charOpts = XMLElementDecl::SpacesOk;
else if(modelType == SchemaElementDecl::Empty)
charOpts = XMLElementDecl::NoCharData;
Modified: xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp Sun Nov 11 17:05:09 2007
@@ -3325,8 +3325,9 @@
ComplexTypeInfo *currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo();
if(currType)
{
- SchemaElementDecl::ModelTypes modelType = (SchemaElementDecl::ModelTypes) currType->getContentType();
- if(modelType == SchemaElementDecl::Children)
+ SchemaElementDecl::ModelTypes modelType = (SchemaElementDecl::ModelTypes) currType->getContentType();
+ if(modelType == SchemaElementDecl::Children ||
+ modelType == SchemaElementDecl::ElementOnlyEmpty)
charOpts = XMLElementDecl::SpacesOk;
else if(modelType == SchemaElementDecl::Empty)
charOpts = XMLElementDecl::NoCharData;
@@ -4153,8 +4154,9 @@
ComplexTypeInfo *currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo();
if(currType)
{
- SchemaElementDecl::ModelTypes modelType = (SchemaElementDecl::ModelTypes) currType->getContentType();
- if(modelType == SchemaElementDecl::Children)
+ SchemaElementDecl::ModelTypes modelType = (SchemaElementDecl::ModelTypes) currType->getContentType();
+ if(modelType == SchemaElementDecl::Children ||
+ modelType == SchemaElementDecl::ElementOnlyEmpty)
charOpts = XMLElementDecl::SpacesOk;
else if(modelType == SchemaElementDecl::Empty)
charOpts = XMLElementDecl::NoCharData;
@@ -4503,8 +4505,9 @@
ComplexTypeInfo *currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo();
if(currType)
{
- SchemaElementDecl::ModelTypes modelType = (SchemaElementDecl::ModelTypes) currType->getContentType();
- if(modelType == SchemaElementDecl::Children)
+ SchemaElementDecl::ModelTypes modelType = (SchemaElementDecl::ModelTypes) currType->getContentType();
+ if(modelType == SchemaElementDecl::Children ||
+ modelType == SchemaElementDecl::ElementOnlyEmpty)
charOpts = XMLElementDecl::SpacesOk;
}
Modified: xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp Sun Nov 11 17:05:09 2007
@@ -170,6 +170,7 @@
, fIgnoreAnnotations(false)
, fDisableDefaultEntityResolution(false)
, fSkipDTDValidation(false)
+ , fHandleMultipleImports(false)
, fErrorCount(0)
, fEntityExpansionLimit(0)
, fEntityExpansionCount(0)
@@ -268,6 +269,7 @@
, fIgnoreAnnotations(false)
, fDisableDefaultEntityResolution(false)
, fSkipDTDValidation(false)
+ , fHandleMultipleImports(false)
, fErrorCount(0)
, fEntityExpansionLimit(0)
, fEntityExpansionCount(0)
Modified: xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp (original)
+++ xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp Sun Nov 11 17:05:09 2007
@@ -176,6 +176,7 @@
, const XMLCh* const text2 = 0
, const XMLCh* const text3 = 0
, const XMLCh* const text4 = 0
+
);
// -----------------------------------------------------------------------
@@ -283,6 +284,7 @@
bool getIgnoreAnnotations() const;
bool getDisableDefaultEntityResolution() const;
bool getSkipDTDValidation() const;
+ bool getHandleMultipleImports() const;
// -----------------------------------------------------------------------
// Getter methods
@@ -384,6 +386,7 @@
void setIgnoreAnnotations(const bool newValue);
void setDisableDefaultEntityResolution(const bool newValue);
void setSkipDTDValidation(const bool newValue);
+ void setHandleMultipleImports(const bool newValue);
// -----------------------------------------------------------------------
// Mutator methods
@@ -748,6 +751,7 @@
bool fIgnoreAnnotations;
bool fDisableDefaultEntityResolution;
bool fSkipDTDValidation;
+ bool fHandleMultipleImports;
int fErrorCount;
unsigned int fEntityExpansionLimit;
unsigned int fEntityExpansionCount;
@@ -1126,6 +1130,11 @@
return fSkipDTDValidation;
}
+inline bool XMLScanner::getHandleMultipleImports() const
+{
+ return fHandleMultipleImports;
+}
+
// ---------------------------------------------------------------------------
// XMLScanner: Setter methods
// ---------------------------------------------------------------------------
@@ -1313,6 +1322,11 @@
inline void XMLScanner::setSkipDTDValidation(const bool newValue)
{
fSkipDTDValidation = newValue;
+}
+
+inline void XMLScanner::setHandleMultipleImports(const bool newValue)
+{
+ fHandleMultipleImports = newValue;
}
// ---------------------------------------------------------------------------
Modified: xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp (original)
+++ xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp Sun Nov 11 17:05:09 2007
@@ -344,6 +344,11 @@
return fScanner->getSkipDTDValidation();
}
+bool AbstractDOMParser::getHandleMultipleImports() const
+{
+ return fScanner->getHandleMultipleImports();
+}
+
// ---------------------------------------------------------------------------
// AbstractDOMParser: Setter methods
// ---------------------------------------------------------------------------
@@ -493,6 +498,11 @@
void AbstractDOMParser::setSkipDTDValidation(const bool newValue)
{
fScanner->setSkipDTDValidation(newValue);
+}
+
+void AbstractDOMParser::setHandleMultipleImports(const bool newValue)
+{
+ fScanner->setHandleMultipleImports(newValue);
}
void AbstractDOMParser::setDocument(DOMDocument* toSet)
Modified: xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.hpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.hpp (original)
+++ xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.hpp Sun Nov 11 17:05:09 2007
@@ -470,6 +470,14 @@
*/
bool getSkipDTDValidation() const;
+ /** Get the 'handle multiple schema imports' flag
+ *
+ * @return true, if the parser is currently configured to
+ * import multiple schemas with the same namespace, false otherwise.
+ *
+ * @see #setHandleMultipleImports
+ */
+ bool getHandleMultipleImports() const;
//@}
@@ -888,6 +896,19 @@
* @param newValue The state to set
*/
void setSkipDTDValidation(const bool newValue);
+
+ /** Set the 'handle multiple schema imports' flag
+ *
+ * This method gives users the ability to import multiple schemas that
+ * have the same namespace.
+ *
+ * NOTE: This option is ignored if schema validation is disabled.
+ *
+ * The parser's default state is false
+ *
+ * @param newValue The state to set
+ */
+ void setHandleMultipleImports(const bool newValue);
//@}
Modified: xerces/c/trunk/src/xercesc/parsers/DOMLSParserImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/parsers/DOMLSParserImpl.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/parsers/DOMLSParserImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/parsers/DOMLSParserImpl.cpp Sun Nov 11 17:05:09 2007
@@ -136,6 +136,7 @@
fSupportedParameters->add(XMLUni::fgXercesDisableDefaultEntityResolution);
fSupportedParameters->add(XMLUni::fgXercesSkipDTDValidation);
fSupportedParameters->add(XMLUni::fgXercesDoXInclude);
+ fSupportedParameters->add(XMLUni::fgXercesHandleMultipleImports);
}
@@ -407,6 +408,10 @@
{
setDoXInclude(state);
}
+ else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesHandleMultipleImports) == 0)
+ {
+ getScanner()->setHandleMultipleImports(state);
+ }
else
throw DOMException(DOMException::NOT_FOUND_ERR, 0, getMemoryManager());
}
@@ -582,6 +587,10 @@
{
return (void*)getScanner()->getSkipDTDValidation();
}
+ else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesHandleMultipleImports) == 0)
+ {
+ return (void*)getScanner()->getHandleMultipleImports();
+ }
else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesEntityResolver) == 0)
{
return fXMLEntityResolver;
@@ -652,7 +661,8 @@
XMLString::compareIStringASCII(name, XMLUni::fgXercesIgnoreAnnotations) == 0 ||
XMLString::compareIStringASCII(name, XMLUni::fgXercesDisableDefaultEntityResolution) == 0 ||
XMLString::compareIStringASCII(name, XMLUni::fgXercesSkipDTDValidation) == 0 ||
- XMLString::compareIStringASCII(name, XMLUni::fgXercesDoXInclude) == 0)
+ XMLString::compareIStringASCII(name, XMLUni::fgXercesDoXInclude) == 0 ||
+ XMLString::compareIStringASCII(name, XMLUni::fgXercesHandleMultipleImports) == 0)
return true;
else if(XMLString::compareIStringASCII(name, XMLUni::fgDOMDisallowDoctype) == 0 ||
XMLString::compareIStringASCII(name, XMLUni::fgDOMIgnoreUnknownCharacterDenormalization) == 0 ||
Modified: xerces/c/trunk/src/xercesc/parsers/SAX2XMLReaderImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/parsers/SAX2XMLReaderImpl.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/parsers/SAX2XMLReaderImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/parsers/SAX2XMLReaderImpl.cpp Sun Nov 11 17:05:09 2007
@@ -1340,6 +1340,10 @@
{
fScanner->setSkipDTDValidation(value);
}
+ else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesHandleMultipleImports) == 0)
+ {
+ fScanner->setHandleMultipleImports(value);
+ }
else
throw SAXNotRecognizedException("Unknown Feature", fMemoryManager);
}
@@ -1386,6 +1390,8 @@
return fScanner->getDisableDefaultEntityResolution();
else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesSkipDTDValidation) == 0)
return fScanner->getSkipDTDValidation();
+ else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesHandleMultipleImports) == 0)
+ return fScanner->getHandleMultipleImports();
else
throw SAXNotRecognizedException("Unknown Feature", fMemoryManager);
Modified: xerces/c/trunk/src/xercesc/parsers/SAXParser.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/parsers/SAXParser.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/parsers/SAXParser.cpp (original)
+++ xerces/c/trunk/src/xercesc/parsers/SAXParser.cpp Sun Nov 11 17:05:09 2007
@@ -372,6 +372,11 @@
return fScanner->getSkipDTDValidation();
}
+bool SAXParser::getHandleMultipleImports() const
+{
+ return fScanner->getHandleMultipleImports();
+}
+
// ---------------------------------------------------------------------------
// SAXParser: Setter methods
// ---------------------------------------------------------------------------
@@ -526,6 +531,11 @@
void SAXParser::setSkipDTDValidation(const bool newValue)
{
fScanner->setSkipDTDValidation(newValue);
+}
+
+void SAXParser::setHandleMultipleImports(const bool newValue)
+{
+ fScanner->setHandleMultipleImports(newValue);
}
// ---------------------------------------------------------------------------
Modified: xerces/c/trunk/src/xercesc/parsers/SAXParser.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/parsers/SAXParser.hpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/parsers/SAXParser.hpp (original)
+++ xerces/c/trunk/src/xercesc/parsers/SAXParser.hpp Sun Nov 11 17:05:09 2007
@@ -515,6 +515,14 @@
*/
bool getSkipDTDValidation() const;
+ /** Get the 'handle multiple schema imports' flag
+ *
+ * @return true, if the parser is currently configured to
+ * import multiple schemas with the same namespace, false otherwise.
+ *
+ * @see #setHandleMultipleImports
+ */
+ bool getHandleMultipleImports() const;
//@}
@@ -899,6 +907,19 @@
* @param newValue The state to set
*/
void setSkipDTDValidation(const bool newValue);
+
+ /** Set the 'handle multiple schema imports' flag
+ *
+ * This method gives users the ability to import multiple schemas that
+ * have the same namespace.
+ *
+ * NOTE: This option is ignored if schema validation is disabled.
+ *
+ * The parser's default state is false
+ *
+ * @param newValue The state to set
+ */
+ void setHandleMultipleImports(const bool newValue);
//@}
Modified: xerces/c/trunk/src/xercesc/util/XMLDateTime.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/XMLDateTime.hpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLDateTime.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLDateTime.hpp Sun Nov 11 17:05:09 2007
@@ -27,6 +27,7 @@
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/util/SchemaDateTimeException.hpp>
+#include <xercesc/util/XMLChar.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -273,6 +274,13 @@
reset();
fEnd = XMLString::stringLen(aString);
+
+ for (; fEnd > 0; fEnd--)
+ {
+ if (!XMLChar1_0::isWhitespace(aString[fEnd - 1]))
+ break;
+ }
+
if (fEnd > 0) {
if (fEnd > fBufferMaxLen)
@@ -282,7 +290,8 @@
fBuffer = (XMLCh*) fMemoryManager->allocate((fBufferMaxLen+1) * sizeof(XMLCh));
}
- memcpy(fBuffer, aString, (fEnd+1) * sizeof(XMLCh));
+ memcpy(fBuffer, aString, (fEnd) * sizeof(XMLCh));
+ fBuffer[fEnd] = '\0';
}
}
Modified: xerces/c/trunk/src/xercesc/util/XMLString.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/XMLString.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLString.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLString.cpp Sun Nov 11 17:05:09 2007
@@ -612,7 +612,7 @@
XMLSize_t nameLen = XMLString::stringLen(name);
int colPos = XMLString::lastIndexOf(name, chColon);
- if ((colPos == -1) || // no ':'
+ if ((colPos == 0) || // no ':'
(colPos == ((int)nameLen) - 1) ) // <URI>':'
return false;
@@ -622,7 +622,7 @@
{
return false;
}
- else if (colPos == 0)
+ else if (colPos == -1)
{
return true;
}
@@ -657,8 +657,7 @@
*/
bool XMLString::isValidEncName(const XMLCh* const name)
{
-
- if (name == 0 || *name == 0)
+ if (name == 0 || *name == 0)
return false;
const XMLCh* tempName = name;
Modified: xerces/c/trunk/src/xercesc/util/XMLUni.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/XMLUni.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLUni.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLUni.cpp Sun Nov 11 17:05:09 2007
@@ -1359,6 +1359,23 @@
, chLatin_o, chLatin_n, chNull
};
+//Xerces: http://apache.org/xml/features/validation/schema/handle-multiple-imports
+const XMLCh XMLUni::fgXercesHandleMultipleImports[] =
+{
+ 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_i, chLatin_o, chLatin_n, chForwardSlash
+ , chLatin_s, chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a
+ , chForwardSlash, chLatin_h, chLatin_a, chLatin_n, chLatin_d, chLatin_l, chLatin_e, chDash
+ , chLatin_m, chLatin_u, chLatin_l, chLatin_t, chLatin_i, chLatin_p
+ , chLatin_l, chLatin_e, chDash, chLatin_i, chLatin_m, chLatin_p, chLatin_o
+ , chLatin_r, chLatin_t, chLatin_s, chNull
+};
+
//Introduced in DOM Level 3
const XMLCh XMLUni::fgDOMCanonicalForm[] =
{
Modified: xerces/c/trunk/src/xercesc/util/XMLUni.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/XMLUni.hpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLUni.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLUni.hpp Sun Nov 11 17:05:09 2007
@@ -233,8 +233,9 @@
static const XMLCh fgXercesDisableDefaultEntityResolution[];
static const XMLCh fgXercesSkipDTDValidation[];
static const XMLCh fgXercesEntityResolver[];
-
+ static const XMLCh fgXercesHandleMultipleImports[];
static const XMLCh fgXercesDoXInclude[];
+
// SAX2 features/properties names
static const XMLCh fgSAX2CoreValidation[];
static const XMLCh fgSAX2CoreNameSpaces[];
Modified: xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp Sun Nov 11 17:05:09 2007
@@ -303,7 +303,8 @@
{
newValue = XMLString::replicate(XMLUni::fgAnyString, fMemoryManager);
}
- else if (fContentType == SchemaElementDecl::Empty)
+ else if (fContentType == SchemaElementDecl::Empty ||
+ fContentType == SchemaElementDecl::ElementOnlyEmpty)
{
newValue = XMLString::replicate(XMLUni::fgEmptyString, fMemoryManager);
}
@@ -352,7 +353,8 @@
XMLContentModel* ComplexTypeInfo::buildContentModel(ContentSpecNode* const aSpecNode)
{
XMLContentModel* cmRet = 0;
- if (fContentType == SchemaElementDecl::Simple) {
+ if (fContentType == SchemaElementDecl::Simple ||
+ fContentType == SchemaElementDecl::ElementOnlyEmpty) {
// just return nothing
}
else if (fContentType == SchemaElementDecl::Mixed_Simple)
Modified: xerces/c/trunk/src/xercesc/validators/schema/SchemaElementDecl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/SchemaElementDecl.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaElementDecl.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaElementDecl.cpp Sun Nov 11 17:05:09 2007
@@ -136,6 +136,7 @@
switch(modelType)
{
case Children :
+ case ElementOnlyEmpty :
retVal = XMLElementDecl::SpacesOk;
break;
Modified: xerces/c/trunk/src/xercesc/validators/schema/SchemaElementDecl.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/SchemaElementDecl.hpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaElementDecl.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaElementDecl.hpp Sun Nov 11 17:05:09 2007
@@ -57,7 +57,7 @@
, Mixed_Complex
, Children
, Simple
-
+ , ElementOnlyEmpty
, ModelTypes_Count
};
Modified: xerces/c/trunk/src/xercesc/validators/schema/SchemaInfo.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/SchemaInfo.hpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaInfo.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaInfo.hpp Sun Nov 11 17:05:09 2007
@@ -328,8 +328,31 @@
if (!fIncludeInfoList->containsElement(toAdd)) {
- fIncludeInfoList->addElement(toAdd);
- toAdd->fIncludeInfoList = fIncludeInfoList;
+ fIncludeInfoList->addElement(toAdd);
+ //code was originally:
+ //toAdd->fIncludeInfoList = fIncludeInfoList;
+ //however for handling multiple imports this was causing
+ //to schemaInfo's to have the same fIncludeInfoList which they
+ //both owned so when it was deleted it crashed.
+ if (toAdd->fIncludeInfoList) {
+ if (toAdd->fIncludeInfoList != fIncludeInfoList) {
+ unsigned int size = toAdd->fIncludeInfoList->size();
+ for (unsigned int i=0; i<size; i++) {
+ if (!fIncludeInfoList->containsElement(toAdd->fIncludeInfoList->elementAt(i))) {
+ fIncludeInfoList->addElement(toAdd->fIncludeInfoList->elementAt(i));
+ }
+ }
+ size = fIncludeInfoList->size();
+ for (unsigned int j=0; j<size; j++) {
+ if (!toAdd->fIncludeInfoList->containsElement(fIncludeInfoList->elementAt(j))) {
+ toAdd->fIncludeInfoList->addElement(fIncludeInfoList->elementAt(j));
+ }
+ }
+ }
+ }
+ else {
+ toAdd->fIncludeInfoList = fIncludeInfoList;
+ }
}
}
}
Modified: xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp Sun Nov 11 17:05:09 2007
@@ -102,8 +102,9 @@
const SchemaElementDecl::ModelTypes modelType = (currType)
? (SchemaElementDecl::ModelTypes)(currType->getContentType())
: ((SchemaElementDecl*)elemDecl)->getModelType();
-
- if (modelType == SchemaElementDecl::Empty)
+
+ if (modelType == SchemaElementDecl::Empty ||
+ modelType == SchemaElementDecl::ElementOnlyEmpty)
{
//
// We can do this one here. It cannot have any children. If it does
@@ -194,9 +195,16 @@
// this value will be legal since it matches one of them.
int colonPos = -1;
unsigned int uriId = getScanner()->resolveQName(value, *fNotationBuf, ElemStack::Mode_Element, colonPos);
- fNotationBuf->set(getScanner()->getURIText(uriId));
- fNotationBuf->append(chColon);
- fNotationBuf->append(&value[colonPos + 1]);
+ const XMLCh* uriText = getScanner()->getURIText(uriId);
+ if (uriText && *uriText) {
+ fNotationBuf->set(getScanner()->getURIText(uriId));
+ fNotationBuf->append(chColon);
+ fNotationBuf->append(&value[colonPos + 1]);
+ }
+ else {
+ fNotationBuf->set(value);
+ }
+
value = fNotationBuf->getRawBuffer();
}
@@ -414,9 +422,15 @@
XMLBuffer notationBuf(1023, fMemoryManager);
int colonPos = -1;
unsigned int uriId = getScanner()->resolveQName(attrValue, notationBuf, ElemStack::Mode_Element, colonPos);
- notationBuf.set(getScanner()->getURIText(uriId));
- notationBuf.append(chColon);
- notationBuf.append(&attrValue[colonPos + 1]);
+ const XMLCh* uriText = getScanner()->getURIText(uriId);
+ if (uriText && *uriText) {
+ notationBuf.set(uriText);
+ notationBuf.append(chColon);
+ notationBuf.append(&attrValue[colonPos + 1]);
+ }
+ else {
+ notationBuf.set(attrValue);
+ }
attDefDV->validate(notationBuf.getRawBuffer()
, context
Modified: xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp Sun Nov 11 17:05:09 2007
@@ -301,77 +301,88 @@
}
void TraverseSchema::preprocessSchema(DOMElement* const schemaRoot,
- const XMLCh* const schemaURL) {
+ const XMLCh* const schemaURL,
+ bool multipleImport) {
- // Make sure namespace binding is defaulted
- const XMLCh* rootPrefix = schemaRoot->getPrefix();
+ if (!multipleImport) {
+ // Make sure namespace binding is defaulted
+ const XMLCh* rootPrefix = schemaRoot->getPrefix();
- if (rootPrefix == 0 || !*rootPrefix) {
+ if (rootPrefix == 0 || !*rootPrefix) {
- const XMLCh* xmlnsStr = schemaRoot->getAttribute(XMLUni::fgXMLNSString);
-
- if (!xmlnsStr || !*xmlnsStr) {
- schemaRoot->setAttribute(XMLUni::fgXMLNSString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
+ const XMLCh* xmlnsStr = schemaRoot->getAttribute(XMLUni::fgXMLNSString);
+
+ if (!xmlnsStr || !*xmlnsStr) {
+ schemaRoot->setAttribute(XMLUni::fgXMLNSString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
+ }
}
- }
- // Set schemaGrammar data and add it to GrammarResolver
- // For complex type registry, attribute decl registry , group/attGroup
- // and namespace mapping, needs to check whether the passed in
- // Grammar was a newly instantiated one.
- fComplexTypeRegistry = fSchemaGrammar->getComplexTypeRegistry();
+ // Set schemaGrammar data and add it to GrammarResolver
+ // For complex type registry, attribute decl registry , group/attGroup
+ // and namespace mapping, needs to check whether the passed in
+ // Grammar was a newly instantiated one.
+ fComplexTypeRegistry = fSchemaGrammar->getComplexTypeRegistry();
- if (fComplexTypeRegistry == 0 ) {
+ if (fComplexTypeRegistry == 0 ) {
- fComplexTypeRegistry = new (fGrammarPoolMemoryManager) RefHashTableOf<ComplexTypeInfo>(29, fGrammarPoolMemoryManager);
- fSchemaGrammar->setComplexTypeRegistry(fComplexTypeRegistry);
- }
+ fComplexTypeRegistry = new (fGrammarPoolMemoryManager) RefHashTableOf<ComplexTypeInfo>(29, fGrammarPoolMemoryManager);
+ fSchemaGrammar->setComplexTypeRegistry(fComplexTypeRegistry);
+ }
- fGroupRegistry = fSchemaGrammar->getGroupInfoRegistry();
+ fGroupRegistry = fSchemaGrammar->getGroupInfoRegistry();
- if (fGroupRegistry == 0 ) {
+ if (fGroupRegistry == 0 ) {
- fGroupRegistry = new (fGrammarPoolMemoryManager) RefHashTableOf<XercesGroupInfo>(13, fGrammarPoolMemoryManager);
- fSchemaGrammar->setGroupInfoRegistry(fGroupRegistry);
- }
+ fGroupRegistry = new (fGrammarPoolMemoryManager) RefHashTableOf<XercesGroupInfo>(13, fGrammarPoolMemoryManager);
+ fSchemaGrammar->setGroupInfoRegistry(fGroupRegistry);
+ }
- fAttGroupRegistry = fSchemaGrammar->getAttGroupInfoRegistry();
+ fAttGroupRegistry = fSchemaGrammar->getAttGroupInfoRegistry();
- if (fAttGroupRegistry == 0 ) {
+ if (fAttGroupRegistry == 0 ) {
- fAttGroupRegistry = new (fGrammarPoolMemoryManager) RefHashTableOf<XercesAttGroupInfo>(13, fGrammarPoolMemoryManager);
- fSchemaGrammar->setAttGroupInfoRegistry(fAttGroupRegistry);
- }
+ fAttGroupRegistry = new (fGrammarPoolMemoryManager) RefHashTableOf<XercesAttGroupInfo>(13, fGrammarPoolMemoryManager);
+ fSchemaGrammar->setAttGroupInfoRegistry(fAttGroupRegistry);
+ }
- fAttributeDeclRegistry = fSchemaGrammar->getAttributeDeclRegistry();
+ fAttributeDeclRegistry = fSchemaGrammar->getAttributeDeclRegistry();
- if (fAttributeDeclRegistry == 0) {
+ if (fAttributeDeclRegistry == 0) {
- fAttributeDeclRegistry = new (fGrammarPoolMemoryManager) RefHashTableOf<XMLAttDef>(29, fGrammarPoolMemoryManager);
- fSchemaGrammar->setAttributeDeclRegistry(fAttributeDeclRegistry);
- }
+ fAttributeDeclRegistry = new (fGrammarPoolMemoryManager) RefHashTableOf<XMLAttDef>(29, fGrammarPoolMemoryManager);
+ fSchemaGrammar->setAttributeDeclRegistry(fAttributeDeclRegistry);
+ }
- fValidSubstitutionGroups = fSchemaGrammar->getValidSubstitutionGroups();
+ fValidSubstitutionGroups = fSchemaGrammar->getValidSubstitutionGroups();
- if (!fValidSubstitutionGroups) {
+ if (!fValidSubstitutionGroups) {
- fValidSubstitutionGroups = new (fGrammarPoolMemoryManager) RefHash2KeysTableOf<ElemVector>(29, fGrammarPoolMemoryManager);
- fSchemaGrammar->setValidSubstitutionGroups(fValidSubstitutionGroups);
- }
+ fValidSubstitutionGroups = new (fGrammarPoolMemoryManager) RefHash2KeysTableOf<ElemVector>(29, fGrammarPoolMemoryManager);
+ fSchemaGrammar->setValidSubstitutionGroups(fValidSubstitutionGroups);
+ }
+
+ //Retrieve the targetnamespace URI information
+ const XMLCh* targetNSURIStr = schemaRoot->getAttribute(SchemaSymbols::fgATT_TARGETNAMESPACE);
+ fSchemaGrammar->setTargetNamespace(targetNSURIStr);
- //Retrieve the targetnamespace URI information
- const XMLCh* targetNSURIStr = schemaRoot->getAttribute(SchemaSymbols::fgATT_TARGETNAMESPACE);
- fSchemaGrammar->setTargetNamespace(targetNSURIStr);
+ fScopeCount = 0;
+ fCurrentScope = Grammar::TOP_LEVEL_SCOPE;
+ fTargetNSURIString = fSchemaGrammar->getTargetNamespace();
+ fTargetNSURI = fURIStringPool->addOrFind(fTargetNSURIString);
- fScopeCount = 0;
- fCurrentScope = Grammar::TOP_LEVEL_SCOPE;
- fTargetNSURIString = fSchemaGrammar->getTargetNamespace();
- fTargetNSURI = fURIStringPool->addOrFind(fTargetNSURIString);
+ XMLSchemaDescription* gramDesc = (XMLSchemaDescription*) fSchemaGrammar->getGrammarDescription();
+ gramDesc->setTargetNamespace(fTargetNSURIString);
- XMLSchemaDescription* gramDesc = (XMLSchemaDescription*) fSchemaGrammar->getGrammarDescription();
- gramDesc->setTargetNamespace(fTargetNSURIString);
+ fGrammarResolver->putGrammar(fSchemaGrammar);
+ }
+ else {
+ fScopeCount = 0;
+ fCurrentScope = Grammar::TOP_LEVEL_SCOPE;
+
+ fTargetNSURIString = fSchemaGrammar->getTargetNamespace();
+ fTargetNSURI = fURIStringPool->addOrFind(fTargetNSURIString);
+ }
- fGrammarResolver->putGrammar(fSchemaGrammar);
fAttributeCheck.setValidationContext(fSchemaGrammar->getValidationContext());
SchemaInfo* currInfo = new (fMemoryManager) SchemaInfo(0, 0, 0, fTargetNSURI, fScopeCount,
@@ -810,6 +821,10 @@
// Nothing to do
if (!srcToFill) {
+ if (!grammarFound && nameSpace) {
+ fSchemaInfo->addImportedNS(fURIStringPool->addOrFind(nameSpace));
+ }
+
return;
}
@@ -829,7 +844,8 @@
}
if (grammarFound) {
- return;
+ if (!fScanner->getHandleMultipleImports())
+ return;
}
// ------------------------------------------------------------------
@@ -879,13 +895,18 @@
// --------------------------------------------------------
// Preprocess new schema
// --------------------------------------------------------
- SchemaInfo* saveInfo = fSchemaInfo;
- fSchemaGrammar = new (fGrammarPoolMemoryManager) SchemaGrammar(fGrammarPoolMemoryManager);
+ SchemaInfo* saveInfo = fSchemaInfo;
+ if (grammarFound) {
+ fSchemaGrammar = (SchemaGrammar*) aGrammar;
+ }
+ else {
+ fSchemaGrammar = new (fGrammarPoolMemoryManager) SchemaGrammar(fGrammarPoolMemoryManager);
+ }
XMLSchemaDescription* gramDesc = (XMLSchemaDescription*) fSchemaGrammar->getGrammarDescription();
gramDesc->setContextType(XMLSchemaDescription::CONTEXT_IMPORT);
gramDesc->setLocationHints(importURL);
- preprocessSchema(root, importURL);
+ preprocessSchema(root, importURL, grammarFound);
fPreprocessedNodes->put((void*) elem, fSchemaInfo);
// --------------------------------------------------------
@@ -1008,10 +1029,11 @@
* </choice-sequence>
*/
ContentSpecNode*
-TraverseSchema::traverseChoiceSequence(const DOMElement* const elem,
- const int modelGroupType)
+TraverseSchema::traverseChoiceSequence(const DOMElement* const elem,
+ const int modelGroupType,
+ bool& hasChildren)
{
-
+ hasChildren = false;
NamespaceScopeManager nsMgr(elem, fSchemaInfo, this);
// -----------------------------------------------------------------------
@@ -1037,6 +1059,7 @@
Janitor<ContentSpecNode> contentSpecNode(0);
for (; child != 0; child = XUtil::getNextSiblingElement(child)) {
+ hasChildren = true;
contentSpecNode.release();
bool seeParticle = false;
bool wasAny = false;
@@ -1080,13 +1103,13 @@
seeParticle = true;
}
else if (XMLString::equals(childName, SchemaSymbols::fgELT_CHOICE)) {
-
- contentSpecNode.reset(traverseChoiceSequence(child,ContentSpecNode::Choice));
+ bool hasChild;
+ contentSpecNode.reset(traverseChoiceSequence(child,ContentSpecNode::Choice, hasChild));
seeParticle = true;
}
else if (XMLString::equals(childName, SchemaSymbols::fgELT_SEQUENCE)) {
-
- contentSpecNode.reset(traverseChoiceSequence(child,ContentSpecNode::Sequence));
+ bool hasChild;
+ contentSpecNode.reset(traverseChoiceSequence(child,ContentSpecNode::Sequence, hasChild));
seeParticle = true;
}
else if (XMLString::equals(childName, SchemaSymbols::fgELT_ANY)) {
@@ -1625,15 +1648,17 @@
bool illegalChild = false;
const XMLCh* childName = content->getLocalName();
+ bool hasChild;
+
if (XMLString::equals(childName, SchemaSymbols::fgELT_SEQUENCE)) {
- specNode.reset(traverseChoiceSequence(content, ContentSpecNode::Sequence));
+ specNode.reset(traverseChoiceSequence(content, ContentSpecNode::Sequence, hasChild));
}
else if (XMLString::equals(childName, SchemaSymbols::fgELT_CHOICE)) {
- specNode.reset(traverseChoiceSequence(content, ContentSpecNode::Choice));
+ specNode.reset(traverseChoiceSequence(content, ContentSpecNode::Choice, hasChild));
}
else if (XMLString::equals(childName, SchemaSymbols::fgELT_ALL)) {
- specNode.reset(traverseAll(content));
+ specNode.reset(traverseAll(content, hasChild));
}
else {
illegalChild = true;
@@ -2102,9 +2127,10 @@
* </all>
*/
ContentSpecNode*
-TraverseSchema::traverseAll(const DOMElement* const elem) {
+TraverseSchema::traverseAll(const DOMElement* const elem, bool& hasChildren) {
NamespaceScopeManager nsMgr(elem, fSchemaInfo, this);
+ hasChildren = false;
// -----------------------------------------------------------------------
// Check attributes
@@ -2133,7 +2159,7 @@
bool hadContent = false;
for (; child != 0; child = XUtil::getNextSiblingElement(child)) {
-
+ hasChildren = true;
contentSpecNode.release();
const XMLCh* childName = child->getLocalName();
@@ -3212,6 +3238,8 @@
unsigned int fixedFlag = 0;
unsigned short scope = 0;
bool isFirstPattern = true;
+ bool sawPattern = false;
+
while (content != 0) {
@@ -3281,10 +3309,16 @@
traverseNotationDecl(content, localPart, uriStr);
}
- fBuffer.set(uriStr);
- fBuffer.append(chColon);
- fBuffer.append(localPart);
- enums.get()->addElement(XMLString::replicate(fBuffer.getRawBuffer(), fGrammarPoolMemoryManager));
+ if (uriStr && *uriStr) {
+ fBuffer.set(uriStr);
+ fBuffer.append(chColon);
+ fBuffer.append(localPart);
+ enums.get()->addElement(XMLString::replicate(fBuffer.getRawBuffer(), fGrammarPoolMemoryManager));
+ }
+ else {
+ enums.get()->addElement(XMLString::replicate(localPart, fGrammarPoolMemoryManager));
+ }
+
}
else if (baseValidator->getType() == DatatypeValidator::QName) {
// We need the URI string for the prefix to determine
@@ -3314,7 +3348,7 @@
else
janPatternAnnot.get()->setNext(fAnnotation);
}
-
+ sawPattern = true;
if (isFirstPattern) { // fBuffer.isEmpty() - overhead call
isFirstPattern = false;
@@ -3365,7 +3399,7 @@
content = XUtil::getNextSiblingElement(content);
} // end while
- if (!pattern.isEmpty()) {
+ if (sawPattern) {
KVStringPair* kv = new (fGrammarPoolMemoryManager) KVStringPair(SchemaSymbols::fgELT_PATTERN, pattern.getRawBuffer(), pattern.getLen(), fGrammarPoolMemoryManager);
if (!janPatternAnnot.isDataNull())
@@ -6015,7 +6049,7 @@
}
-void TraverseSchema::checkMinMax(ContentSpecNode* const specNode,
+int TraverseSchema::checkMinMax(ContentSpecNode* const specNode,
const DOMElement* const elem,
const int allContextFlag) {
@@ -6074,7 +6108,7 @@
}
if (minOccurs == 0 && maxOccurs == 0){
- return;
+ return minOccurs;
}
// Constraint checking for min/max value
@@ -6127,6 +6161,7 @@
}
}
}
+ return minOccurs;
}
@@ -6172,6 +6207,8 @@
}
}
+ bool effectiveContent_hasChild = false;
+
if (childElem != 0) {
fCircularCheckIndex = fCurrentTypeNameStack->size();
@@ -6204,21 +6241,25 @@
}
else if (XMLString::equals(childName, SchemaSymbols::fgELT_SEQUENCE)) {
- specNodeJan.reset(traverseChoiceSequence(childElem, ContentSpecNode::Sequence));
+ specNodeJan.reset(traverseChoiceSequence(childElem, ContentSpecNode::Sequence, effectiveContent_hasChild));
specNode = specNodeJan.get();
checkMinMax(specNode, childElem);
attrNode = XUtil::getNextSiblingElement(childElem);
}
else if (XMLString::equals(childName, SchemaSymbols::fgELT_CHOICE)) {
- specNodeJan.reset(traverseChoiceSequence(childElem, ContentSpecNode::Choice));
+ specNodeJan.reset(traverseChoiceSequence(childElem, ContentSpecNode::Choice, effectiveContent_hasChild));
specNode = specNodeJan.get();
- checkMinMax(specNode, childElem);
+ int minOccurs = checkMinMax(specNode, childElem);
+ if (!effectiveContent_hasChild && minOccurs != 0) {
+ effectiveContent_hasChild = true;
+ }
+
attrNode = XUtil::getNextSiblingElement(childElem);
}
else if (XMLString::equals(childName, SchemaSymbols::fgELT_ALL)) {
- specNodeJan.reset(traverseAll(childElem));
+ specNodeJan.reset(traverseAll(childElem, effectiveContent_hasChild));
specNode = specNodeJan.get();
checkMinMax(specNode, childElem, All_Group);
attrNode = XUtil::getNextSiblingElement(childElem);
@@ -6401,7 +6442,12 @@
typeInfo->setContentType(baseTypeInfo->getContentType());
}
else if (typeInfo->getContentSpec() == 0) {
- typeInfo->setContentType(SchemaElementDecl::Empty);
+ if (!effectiveContent_hasChild) {
+ typeInfo->setContentType(SchemaElementDecl::Empty);
+ }
+ else {
+ typeInfo->setContentType(SchemaElementDecl::ElementOnlyEmpty);
+ }
}
else {
typeInfo->setContentType(SchemaElementDecl::Children);
@@ -6891,10 +6937,6 @@
int targetNSURI = toRestore->getTargetNSURI();
fSchemaGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(toRestore->getTargetNSURIString());
-
- if (!fSchemaGrammar) {
- return;
- }
fTargetNSURI = targetNSURI;
fCurrentScope = saveScope;
Modified: xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.hpp?rev=594002&r1=594001&r2=594002&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.hpp Sun Nov 11 17:05:09 2007
@@ -130,7 +130,8 @@
*/
void doTraverseSchema(const DOMElement* const schemaRoot);
void preprocessSchema(DOMElement* const schemaRoot,
- const XMLCh* const schemaURL);
+ const XMLCh* const schemaURL,
+ bool multipleImport = false);
void traverseSchemaHeader(const DOMElement* const schemaRoot);
XSAnnotation* traverseAnnotationDecl(const DOMElement* const childElem,
ValueVectorOf<DOMNode*>* const nonXSAttList,
@@ -182,10 +183,12 @@
const XMLCh* traverseNotationDecl(const DOMElement* const childElem,
const XMLCh* const name,
const XMLCh* const uriStr);
- ContentSpecNode* traverseChoiceSequence(const DOMElement* const elemDecl,
- const int modelGroupType);
+ ContentSpecNode* traverseChoiceSequence(const DOMElement* const elemDecl,
+ const int modelGroupType,
+ bool& hasChildren);
ContentSpecNode* traverseAny(const DOMElement* const anyDecl);
- ContentSpecNode* traverseAll(const DOMElement* const allElem);
+ ContentSpecNode* traverseAll(const DOMElement* const allElem,
+ bool& hasChildren);
XercesGroupInfo* traverseGroupDecl(const DOMElement* const childElem,
const bool topLevel = true);
XercesAttGroupInfo* traverseAttributeGroupDecl(const DOMElement* const elem,
@@ -432,7 +435,8 @@
const XMLCh* const attName,
const bool toTrim = false);
- void checkMinMax(ContentSpecNode* const specNode,
+ /* return minOccurs */
+ int checkMinMax(ContentSpecNode* const specNode,
const DOMElement* const elem,
const int allContext = Not_All_Context);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org