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 2003/01/15 16:32:16 UTC
cvs commit: xml-xerces/c/src/xercesc/validators/schema TraverseSchema.hpp TraverseSchema.cpp
knoaman 2003/01/15 07:32:16
Modified: c/src/xercesc/validators/schema TraverseSchema.hpp
TraverseSchema.cpp
Log:
Check for target namespace with empty string.
Revision Changes Path
1.21 +5 -7 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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- TraverseSchema.hpp 13 Jan 2003 20:16:52 -0000 1.20
+++ TraverseSchema.hpp 15 Jan 2003 15:32:15 -0000 1.21
@@ -559,7 +559,7 @@
XercesAttGroupInfo* const toAttGroup,
ComplexTypeInfo* const typeInfo);
- const XMLCh* getTargetNamespaceString(const DOMElement* const elem);
+ void checkForEmptyTargetNamespace(const DOMElement* const elem);
/**
* Attribute wild card intersection.
@@ -855,16 +855,14 @@
return attValue;
}
-inline const XMLCh*
-TraverseSchema::getTargetNamespaceString(const DOMElement* const elem) {
+inline void
+TraverseSchema::checkForEmptyTargetNamespace(const DOMElement* const elem) {
const XMLCh* targetNS = getElementAttValue(elem, SchemaSymbols::fgATT_TARGETNAMESPACE);
- if (targetNS && (!targetNS || !*targetNS)) {
+ if (targetNS && !*targetNS) {
reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::InvalidTargetNSValue);
}
-
- return targetNS;
}
inline bool TraverseSchema::isBaseFromAnotherSchema(const XMLCh* const baseURI)
1.56 +12 -17 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.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- TraverseSchema.cpp 14 Jan 2003 21:29:56 -0000 1.55
+++ TraverseSchema.cpp 15 Jan 2003 15:32:15 -0000 1.56
@@ -365,13 +365,7 @@
//Retrieve the targetnamespace URI information
const XMLCh* targetNSURIStr = schemaRoot->getAttribute(SchemaSymbols::fgATT_TARGETNAMESPACE);
-
- if (targetNSURIStr == 0 || !*targetNSURIStr) {
- fSchemaGrammar->setTargetNamespace(XMLUni::fgZeroLenString);
- }
- else {
- fSchemaGrammar->setTargetNamespace(targetNSURIStr);
- }
+ fSchemaGrammar->setTargetNamespace(targetNSURIStr);
fScopeCount = 0;
fCurrentScope = Grammar::TOP_LEVEL_SCOPE;
@@ -407,6 +401,9 @@
reportSchemaError(schemaRoot, XMLUni::fgXMLErrDomain, XMLErrs::InvalidXMLSchemaRoot);
}
+ // Make sure that the targetNamespace value is not empty string
+ checkForEmptyTargetNamespace(schemaRoot);
+
// -----------------------------------------------------------------------
// Check Attributes
// -----------------------------------------------------------------------
@@ -546,11 +543,10 @@
if (root) {
- const XMLCh* targetNSURIString = getTargetNamespaceString(root);
- bool targetNSLength = !targetNSURIString || !*targetNSURIString;
+ const XMLCh* targetNSURIString = root->getAttribute(SchemaSymbols::fgATT_TARGETNAMESPACE);
// check to see if targetNameSpace is right
- if (!targetNSLength
+ if (*targetNSURIString
&& !XMLString::equals(targetNSURIString,fTargetNSURIString)){
reportSchemaError(root, XMLUni::fgXMLErrDomain, XMLErrs::IncludeNamespaceDifference,
schemaLocation, targetNSURIString);
@@ -559,7 +555,7 @@
// if targetNamespace is empty, change it to includ'g schema
// targetNamespace
- if (targetNSLength && root->getAttributeNode(XMLUni::fgXMLNSString) == 0
+ if (!*targetNSURIString && root->getAttributeNode(XMLUni::fgXMLNSString) == 0
&& fTargetNSURI != fEmptyNamespaceURI) {
root->setAttribute(XMLUni::fgXMLNSString, fTargetNSURIString);
}
@@ -727,7 +723,7 @@
return;
}
- const XMLCh* targetNSURIString = getTargetNamespaceString(root);
+ const XMLCh* targetNSURIString = root->getAttribute(SchemaSymbols::fgATT_TARGETNAMESPACE);
if (!XMLString::equals(targetNSURIString, nameSpace)) {
reportSchemaError(root, XMLUni::fgXMLErrDomain, XMLErrs::ImportNamespaceDifference,
@@ -7358,11 +7354,10 @@
return false;
}
- const XMLCh* targetNSURIString = getTargetNamespaceString(root); //getElementAttValue(root,SchemaSymbols::fgATT_TARGETNAMESPACE);
- bool targetNSLength = !targetNSURIString || !*targetNSURIString;
+ const XMLCh* targetNSURIString = root->getAttribute(SchemaSymbols::fgATT_TARGETNAMESPACE);
// check to see if targetNameSpace is right
- if (!targetNSLength
+ if (*targetNSURIString
&& !XMLString::equals(targetNSURIString,fTargetNSURIString)){
reportSchemaError(root, XMLUni::fgXMLErrDomain, XMLErrs::RedefineNamespaceDifference,
schemaLocation, targetNSURIString);
@@ -7371,7 +7366,7 @@
// if targetNamespace is empty, change it to redefin'g schema
// targetNamespace
- if (targetNSLength && root->getAttributeNode(XMLUni::fgXMLNSString) == 0
+ if (!*targetNSURIString && root->getAttributeNode(XMLUni::fgXMLNSString) == 0
&& fTargetNSURI != fEmptyNamespaceURI) {
root->setAttribute(XMLUni::fgXMLNSString, fTargetNSURIString);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org