version 1.1.1.1, 2001/01/14 19:53:23
|
version 1.2, 2001/03/23 21:33:44
|
|
|
// Author: | // Author: |
// | // |
// $Log$ | // $Log$ |
|
// Revision 1.2 2001/03/23 21:33:44 mike |
|
// Removed debugging output |
|
// |
// Revision 1.1.1.1 2001/01/14 19:53:23 mike | // Revision 1.1.1.1 2001/01/14 19:53:23 mike |
// Pegasus import | // Pegasus import |
// | // |
|
|
Boolean XmlParser::_getElementName(char*& p) | Boolean XmlParser::_getElementName(char*& p) |
{ | { |
if (!isalpha(*p) && *p != '_') | if (!isalpha(*p) && *p != '_') |
{ |
|
std::cout << __LINE__ << std::endl; |
|
throw XmlException(XmlException::BAD_START_TAG, _line); | throw XmlException(XmlException::BAD_START_TAG, _line); |
} |
|
| |
while (*p && | while (*p && |
(isalnum(*p) || *p == '_' || *p == '-' || *p == ':' || *p == '.')) | (isalnum(*p) || *p == '_' || *p == '-' || *p == ':' || *p == '.')) |
|
|
openCloseElement = false; | openCloseElement = false; |
| |
if (!isalpha(*p) && *p != '_') | if (!isalpha(*p) && *p != '_') |
{ |
|
std::cout << __LINE__ << std::endl; |
|
throw XmlException(XmlException::BAD_START_TAG, _line); | throw XmlException(XmlException::BAD_START_TAG, _line); |
} |
|
| |
while (*p && | while (*p && |
(isalnum(*p) || *p == '_' || *p == '-' || *p == ':' || *p == '.')) | (isalnum(*p) || *p == '_' || *p == '-' || *p == ':' || *p == '.')) |
|
|
void XmlParser::_getAttributeNameAndEqual(char*& p) | void XmlParser::_getAttributeNameAndEqual(char*& p) |
{ | { |
if (!isalpha(*p) && *p != '_') | if (!isalpha(*p) && *p != '_') |
{ |
|
std::cout << __LINE__ << std::endl; |
|
throw XmlException(XmlException::BAD_ATTRIBUTE_NAME, _line); | throw XmlException(XmlException::BAD_ATTRIBUTE_NAME, _line); |
} |
|
| |
while (*p && | while (*p && |
(isalnum(*p) || *p == '_' || *p == '-' || *p == ':' || *p == '.')) | (isalnum(*p) || *p == '_' || *p == '-' || *p == ':' || *p == '.')) |
|
|
_skipWhitespace(p); | _skipWhitespace(p); |
| |
if (*p != '=') | if (*p != '=') |
{ |
|
std::cout << __LINE__ << std::endl; |
|
throw XmlException(XmlException::BAD_ATTRIBUTE_NAME, _line); | throw XmlException(XmlException::BAD_ATTRIBUTE_NAME, _line); |
} |
|
| |
p++; | p++; |
| |
|
|
// ATTN-B: handle values contained in semiquotes: | // ATTN-B: handle values contained in semiquotes: |
| |
if (*p != '"' && *p != '\'') | if (*p != '"' && *p != '\'') |
{ |
|
std::cout << __LINE__ << std::endl; |
|
throw XmlException(XmlException::BAD_ATTRIBUTE_VALUE, _line); | throw XmlException(XmlException::BAD_ATTRIBUTE_VALUE, _line); |
} |
|
| |
char startChar = *p++; | char startChar = *p++; |
| |
|
|
p++; | p++; |
| |
if (*p != startChar) | if (*p != startChar) |
{ |
|
std::cout << __LINE__ << std::endl; |
|
throw XmlException(XmlException::BAD_ATTRIBUTE_VALUE, _line); | throw XmlException(XmlException::BAD_ATTRIBUTE_VALUE, _line); |
} |
|
| |
*p++ = '\0'; | *p++ = '\0'; |
} | } |
|
|
entry.text = ++p; | entry.text = ++p; |
| |
if (!_getElementName(p)) | if (!_getElementName(p)) |
{ |
|
std::cout << __LINE__ << std::endl; |
|
throw(XmlException(XmlException::BAD_END_TAG, _line)); | throw(XmlException(XmlException::BAD_END_TAG, _line)); |
} |
|
| |
return; | return; |
} | } |
|
|
} | } |
} | } |
else | else |
{ |
|
std::cout << __LINE__ << std::endl; |
|
throw XmlException(XmlException::BAD_START_TAG, _line); | throw XmlException(XmlException::BAD_START_TAG, _line); |
} |
|
| |
//-------------------------------------------------------------------------- | //-------------------------------------------------------------------------- |
// Grab all the attributes: | // Grab all the attributes: |
|
|
_getAttributeNameAndEqual(p); | _getAttributeNameAndEqual(p); |
| |
if (*p != '"' && *p != '\'') | if (*p != '"' && *p != '\'') |
{ |
|
std::cout << __LINE__ << std::endl; |
|
throw XmlException(XmlException::BAD_ATTRIBUTE_VALUE, _line); | throw XmlException(XmlException::BAD_ATTRIBUTE_VALUE, _line); |
} |
|
| |
attr.value = p + 1; | attr.value = p + 1; |
_getAttributeValue(p); | _getAttributeValue(p); |
|
|
| |
if (!(p[0] == '?' && p[1] == '>') && !isspace(*p)) | if (!(p[0] == '?' && p[1] == '>') && !isspace(*p)) |
{ | { |
std::cout << __LINE__ << std::endl; |
|
throw XmlException( | throw XmlException( |
XmlException::BAD_ATTRIBUTE_VALUE, _line); | XmlException::BAD_ATTRIBUTE_VALUE, _line); |
} | } |
|
|
{ | { |
// The next thing must be a space or a '>': | // The next thing must be a space or a '>': |
| |
std::cout << __LINE__ << std::endl; |
|
throw XmlException(XmlException::BAD_ATTRIBUTE_VALUE, _line); | throw XmlException(XmlException::BAD_ATTRIBUTE_VALUE, _line); |
} | } |
| |