peiyongz 2004/08/11 09:07:28 Modified: c/src/xercesc/util XMLString.hpp XMLString.cpp Log: isValidNOTATION Revision Changes Path 1.26 +13 -0 xml-xerces/c/src/xercesc/util/XMLString.hpp Index: XMLString.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLString.hpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- XMLString.hpp 25 May 2004 18:11:32 -0000 1.25 +++ XMLString.hpp 11 Aug 2004 16:07:27 -0000 1.26 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.26 2004/08/11 16:07:27 peiyongz + * isValidNOTATION + * * Revision 1.25 2004/05/25 18:11:32 peiyongz * removeChar() added * @@ -1023,6 +1026,16 @@ * @return Returns the length of the string */ static unsigned int stringLen(const XMLCh* const src); + + /** + * + * Checks whether an name is a valid NOTATION according to XML 1.0 + * @param name The string to check its NOTATION validity + * @param manager The memory manager + * @return Returns true if name is NOTATION valid, otherwise false + */ + static bool isValidNOTATION(const XMLCh* const name + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** * Deprecated: please use XMLChar1_0::isValidNCName 1.35 +52 -4 xml-xerces/c/src/xercesc/util/XMLString.cpp Index: XMLString.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLString.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- XMLString.cpp 12 Jul 2004 21:09:01 -0000 1.34 +++ XMLString.cpp 11 Aug 2004 16:07:27 -0000 1.35 @@ -66,18 +66,22 @@ #include <ctype.h> #include <stdlib.h> #include <errno.h> + +#include <xercesc/util/XMLString.hpp> #include <xercesc/util/ArrayIndexOutOfBoundsException.hpp> #include <xercesc/util/IllegalArgumentException.hpp> #include <xercesc/util/NumberFormatException.hpp> +#include <xercesc/util/OutOfMemoryException.hpp> +#include <xercesc/util/RuntimeException.hpp> +#include <xercesc/util/TranscodingException.hpp> + #include <xercesc/util/Janitor.hpp> #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/util/RefArrayVectorOf.hpp> -#include <xercesc/util/RuntimeException.hpp> #include <xercesc/util/TransService.hpp> -#include <xercesc/util/TranscodingException.hpp> -#include <xercesc/util/XMLString.hpp> #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> +#include <xercesc/util/XMLUri.hpp> #include <xercesc/internal/XMLReader.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -667,6 +671,50 @@ targetStr[copySize] = 0; } + +bool XMLString::isValidNOTATION(const XMLCh* const name + , MemoryManager* const manager ) +{ + // + // NOTATATION: <URI>:<localPart> + // where URI is optional + // ':' and localPart must be present + // + int nameLen = XMLString::stringLen(name); + int colPos = XMLString::lastIndexOf(name, chColon); + + if ((colPos == -1) || // no ':' + (colPos == nameLen - 1) ) // <URI>':' + return false; + + // Examine URI + if (colPos > 0) + { + XMLCh* temp = (XMLCh*) &(name[colPos]); + *temp = 0; + + try + { + XMLUri newURI(name, manager); // no relative uri support here + *temp = chColon; + } + catch(const OutOfMemoryException&) + { + *temp = chColon; + return false; + } + catch (...) + { + *temp = chColon; + return false; + } + } + + // Examine localpart + return XMLString::isValidNCName(&(name[colPos+1])); + +} + /** * Deprecated: isValidNCName
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]