gareth 2003/01/29 11:52:32
Modified: c/src/xercesc/validators/datatype DatatypeValidator.cpp
DatatypeValidator.hpp
Log:
PSVI API additions.
Revision Changes Path
1.5 +6 -1
xml-xerces/c/src/xercesc/validators/datatype/DatatypeValidator.cpp
Index: DatatypeValidator.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/datatype/DatatypeValidator.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DatatypeValidator.cpp 19 Dec 2002 14:03:10 -0000 1.4
+++ DatatypeValidator.cpp 29 Jan 2003 19:52:32 -0000 1.5
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.5 2003/01/29 19:52:32 gareth
+ * PSVI API additions.
+ *
* Revision 1.4 2002/12/19 14:03:10 gareth
* get/set methods to see if the represented type is anonymous. Patch by Peter
Volchek.
*
@@ -96,7 +99,6 @@
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
-#include <xercesc/validators/schema/SchemaSymbols.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -115,6 +117,9 @@
, fFacets(facets)
, fPattern(0)
, fRegex(0)
+ , fTypeLocalName(0)
+ , fTypeName(0)
+ , fTypeUri(0)
, fAnonymous(false)
{
}
1.9 +117 -1
xml-xerces/c/src/xercesc/validators/datatype/DatatypeValidator.hpp
Index: DatatypeValidator.hpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/datatype/DatatypeValidator.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DatatypeValidator.hpp 19 Dec 2002 14:03:10 -0000 1.8
+++ DatatypeValidator.hpp 29 Jan 2003 19:52:32 -0000 1.9
@@ -64,6 +64,8 @@
#include <xercesc/util/RefHashTableOf.hpp>
#include <xercesc/util/KVStringPair.hpp>
#include <xercesc/util/regx/RegularExpression.hpp>
+#include <xercesc/validators/schema/SchemaSymbols.hpp>
+#include <xercesc/framework/XMLBuffer.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -271,6 +273,34 @@
RefArrayVectorOf<XMLCh>* const enums,
const int finalSet) = 0;
+ /**
+ * Returns the uri,name of the type this validator is for
+ */
+ const XMLCh* getTypeName() const;
+
+ /**
+ * sets the uri,name that this validator is for - typeName is uri,name string.
+ * due to the internals of xerces this will set the uri to be the schema uri if
+ * there is no comma in typeName
+ */
+ void setTypeName(const XMLCh* const typeName);
+
+ /**
+ * sets the uri,name that this validator is for
+ */
+ void setTypeName(const XMLCh* const name, const XMLCh* const uri);
+
+ /**
+ * Returns the uri of the type this validator is for
+ */
+ const XMLCh* getTypeUri() const;
+
+ /**
+ * Returns the name of the type this validator is for
+ */
+ const XMLCh* getTypeLocalName() const;
+
+
protected:
// -----------------------------------------------------------------------
// Protected Constructors
@@ -371,6 +401,14 @@
// {base type definition} cannot specify a value for a specific
// facet.
//
+ // fTypeName
+ // the uri,name of the type this validator will validate
+ //
+ // fTypeLocalName
+ // the name of the type this validator will validate
+ //
+ // fTypeUri
+ // the uri of the type this validator will validate
// fAnonymous
// true if this type is anonynous
//
@@ -383,6 +421,9 @@
RefHashTableOf<KVStringPair>* fFacets;
XMLCh* fPattern;
RegularExpression* fRegex;
+ XMLCh* fTypeLocalName;
+ XMLCh* fTypeName;
+ XMLCh* fTypeUri;
bool fAnonymous;
};
@@ -428,6 +469,9 @@
delete fFacets;
delete [] fPattern;
delete fRegex;
+ delete [] fTypeName;
+ delete [] fTypeLocalName;
+ delete [] fTypeUri;
}
@@ -504,6 +548,78 @@
inline bool DatatypeValidator::isAtomic() const {
return true;
+}
+
+inline const XMLCh* DatatypeValidator::getTypeName() const {
+ return fTypeName;
+}
+
+inline const XMLCh* DatatypeValidator::getTypeLocalName() const {
+ if(!fTypeLocalName) {
+ int index = XMLString::indexOf(fTypeName, chComma);
+ int length = XMLString::stringLen(fTypeName);
+ XMLCh *tName = new XMLCh[length - index + 1];
+ XMLString::subString(tName, fTypeName, index + 1, length);
+ ((DatatypeValidator *)this)->fTypeLocalName = tName;
+ }
+
+ return fTypeLocalName;
+}
+
+inline const XMLCh* DatatypeValidator::getTypeUri() const {
+ if(!fTypeUri) {
+ int index = XMLString::indexOf(fTypeName, chComma);
+ int length = XMLString::stringLen(fTypeName);
+ XMLCh *uri = new XMLCh[index + 1];
+ XMLString::subString(uri, fTypeName, 0, index);
+ ((DatatypeValidator *)this)->fTypeUri = uri;
+ }
+
+ return fTypeUri;
+}
+
+inline void DatatypeValidator::setTypeName(const XMLCh* const name, const XMLCh*
const uri) {
+
+ delete [] fTypeName;
+ delete [] fTypeLocalName;
+ delete [] fTypeUri;
+
+ fTypeUri = XMLString::replicate(uri);
+ fTypeLocalName = XMLString::replicate(name);
+ XMLBuffer buf;
+ buf.set(uri);
+ buf.append(chComma);
+ buf.append(name);
+ fTypeName = XMLString::replicate(buf.getRawBuffer());
+}
+
+inline void DatatypeValidator::setTypeName(const XMLCh* const typeName) {
+
+ delete [] fTypeName;
+ delete [] fTypeLocalName;
+ delete [] fTypeUri;
+
+ //REVISIT this is a lot of work, cant we set this earlier when we have the info?
+ if( XMLString::indexOf( typeName, chComma ) < 0 ) {
+ fTypeLocalName = XMLString::replicate(typeName);
+ fTypeUri = XMLString::replicate(SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
+ XMLBuffer buf;
+ buf.set(SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
+ buf.append(chComma);
+ buf.append(typeName);
+ fTypeName = XMLString::replicate(buf.getRawBuffer());
+ }
+ else {
+ int index = XMLString::indexOf(typeName, chComma);
+ int length = XMLString::stringLen(typeName);
+ XMLCh *uri = new XMLCh[index + 1];
+ XMLCh *tName = new XMLCh[length - index + 1];
+ XMLString::subString(uri, typeName, 0, index);
+ XMLString::subString(tName, typeName, index + 1, length);
+ fTypeLocalName = tName;
+ fTypeUri = uri;
+ fTypeName = XMLString::replicate(typeName);
+ }
}
inline void DatatypeValidator::setAnonymous() {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]