diff options
author | kitty <kitty@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-10-23 22:40:16 +0000 |
---|---|---|
committer | kitty <kitty@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-10-23 22:40:16 +0000 |
commit | 2a89cc24cfd75c0bbf29b3d35d97da2f24a0585f (patch) | |
tree | f38f3f4bb44335e3c1f9f165c127ad8e9e4c225a | |
parent | 9a59e38a3089d929ddbe62025c6b195e64af8a8c (diff) | |
download | ATCD-2a89cc24cfd75c0bbf29b3d35d97da2f24a0585f.tar.gz |
ChangeLogTag: Wed Oct 23 17:27:14 2002 Krishnakumar B <kitty@cs.wustl.edu>
-rw-r--r-- | ACEXML/apps/svcconf/Makefile | 1 | ||||
-rw-r--r-- | ACEXML/common/Encoding.cpp | 4 | ||||
-rw-r--r-- | ACEXML/common/Encoding.h | 16 | ||||
-rw-r--r-- | ACEXML/common/Transcode.h | 18 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/Print_Handler.cpp | 4 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp | 4 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/namespaces.xml | 95 | ||||
-rw-r--r-- | ACEXML/parser/parser/Makefile | 1 | ||||
-rw-r--r-- | ACEXML/parser/parser/Parser.cpp | 550 | ||||
-rw-r--r-- | ACEXML/parser/parser/Parser.dsp | 4 | ||||
-rw-r--r-- | ACEXML/parser/parser/Parser.h | 19 | ||||
-rw-r--r-- | ACEXML/parser/parser/ParserErrors.h | 93 | ||||
-rw-r--r-- | ChangeLog | 46 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-03a | 46 |
14 files changed, 591 insertions, 310 deletions
diff --git a/ACEXML/apps/svcconf/Makefile b/ACEXML/apps/svcconf/Makefile index 9adc75b4372..e908e8ca2f7 100644 --- a/ACEXML/apps/svcconf/Makefile +++ b/ACEXML/apps/svcconf/Makefile @@ -395,6 +395,7 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/Obstack_T.cpp \ $(ACE_ROOT)/ACEXML/parser/parser/Entity_Manager.h \ $(ACE_ROOT)/ACEXML/parser/parser/Entity_Manager.i \ + $(ACE_ROOT)/ACEXML/parser/parser/ParserErrors.h \ $(ACE_ROOT)/ACEXML/parser/parser/Parser.i \ Svcconf_Handler.h \ $(ACE_ROOT)/ACEXML/common/DefaultHandler.h \ diff --git a/ACEXML/common/Encoding.cpp b/ACEXML/common/Encoding.cpp index 7fe8811cdbd..c6e53ed8c47 100644 --- a/ACEXML/common/Encoding.cpp +++ b/ACEXML/common/Encoding.cpp @@ -7,8 +7,8 @@ const ACEXML_Char* ACEXML_Encoding::encoding_names_[8] = { ACE_TEXT ("UCS-4LE"), ACE_TEXT ("UCS-4_2143"), ACE_TEXT ("UCS-4_3412"), - ACE_TEXT ("UTF-16BE"), - ACE_TEXT ("UTF-16LE"), + ACE_TEXT ("UTF-16"), + ACE_TEXT ("UTF-16"), ACE_TEXT ("UTF-8"), ACE_TEXT ("Unsupported Encoding") }; diff --git a/ACEXML/common/Encoding.h b/ACEXML/common/Encoding.h index fc0917c0b91..9c334a3b602 100644 --- a/ACEXML/common/Encoding.h +++ b/ACEXML/common/Encoding.h @@ -36,14 +36,14 @@ class ACEXML_Export ACEXML_Encoding { public: enum { - UCS4BE = 0, - UCS4LE = 1, - UCS4_2143 = 2, - UCS4_3412 = 3, - UTF16BE = 4, - UTF16LE = 5, - UTF8 = 6, - OTHER = 7 + UCS4BE, + UCS4LE, + UCS4_2143, + UCS4_3412, + UTF16BE, + UTF16LE, + UTF8, + OTHER } ENCODING; static const ACEXML_Char* encoding_names_[8]; diff --git a/ACEXML/common/Transcode.h b/ACEXML/common/Transcode.h index 427784891db..904d699ab56 100644 --- a/ACEXML/common/Transcode.h +++ b/ACEXML/common/Transcode.h @@ -58,7 +58,7 @@ public: * Convert a UTF-16 character into a string in UTF-8 encoding. * * @return number of characters the function uses to store the - * converted string if succeeds or one of the error STATUS + * converted string if it succeeds or one of the error STATUS * otherwise. */ static int utf162utf8 (ACEXML_UTF16 src, @@ -69,7 +69,7 @@ public: * Convert a UCS-4 character into a string in UTF-8 encoding. * * @return number of characters the function uses to store the - * converted string if succeeds or one of the error STATUS + * converted string if it succeeds or one of the error STATUS * otherwise. */ static int ucs42utf8 (ACEXML_UCS4 src, @@ -80,7 +80,7 @@ public: * Convert a UCS-4 character into a string in UTF-16 encoding. * * @return number of characters the function uses to store the - * converted string if succeeds or one of the error STATUS + * converted string if it succeeds or one of the error STATUS * otherwise. */ static int ucs42utf16 (ACEXML_UCS4 src, @@ -91,7 +91,7 @@ public: * Convert a UTF-16 surrogate character pair into a string in UTF-8 encoding. * * @return number of characters the function uses to store the - * converted string if succeeds or one of the error STATUS + * converted string if it succeeds or one of the error STATUS * otherwise. */ static int surrogate2utf8 (ACEXML_UTF16 high, @@ -102,7 +102,7 @@ public: /* * Convert a UTF-16 surrogate character pair into a UCS-4 character. * - * @return SUCCESS if succeeds or one of the error STATUS + * @return SUCCESS if it succeeds or one of the error STATUS * otherwise. */ static int surrogate2ucs4 (ACEXML_UTF16 high, @@ -114,7 +114,7 @@ public: * into a UCS-4 character. * * @return number of characters the function consumed from the - * UTF-8 string if succeeds or one of the error STATUS + * UTF-8 string if it succeeds or one of the error STATUS * otherwise. */ static int utf82ucs4 (const ACEXML_UTF8 *src, @@ -126,7 +126,7 @@ public: * into a UCS-4 character. * * @return number of characters the function consumed from the - * UTF-16 string if succeeds or one of the error STATUS + * UTF-16 string if it succeeds or one of the error STATUS * otherwise. */ static int utf162ucs4 (const ACEXML_UTF16 *src, @@ -146,7 +146,7 @@ public: * @param len The length of @a dst string. * * @return number of characters the function consumed from the - * UTF-8 string if succeeds or one of the error STATUS + * UTF-8 string if it succeeds or one of the error STATUS * otherwise. */ static int utf8s2utf16s (const ACEXML_UTF8 *src, @@ -159,7 +159,7 @@ public: * @param len The length of @a dst string. * * @return number of characters the function uses in - * UTF-8 string if succeeds or one of the error STATUS + * UTF-8 string if it succeeds or one of the error STATUS * otherwise. */ static int utf16s2utf8s (const ACEXML_UTF16 *src, diff --git a/ACEXML/examples/SAXPrint/Print_Handler.cpp b/ACEXML/examples/SAXPrint/Print_Handler.cpp index 19cfb44ba8d..a8a232a6bfb 100644 --- a/ACEXML/examples/SAXPrint/Print_Handler.cpp +++ b/ACEXML/examples/SAXPrint/Print_Handler.cpp @@ -22,14 +22,14 @@ ACEXML_Print_Handler::~ACEXML_Print_Handler (void) void ACEXML_Print_Handler::characters (const ACEXML_Char *cdata, int start, - int end ACEXML_ENV_ARG_DECL_NOT_USED) + int length ACEXML_ENV_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((ACEXML_SAXException)) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event characters () ** start: %d end: %d ***************\n%s\n- End event characters () ---------------\n"), - start, end, cdata)); + start, length, cdata)); } void diff --git a/ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp b/ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp index 66d96dca47b..462c14ba7a7 100644 --- a/ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp +++ b/ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp @@ -22,12 +22,12 @@ ACEXML_SAXPrint_Handler::~ACEXML_SAXPrint_Handler (void) void ACEXML_SAXPrint_Handler::characters (const ACEXML_Char *cdata, int start, - int end ACEXML_ENV_ARG_DECL_NOT_USED) + int length ACEXML_ENV_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((ACEXML_SAXException)) { ACE_UNUSED_ARG (start); - ACE_UNUSED_ARG (end); + ACE_UNUSED_ARG (length); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s"), cdata)); diff --git a/ACEXML/examples/SAXPrint/namespaces.xml b/ACEXML/examples/SAXPrint/namespaces.xml new file mode 100644 index 00000000000..f2418848929 --- /dev/null +++ b/ACEXML/examples/SAXPrint/namespaces.xml @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="iso8859-1"?> + +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns="http://purl.org/rss/1.0/"> + +<channel rdf:about="http://primates.ximian.com/~ravi/BoozeLog/"> +<title>Vignesh Blogs Here</title> +<link>http://primates.ximian.com/~ravi/BoozeLog/</link> +<description></description> +<language>en-us</language> +<webMaster></webMaster> +<lastBuildDate>2002-10-11T00:50:42-06:00</lastBuildDate> +<pubDate>2002-10-12T20:19:57-06:00</pubDate> +<admin:generatorAgent rdf:resource="http://www.movabletype.org/?v=2.21" /> + +<items> +<rdf:Seq><rdf:li rdf:resource="http://primates.ximian.com/~ravi/BoozeLog/archives/000025.html" /> +<rdf:li rdf:resource="http://primates.ximian.com/~ravi/BoozeLog/archives/000024.html" /> +<rdf:li rdf:resource="http://primates.ximian.com/~ravi/BoozeLog/archives/000023.html" /> +<rdf:li rdf:resource="http://primates.ximian.com/~ravi/BoozeLog/archives/000020.html" /> +<rdf:li rdf:resource="http://primates.ximian.com/~ravi/BoozeLog/archives/000013.html" /> +<rdf:li rdf:resource="http://primates.ximian.com/~ravi/BoozeLog/archives/000012.html" /> +<rdf:li rdf:resource="http://primates.ximian.com/~ravi/BoozeLog/archives/000011.html" /> +<rdf:li rdf:resource="http://primates.ximian.com/~ravi/BoozeLog/archives/000008.html" /> +</rdf:Seq> +</items> + +</channel> + +<item rdf:about="http://primates.ximian.com/~ravi/BoozeLog/archives/000025.html"> +<title>Happy Birthday Vidya</title> +<description>Today is Vidya's birthday ! Happy Birthday Vidya! We had a midnight party,as usual, at Swapna's place, though I dont...</description> +<link>http://primates.ximian.com/~ravi/BoozeLog/archives/000025.html</link> +<dc:subject>Blog entry</dc:subject> +<dc:creator>Booze</dc:creator> +<dc:date>2002-10-11T00:50:42-06:00</dc:date> +</item> +<item rdf:about="http://primates.ximian.com/~ravi/BoozeLog/archives/000024.html"> +<title>Way to go, Shaastra!</title> +<description>On Flash Back mode now: Shaastra is the technical festival at my alma mater, IIT Madras, that replaced the old,...</description> +<link>http://primates.ximian.com/~ravi/BoozeLog/archives/000024.html</link> +<dc:subject>Blog entry</dc:subject> +<dc:creator>Booze</dc:creator> +<dc:date>2002-10-10T11:52:02-06:00</dc:date> +</item> +<item rdf:about="http://primates.ximian.com/~ravi/BoozeLog/archives/000023.html"> +<title>Back and Forth in Time</title> +<description>The blog is going to be a little skewed in time for the next coupla days.. Inspite of my laziness,...</description> +<link>http://primates.ximian.com/~ravi/BoozeLog/archives/000023.html</link> +<dc:subject>Blog entry</dc:subject> +<dc:creator>Booze</dc:creator> +<dc:date>2002-10-09T23:47:19-06:00</dc:date> +</item> +<item rdf:about="http://primates.ximian.com/~ravi/BoozeLog/archives/000020.html"> +<title>Frisco Rocks!</title> +<description>If there be any reason the blog hasnt been updated,it is simply because I am enjoying my trip to San...</description> +<link>http://primates.ximian.com/~ravi/BoozeLog/archives/000020.html</link> +<dc:subject>Blog entry</dc:subject> +<dc:creator>Booze</dc:creator> +<dc:date>2002-10-03T23:53:16-06:00</dc:date> +</item> +<item rdf:about="http://primates.ximian.com/~ravi/BoozeLog/archives/000013.html"> +<title>Think but not make thoughts your aim</title> +<description>A line from Rudyard Kipling's IF : would sum up my feelings for today, a lot of thinking from morning...</description> +<link>http://primates.ximian.com/~ravi/BoozeLog/archives/000013.html</link> +<dc:subject>Blog entry</dc:subject> +<dc:creator>Booze</dc:creator> +<dc:date>2002-09-28T22:48:09-06:00</dc:date> +</item> +<item rdf:about="http://primates.ximian.com/~ravi/BoozeLog/archives/000012.html"> +<title>New ARM but...</title> +<description>ARM stands for Advanced Recording Model, a simulation software that I use for my work, and I have been tinkering...</description> +<link>http://primates.ximian.com/~ravi/BoozeLog/archives/000012.html</link> +<dc:subject>Blog entry</dc:subject> +<dc:creator>Booze</dc:creator> +<dc:date>2002-09-27T22:36:28-06:00</dc:date> +</item> +<item rdf:about="http://primates.ximian.com/~ravi/BoozeLog/archives/000011.html"> +<title>A much needed break</title> +<description>Slowly got over the hangover of Sandhya's departure and moved to more mundane things in life : assignments, submissions and...</description> +<link>http://primates.ximian.com/~ravi/BoozeLog/archives/000011.html</link> +<dc:subject>Blog entry</dc:subject> +<dc:creator>Booze</dc:creator> +<dc:date>2002-09-26T23:05:46-06:00</dc:date> +</item> +<item rdf:about="http://primates.ximian.com/~ravi/BoozeLog/archives/000008.html"> +<title>Here we go !</title> +<description>My first attempts at Blogging, the idea was introduced to me by Ravi Pratap. MoveableType really makes it easy and...</description> +<link>http://primates.ximian.com/~ravi/BoozeLog/archives/000008.html</link> +<dc:subject>Blog entry</dc:subject> +<dc:creator>Booze</dc:creator> +<dc:date>2002-09-25T19:27:22-06:00</dc:date> +</item> + + +</rdf:RDF> diff --git a/ACEXML/parser/parser/Makefile b/ACEXML/parser/parser/Makefile index 91aaf5bf525..b16dcfec6ba 100644 --- a/ACEXML/parser/parser/Makefile +++ b/ACEXML/parser/parser/Makefile @@ -339,6 +339,7 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU $(ACE_ROOT)/ace/Obstack_T.cpp \ Entity_Manager.h \ Entity_Manager.i \ + ParserErrors.h \ Parser.i \ $(ACE_ROOT)/ACEXML/common/Transcode.h \ $(ACE_ROOT)/ACEXML/common/Transcode.i \ diff --git a/ACEXML/parser/parser/Parser.cpp b/ACEXML/parser/parser/Parser.cpp index 4b49b5ed895..805cf0b0c9b 100644 --- a/ACEXML/parser/parser/Parser.cpp +++ b/ACEXML/parser/parser/Parser.cpp @@ -5,21 +5,90 @@ #include "ACEXML/common/AttributesImpl.h" #include "ace/ACE.h" -static const ACEXML_Char default_attribute_type[] = {'C', 'D', 'A', 'T', 'A', 0}; +#if !defined (__ACEXML_INLINE__) +# include "ACEXML/parser/parser/Parser.i" +#endif /* __ACEXML_INLINE__ */ + +static const ACEXML_Char default_attribute_type[] = ACE_TEXT ("CDATA"); static const ACEXML_Char empty_string[] = { 0 }; const ACEXML_Char -ACEXML_Parser::simple_parsing_feature_[] = { 'S', 'i', 'm', 'p', 'l', 'e', 0 }; +ACEXML_Parser::simple_parsing_feature_[] = ACE_TEXT ("Simple"); const ACEXML_Char -ACEXML_Parser::namespaces_feature_[] = {'h', 't', 't', 'p', ':', '/', '/', 'x', 'm', 'l', '.', 'o', 'r', 'g', '/', 's', 'a', 'x', '/', 'f', 'e', 'a', 't', 'u', 'r', 'e', 's', '/', 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', 's', 0 }; +ACEXML_Parser::namespaces_feature_[] = ACE_TEXT ("http://xml.org/sax/features/namespaces"); const ACEXML_Char -ACEXML_Parser::namespace_prefixes_feature_[] = {'h', 't', 't', 'p', ':', '/', '/', 'x', 'm', 'l', '.', 'o', 'r', 'g', '/', 's', 'a', 'x', '/', 'f', 'e', 'a', 't', 'u', 'r', 'e', 's', '/', 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '-', 'p', 'r', 'e', 'f', 'i', 'x', 'e', 's', 0 }; - -#if !defined (__ACEXML_INLINE__) -# include "ACEXML/parser/parser/Parser.i" -#endif /* __ACEXML_INLINE__ */ +ACEXML_Parser::namespace_prefixes_feature_[] = ACE_TEXT ("http://xml.org/sax/features/namespace-prefixes"); + + +static const ACEXML_Char* ACEXML_Parser_Msg [] = { + ACE_TEXT ("Invalid input source"), + ACE_TEXT ("Expecting '<'"), + ACE_TEXT ("Expecting '>'"), + ACE_TEXT ("Invalid comment"), + ACE_TEXT ("Duplicate DOCTYPE definition"), + ACE_TEXT ("Unexpected EOF"), + ACE_TEXT ("Invalid XMLDecl ('<?xml' ?)"), + ACE_TEXT ("Unrecognized XMLDecl ('version'?)"), + ACE_TEXT ("ACEXML only supports XML Version 1.0 documents"), + ACE_TEXT ("Encoding declaration doesn't match auto-detected encoding"), + ACE_TEXT ("ACEXML Parser Internal error"), + ACE_TEXT ("PITarget name cannot start with 'xml'"), + ACE_TEXT ("Expecting keyword 'DOCTYPE'"), + ACE_TEXT ("Expecting a DOCTYPE name"), + ACE_TEXT ("Root element missing"), + ACE_TEXT ("Error reading attribute"), + ACE_TEXT ("Duplicate namespace prefix"), + ACE_TEXT ("Duplicate attribute found"), + ACE_TEXT ("Cannot have both namespaces and namespace_prefixes simultaneously"), + ACE_TEXT ("Unexpected character"), + ACE_TEXT ("Mismatched End-tag encountered"), + ACE_TEXT ("Expecting '[CDATA[' section"), + ACE_TEXT ("Invalid keyword in markupdecl"), + ACE_TEXT ("Invalid character following '<!' in markupdecl"), + ACE_TEXT ("Expecting markupdecl or DeclSep"), + ACE_TEXT ("Expecting keyword `ELEMENT'"), + ACE_TEXT ("Error reading element name"), + ACE_TEXT ("Expecting keyword `EMPTY' in ELEMENT definition."), + ACE_TEXT ("Expecting keyword `ANY' in ELEMENT definition."), + ACE_TEXT ("Error reading ELEMENT definition."), + ACE_TEXT ("Expecting keyword `ENTITY'"), + ACE_TEXT ("Can't use a reference when defining entity name"), + ACE_TEXT ("Error reading ENTITY name."), + ACE_TEXT ("Error reading ENTITY value."), + ACE_TEXT ("Duplicate ENTITY definition"), + ACE_TEXT ("Invalid ExternalID definition (system ID missing)"), + ACE_TEXT ("Unexpected keyword NDATA in PEDecl"), + ACE_TEXT ("Expecting keyword NDATA"), + ACE_TEXT ("Expecting keyword `ATTLIST'"), + ACE_TEXT ("Error reading attribute name"), + ACE_TEXT ("Expecting keyword `CDATA'"), + ACE_TEXT ("Expecting keyword `ID', `IDREF', or `IDREFS'"), + ACE_TEXT ("Expecting keyword `ENTITY', or `ENTITIES'"), + ACE_TEXT ("Expecting keyword `NMTOKEN', `NMTOKENS', or `NOTATION'"), + ACE_TEXT ("Expecting keyword `NMTOKEN' or `NMTOKENS'"), + ACE_TEXT ("Expecting keyword `NOTATION'"), + ACE_TEXT ("Expecting `(' following NOTATION"), + ACE_TEXT ("Error reading NOTATION name"), + ACE_TEXT ("Error reading enumerated NMTOKEN name"), + ACE_TEXT ("Invalid Attribute Type"), + ACE_TEXT ("Expecting keyword `#REQUIRED'"), + ACE_TEXT ("Expecting keyword `#IMPLIED'"), + ACE_TEXT ("Expecting keyword `#FIXED'"), + ACE_TEXT ("Error parsing `#FIXED' attribute value"), + ACE_TEXT ("Invalid notation name."), + ACE_TEXT ("Expecting keyword 'SYSTEM'"), + ACE_TEXT ("Expecting keyword 'PUBLIC'"), + ACE_TEXT ("Error parsing system/public literal"), + ACE_TEXT ("Expecting either keyword `SYSTEM' or `PUBLIC'."), + ACE_TEXT ("Expecting keyword `#PCDATA'"), + ACE_TEXT ("Expecting end of Mixed section"), + ACE_TEXT ("Expecting closing `)*' or ')'") + ACE_TEXT ("Error reading sub-element name"), + ACE_TEXT ("Expecting `,', `|', or `)' while defining an element."), + ACE_TEXT ("Invalid character reference") +}; ACEXML_Parser::ACEXML_Parser (void) : dtd_handler_ (0), @@ -46,13 +115,11 @@ ACEXML_Parser::getFeature (const ACEXML_Char *name ACEXML_ENV_ARG_DECL) ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException, ACEXML_SAXNotSupportedException)) { - if (ACE_OS::strcmp (name, - ACEXML_Parser::simple_parsing_feature_) == 0) + if (ACE_OS::strcmp (name, ACEXML_Parser::simple_parsing_feature_) == 0) { return this->simple_parsing_; } - else if (ACE_OS::strcmp (name, - ACEXML_Parser::namespaces_feature_) == 0) + else if (ACE_OS::strcmp (name, ACEXML_Parser::namespaces_feature_) == 0) { return this->namespaces_; } @@ -73,14 +140,12 @@ ACEXML_Parser::setFeature (const ACEXML_Char *name, ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException, ACEXML_SAXNotSupportedException)) { - if (ACE_OS::strcmp (name, - ACEXML_Parser::simple_parsing_feature_) == 0) + if (ACE_OS::strcmp (name, ACEXML_Parser::simple_parsing_feature_) == 0) { this->simple_parsing_ = (boolean_value == 0 ? 0 : 1); return; } - else if (ACE_OS::strcmp (name, - ACEXML_Parser::namespaces_feature_) == 0) + else if (ACE_OS::strcmp (name, ACEXML_Parser::namespaces_feature_) == 0) { this->namespaces_ = (boolean_value == 0 ? 0 : 1); return; @@ -115,11 +180,11 @@ ACEXML_Parser::setProperty (const ACEXML_Char *name, } void -ACEXML_Parser::report_error (const ACEXML_Char* message ACEXML_ENV_ARG_DECL) +ACEXML_Parser::report_error (ACEXML_Error minor_code ACEXML_ENV_ARG_DECL) { ACEXML_SAXParseException* exception = 0; ACE_NEW_NORETURN (exception, - ACEXML_SAXParseException (message)); + ACEXML_SAXParseException (ACEXML_Parser_Msg[minor_code])); if (this->error_handler_) this->error_handler_->error (*exception ACEXML_ENV_ARG_PARAMETER); else @@ -128,22 +193,22 @@ ACEXML_Parser::report_error (const ACEXML_Char* message ACEXML_ENV_ARG_DECL) } void -ACEXML_Parser::report_warning (const ACEXML_Char* message ACEXML_ENV_ARG_DECL) +ACEXML_Parser::report_warning (ACEXML_Error minor_code ACEXML_ENV_ARG_DECL) { ACEXML_SAXParseException* exception = 0; ACE_NEW_NORETURN (exception, - ACEXML_SAXParseException (message)); + ACEXML_SAXParseException (ACEXML_Parser_Msg[minor_code])); if (this->error_handler_) this->error_handler_->warning (*exception ACEXML_ENV_ARG_PARAMETER); return; } void -ACEXML_Parser::report_fatal_error (const ACEXML_Char* message ACEXML_ENV_ARG_DECL) +ACEXML_Parser::report_fatal_error (ACEXML_Error minor_code ACEXML_ENV_ARG_DECL) { ACEXML_SAXParseException* exception = 0; ACE_NEW_NORETURN (exception, - ACEXML_SAXParseException (message)); + ACEXML_SAXParseException (ACEXML_Parser_Msg[minor_code])); if (this->error_handler_) this->error_handler_->fatalError (*exception ACEXML_ENV_ARG_PARAMETER); ACEXML_ENV_RAISE (exception); @@ -156,7 +221,7 @@ ACEXML_Parser::parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL) { if (input == 0 || (this->instream_ = input->getCharStream ()) == 0) { - this->report_fatal_error(ACE_TEXT ("Invalid input source") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_INVIP ACEXML_ENV_ARG_PARAMETER); return; } @@ -182,7 +247,7 @@ ACEXML_Parser::parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL) { if (this->skip_whitespace (0) != '<') { - this->report_fatal_error (ACE_TEXT ("Expecting '<'") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_LESS ACEXML_ENV_ARG_PARAMETER); return; } ACEXML_Char fwd = this->peek (); @@ -203,13 +268,15 @@ ACEXML_Parser::parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL) { if (this->grok_comment () < 0) { - this->report_fatal_error(ACE_TEXT ("Invalid comment") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_INVCO + ACEXML_ENV_ARG_PARAMETER); return; } } else { - this->report_fatal_error (ACE_TEXT ("Duplicate DOCTYPE definitions") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_DUPDOC + ACEXML_ENV_ARG_PARAMETER); return; } break; @@ -218,7 +285,7 @@ ACEXML_Parser::parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL) ACEXML_CHECK; break; case 0: - this->report_fatal_error (ACE_TEXT ("Unexpected EOF") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_EOF ACEXML_ENV_ARG_PARAMETER); return; default: // Root element begins prolog_done = 1; @@ -254,95 +321,65 @@ ACEXML_Parser::parse_xml_prolog (ACEXML_ENV_SINGLE_ARG_DECL) { if (this->parse_token (ACE_TEXT("<?xml")) < 0) { - this->report_fatal_error(ACE_TEXT ("Invalid XMLDecl ('<?xml' ?)") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_INVXMLDECL ACEXML_ENV_ARG_PARAMETER); return; } ACEXML_Char *astring; - if (this->skip_whitespace (0) != 'v' // Discard whitespace - || (this->parse_token (ACE_TEXT("ersion")) < 0) + || this->parse_token (ACE_TEXT("ersion")) < 0 || this->skip_equal () != 0 || this->get_quoted_string (astring) != 0) { - this->report_fatal_error (ACE_TEXT ("Unrecognized XMLDecl ('version'?)") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_INVVERSION ACEXML_ENV_ARG_PARAMETER); return; } - // @@ Handle version number here. - int xmldecl_state = 0; - int seen_encoding = 0; - - while (1) + if (ACE_OS::strcmp (astring, ACE_TEXT ("1.0")) != 0) { - ACEXML_Char fwd = this->peek (); + this->report_fatal_error (ACEXML_ENOTSUP ACEXML_ENV_ARG_PARAMETER); + return; + } + + ACEXML_Char fwd = this->skip_whitespace (0); if (fwd != '?') { - fwd = this->skip_whitespace (0); // Discard whitespace - if (fwd == '?') - { - // Fall down to consume the '?' and wrap up the XML Decl parsing. - } - else if (xmldecl_state == 0 && fwd == 'e') + if (fwd == 'e') { if ((this->parse_token (ACE_TEXT("ncoding")) == 0) && this->skip_equal () == 0 && this->get_quoted_string (astring) == 0) { - if (seen_encoding) - { - this->report_fatal_error (ACE_TEXT ("Duplicate encoding defined") ACEXML_ENV_ARG_PARAMETER); - return; - } - else - { - seen_encoding = 1; if (ACE_OS::strcmp (astring, this->instream_->getEncoding()) != 0) { - if (ACE_OS::strstr (astring, - this->instream_->getEncoding()) != 0) - { ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Detected Encoding is %s : Declared Encoding is %s"), + ACE_TEXT ("Detected Encoding is %s ") + ACE_TEXT (": Declared Encoding is %s\n"), this->instream_->getEncoding(), astring)); - this->report_fatal_error (ACE_TEXT ("Encoding declaration doesn't match detected encoding") ACEXML_ENV_ARG_PARAMETER); - return; - } - } + this->report_warning (ACEXML_ENCMISMATCH + ACEXML_ENV_ARG_PARAMETER); } - continue; + fwd = this->skip_whitespace (0); } - else - break; } - else if (xmldecl_state < 2 && fwd == 's') + if (fwd == 's') { if ((this->parse_token (ACE_TEXT("tandalone")) == 0) && this->skip_equal () == 0 && this->get_quoted_string (astring) == 0) { - xmldecl_state = 2; if (ACE_OS::strcmp (astring, ACE_TEXT ("yes")) == 0) - { - // @@ This is a standalone XML file. - continue; - } + this->standalone_ = 1; else if (ACE_OS::strcmp (astring, ACE_TEXT ("no")) == 0) - { - // @@ This is not a stand alone XML file. - continue; + this->standalone_ = 0; + fwd = this->skip_whitespace (0); } } - break; } - else - break; - } - if (this->parse_token (ACE_TEXT ("?>")) < 0) - break; + if (fwd == '?' && this->get() == '>') return; - } // End parsing XML Decl. - this->report_fatal_error (ACE_TEXT ("Unrecognized XML Decl ('standalone'?)") ACEXML_ENV_ARG_PARAMETER); + // All the rules fail. So return an error. + this->report_fatal_error (ACEXML_INVXMLDECL ACEXML_ENV_ARG_PARAMETER); return; } @@ -377,7 +414,7 @@ ACEXML_Parser::parse_processing_instruction (ACEXML_ENV_SINGLE_ARG_DECL) { if (this->get () != '?') { // How did we get here? - this->report_fatal_error(ACE_TEXT ("Internal error") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EINT ACEXML_ENV_ARG_PARAMETER); return -1; } const ACEXML_Char *pitarget = this->read_name (); @@ -386,7 +423,7 @@ ACEXML_Parser::parse_processing_instruction (ACEXML_ENV_SINGLE_ARG_DECL) if (ACE_OS::strcasecmp (ACE_TEXT ("xml"), pitarget) != 0) { // Invalid PITarget name. - this->report_fatal_error(ACE_TEXT ("PITarget name cannot start with 'xml'") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_INVPI ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -406,7 +443,8 @@ ACEXML_Parser::parse_processing_instruction (ACEXML_ENV_SINGLE_ARG_DECL) { instruction = this->obstack_.freeze (); this->content_handler_->processingInstruction (pitarget, - instruction ACEXML_ENV_ARG_PARAMETER); + instruction + ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK_RETURN (-1); this->obstack_.unwind (ACE_const_cast (ACEXML_Char*, pitarget)); return 0; @@ -434,14 +472,14 @@ ACEXML_Parser::parse_doctypedecl (ACEXML_ENV_SINGLE_ARG_DECL) { if (this->parse_token (ACE_TEXT ("DOCTYPE")) < 0) { - this->report_fatal_error(ACE_TEXT ("Expecting keyword 'DOCTYPE'") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_INVDOCKEYWORD ACEXML_ENV_ARG_PARAMETER); return -1; } ACEXML_Char nextch = this->skip_whitespace (0); if (nextch == 0) { - this->report_fatal_error(ACE_TEXT ("Expecting a DOCTYPE name") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_INVDOCNAME ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -476,7 +514,7 @@ ACEXML_Parser::parse_doctypedecl (ACEXML_ENV_SINGLE_ARG_DECL) // this is an XML document without a dectypedecl. return 0; case '0': - this->report_fatal_error (ACE_TEXT ("Unexpected EOF") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_EOF ACEXML_ENV_ARG_PARAMETER); return -1; default: break; @@ -484,7 +522,7 @@ ACEXML_Parser::parse_doctypedecl (ACEXML_ENV_SINGLE_ARG_DECL) if (this->skip_whitespace (0) != '>') { - this->report_fatal_error(ACE_TEXT ("Internal error") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EINT ACEXML_ENV_ARG_PARAMETER); return -1; } return 0; @@ -498,13 +536,13 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) const ACEXML_Char *startname = this->read_name (); if (startname == 0) { - this->report_fatal_error (ACE_TEXT ("Unexpected EOF") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_EOF ACEXML_ENV_ARG_PARAMETER); return; } if (is_root && this->doctype_ != 0 && ACE_OS::strcmp (startname, this->doctype_) != 0) { - this->report_fatal_error (ACE_TEXT ("Root element missing") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_MISSINGROOT ACEXML_ENV_ARG_PARAMETER); return; } ACEXML_AttributesImpl attributes; @@ -521,12 +559,12 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) switch (ch) { case 0: - this->report_fatal_error(ACE_TEXT ("Internal error") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EINT ACEXML_ENV_ARG_PARAMETER); return; case '/': if (this->get () != '>') { - this->report_fatal_error(ACE_TEXT ("Expecting '>'") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_GREAT ACEXML_ENV_ARG_PARAMETER); return; } else @@ -534,14 +572,18 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) this->xml_namespace_.processName(startname, ns_uri, ns_lname, 0); prefix = ACE_const_cast (ACEXML_Char*, this->xml_namespace_.getPrefix(ns_uri)); - this->report_prefix_mapping (prefix, ns_uri, ns_lname, 1 ACEXML_ENV_ARG_PARAMETER); + this->report_prefix_mapping (prefix, ns_uri, ns_lname, 1 + ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; this->content_handler_->startElement (ns_uri, ns_lname, - startname, &attributes ACEXML_ENV_ARG_PARAMETER); + startname, &attributes + ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; - this->content_handler_->endElement (ns_uri, ns_lname, startname ACEXML_ENV_ARG_PARAMETER); + this->content_handler_->endElement (ns_uri, ns_lname, startname + ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; - this->report_prefix_mapping (prefix, ns_uri, ns_lname, 0 ACEXML_ENV_ARG_PARAMETER); + this->report_prefix_mapping (prefix, ns_uri, ns_lname, 0 + ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; } if (new_namespace != 0) @@ -553,10 +595,12 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) this->xml_namespace_.processName (startname, ns_uri, ns_lname, 0); prefix = ACE_const_cast (ACEXML_Char*, this->xml_namespace_.getPrefix (ns_uri)); - this->report_prefix_mapping (prefix, ns_uri, ns_lname, 1 ACEXML_ENV_ARG_PARAMETER); + this->report_prefix_mapping (prefix, ns_uri, ns_lname, 1 + ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; this->content_handler_->startElement (ns_uri, ns_lname, startname, - &attributes ACEXML_ENV_ARG_PARAMETER); + &attributes + ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; start_element_done = 1; break; @@ -569,7 +613,7 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) this->skip_equal () != 0 || this->get_quoted_string (attvalue) != 0) { - this->report_fatal_error(ACE_TEXT ("Error reading attribute") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_RDATTR ACEXML_ENV_ARG_PARAMETER); return; } @@ -589,7 +633,8 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) if (this->xml_namespace_.declarePrefix (ns_name, attvalue) == -1) { - this->report_fatal_error(ACE_TEXT ("Duplicate namespace prefix") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_DUPPREFIX + ACEXML_ENV_ARG_PARAMETER); return; } } @@ -601,13 +646,15 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) default_attribute_type, attvalue) == -1) { - this->report_fatal_error(ACE_TEXT ("Duplicate attribute found") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_DUPATTR + ACEXML_ENV_ARG_PARAMETER); return; } } if (!this->namespaces_ && !this->namespace_prefixes_) { - this->report_fatal_error(ACE_TEXT ("Both namespaces feature and namespace_prefixes feature are false. Illegal Mode") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_NSERR + ACEXML_ENV_ARG_PARAMETER); return; } } @@ -619,7 +666,8 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) default_attribute_type, attvalue) == -1) { - this->report_fatal_error(ACE_TEXT ("Duplicate attribute found") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_DUPATTR + ACEXML_ENV_ARG_PARAMETER); return; } } @@ -637,14 +685,15 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) switch (ch) { case 0: - this->report_fatal_error(ACE_TEXT ("Internal error") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EINT ACEXML_ENV_ARG_PARAMETER); return; case '<': // Push out old 'characters' event. if (cdata_length != 0) { cdata = this->obstack_.freeze (); - this->content_handler_->characters (cdata, 0, cdata_length ACEXML_ENV_ARG_PARAMETER); + this->content_handler_->characters (cdata, 0, cdata_length + ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; this->obstack_.unwind (cdata); cdata_length = 0; @@ -659,7 +708,8 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) { if (this->grok_comment () < 0) { - this->report_fatal_error(ACE_TEXT ("Error parsing comment") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_INVCO + ACEXML_ENV_ARG_PARAMETER); return; } } @@ -670,7 +720,8 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) } else { - this->report_fatal_error(ACE_TEXT ("Unexpected character") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ECHAR + ACEXML_ENV_ARG_PARAMETER); return; } break; @@ -685,19 +736,23 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) if (endname == 0 || ACE_OS::strcmp (startname, endname) != 0) { - this->report_fatal_error(ACE_TEXT ("Mismatched End-tag encountered") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ETAG + ACEXML_ENV_ARG_PARAMETER); return ; } if (this->skip_whitespace (0) != '>') { - this->report_fatal_error(ACE_TEXT ("Expecting '>' in an end-tag") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_GREAT + ACEXML_ENV_ARG_PARAMETER); return; } - this->content_handler_->endElement (ns_uri, ns_lname, endname ACEXML_ENV_ARG_PARAMETER); + this->content_handler_->endElement (ns_uri, ns_lname, endname + ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; prefix = ACE_const_cast (ACEXML_Char*, this->xml_namespace_.getPrefix(ns_uri)); - this->report_prefix_mapping (prefix, ns_uri, ns_lname, 0 ACEXML_ENV_ARG_PARAMETER); + this->report_prefix_mapping (prefix, ns_uri, ns_lname, 0 + ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; if (new_namespace != 0) this->xml_namespace_.popContext (); @@ -719,7 +774,9 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) { if (this->parse_char_reference (buffer, 6) != 0) { - // not referring to any character exception? + this->report_fatal_error (ACEXML_INVCHAR + ACEXML_ENV_ARG_PARAMETER); + return; } charval.set (buffer, 0); @@ -730,18 +787,12 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) if (replace == 0) { - this->report_fatal_error(ACE_TEXT ("Internal error") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EINT ACEXML_ENV_ARG_PARAMETER); return; } -// if (this->try_grow_cdata (replace->length (), -// cdata_length, xmlenv) == 0) -// { cdata_length = replace->length (); for (size_t i = 0; i < replace->length (); ++i) this->obstack_.grow ((*replace)[i]); -// } -// else -// return; } break; case 0x0D: // End-of-Line handling @@ -755,9 +806,8 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) if (cdata == 0) { cdata = this->obstack_.freeze (); - this->content_handler_->characters (cdata, - 0, - cdata_length ACEXML_ENV_ARG_PARAMETER); + this->content_handler_->characters (cdata, 0, cdata_length + ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK; this->obstack_.grow (ch); cdata_length = 1; // the missing char. @@ -770,14 +820,10 @@ ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL) int ACEXML_Parser::parse_char_reference (ACEXML_Char *buf, size_t len) { - if (this->get () != '#') - { - // Internal error. + if (this->get () != '#') // Internal error. return -1; - } int hex = 0; - if (this->peek () == 'x') { hex = 1; @@ -844,19 +890,25 @@ ACEXML_Parser::parse_char_reference (ACEXML_Char *buf, size_t len) if (more_digit == 0) // no digit exist??? return -1; int clen; + // [WFC: Legal Character] + if (sum == 0x9 || sum == 0xA || sum == 0xD + || sum >= 0x20 && sum <= 0xD7FF + || sum >= 0xE000 && sum <= 0xFFFD + || sum >= 0x10000 && sum <= 0x10FFFF) + { + #if defined (ACE_USES_WCHAR) // UTF-16 if ((clen = ACEXML_Transcoder::ucs42utf16 (sum, buf, len)) < 0) return -1; -#elif 1 // or UTF-8 +#else // or UTF-8 if ((clen = ACEXML_Transcoder::ucs42utf8 (sum, buf, len)) < 0) return -1; - // #elif 0 // UCS 4, not likely - // buf [0] = sum; - // buf [1] = 0; #endif buf [clen] = 0; return 0; + } + return -1; default: return -1; } @@ -895,99 +947,43 @@ ACEXML_Parser::parse_cdata (ACEXML_ENV_SINGLE_ARG_DECL) { if (this->parse_token (ACE_TEXT ("[CDATA[")) < 0) { - this->report_fatal_error(ACE_TEXT ("'[CDATA[' expected") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ECDATASEC ACEXML_ENV_ARG_PARAMETER); return -1; } - int parse_state = 0; - size_t datalen = 0; - + ACEXML_Char ch; + int datalen = 0; + ACEXML_Char *cdata = 0; while (1) { - ACEXML_Char ch; - ACEXML_Char *cdata; - ch = this->get (); // Anything goes except the sequence "]]>". - switch (parse_state) + if (ch == ']' && this->peek() == ']') { - case 2: - if (ch == ']') - { - parse_state = 3; - continue; - } - break; - case 3: - if (ch == '>') // Yay! + ACEXML_Char temp = ch; + ch = this->get(); + if (ch == ']' && this->peek() == '>') { + ch = this->get(); cdata = this->obstack_.freeze (); - this->content_handler_->characters (cdata, - 0, - datalen ACEXML_ENV_ARG_PARAMETER); - // ACEXML_CHECK_RETURN (-1); + this->content_handler_->characters (cdata, 0, datalen + ACEXML_ENV_ARG_PARAMETER); + ACEXML_CHECK_RETURN (-1); this->obstack_.unwind(cdata); return 0; } - break; - default: - if (ch == ']') - { - parse_state = 2; - continue; - } - else - parse_state = 1; + this->obstack_.grow (temp); + ++datalen; } - while (parse_state > 0) - { - if (this->try_grow_cdata (1, datalen ACEXML_ENV_ARG_PARAMETER) < 0) - return -1; - - if (parse_state != 1) - this->obstack_.grow (']'); - else - { - if (ch == 0x0D) + else if (ch == 0x0D) ch = (this->peek () == 0x0A ? this->get () : 0x0A); this->obstack_.grow (ch); - } ++datalen; - --parse_state; - } }; ACE_NOTREACHED (return -1); } int -ACEXML_Parser::try_grow_cdata (size_t size, size_t &len ACEXML_ENV_ARG_DECL) -{ - if (this->obstack_.request (size) != 0) - { - if (len != 0) - { - ACEXML_Char *cdata = this->obstack_.freeze (); - if (cdata == 0) - { - this->report_fatal_error(ACE_TEXT ("Internal Error growing CDATA buffer") ACEXML_ENV_ARG_PARAMETER); - return -1; - } - this->content_handler_->characters (cdata, - 0, - len ACEXML_ENV_ARG_PARAMETER); - ACEXML_CHECK_RETURN (-1); - len = 0; // reset counter - if (this->obstack_.request (size) == 0) - return 0; - } - this->report_fatal_error(ACE_TEXT ("Internal Error, buffer overflowed") ACEXML_ENV_ARG_PARAMETER); - return -1; - } - return 0; -} - - -int ACEXML_Parser::parse_internal_dtd (ACEXML_ENV_SINGLE_ARG_DECL) { ACEXML_Char nextch = this->skip_whitespace (0); @@ -1020,7 +1016,8 @@ ACEXML_Parser::parse_internal_dtd (ACEXML_ENV_SINGLE_ARG_DECL) break; default: - this->report_fatal_error(ACE_TEXT ("Invalid keyword in decl spec") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_MKDECLKEYWORD + ACEXML_ENV_ARG_PARAMETER); return -1; } break; @@ -1038,15 +1035,17 @@ ACEXML_Parser::parse_internal_dtd (ACEXML_ENV_SINGLE_ARG_DECL) case '-': // a comment. if (this->grok_comment () < 0) { - this->report_fatal_error(ACE_TEXT ("Error parsing comment") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_INVCO + ACEXML_ENV_ARG_PARAMETER); return -1; } break; case 0: - this->report_fatal_error (ACE_TEXT ("Unexpected EOF") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_EOF ACEXML_ENV_ARG_PARAMETER); return -1; default: - this->report_fatal_error (ACE_TEXT ("Invalid char. follows '<!' in markupdecl") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_MKINVCH + ACEXML_ENV_ARG_PARAMETER); return -1; } break; @@ -1057,10 +1056,10 @@ ACEXML_Parser::parse_internal_dtd (ACEXML_ENV_SINGLE_ARG_DECL) break; case 0: - this->report_fatal_error (ACE_TEXT ("Unexpected EOF") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_EOF ACEXML_ENV_ARG_PARAMETER); return -1; default: - this->report_fatal_error (ACE_TEXT ("Invalid char. follows '<!' in markupdecl") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_MKINVCH ACEXML_ENV_ARG_PARAMETER); return -1; } break; @@ -1074,11 +1073,11 @@ ACEXML_Parser::parse_internal_dtd (ACEXML_ENV_SINGLE_ARG_DECL) case 0: // This may not be an error if we decide // to generalize this function to handle both // internal and external DTD definitions. - this->report_fatal_error (ACE_TEXT ("Unexpected EOF") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_EOF ACEXML_ENV_ARG_PARAMETER); return -1; default: - this->report_fatal_error (ACE_TEXT ("Expecting markupdecl or DecSep") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_MKDECL ACEXML_ENV_ARG_PARAMETER); return -1; }; @@ -1100,14 +1099,14 @@ ACEXML_Parser::parse_element_decl (ACEXML_ENV_SINGLE_ARG_DECL) if ((this->parse_token (ACE_TEXT ("LEMENT")) < 0) || this->skip_whitespace_count () == 0) { - this->report_fatal_error (ACE_TEXT ("Expecting keyword `ELEMENT'") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_EELEMENT ACEXML_ENV_ARG_PARAMETER); return -1; } ACEXML_Char *element_name = this->read_name (); if (element_name == 0) { - this->report_fatal_error (ACE_TEXT ("Error reading element name while defining ELEMENT.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_ERDELENAME ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -1119,14 +1118,14 @@ ACEXML_Parser::parse_element_decl (ACEXML_ENV_SINGLE_ARG_DECL) case 'E': // EMPTY if (this->parse_token (ACE_TEXT ("EMPTY")) < 0) { - this->report_fatal_error (ACE_TEXT ("Expecting keyword `EMPTY' in ELEMENT definition.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_EEMPTY ACEXML_ENV_ARG_PARAMETER); return -1; } break; case 'A': // ANY if (this->parse_token (ACE_TEXT ("ANY")) < 0) { - this->report_fatal_error (ACE_TEXT ("Expecting keyword `ANY' in ELEMENT definition.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_EANY ACEXML_ENV_ARG_PARAMETER); return -1; } break; @@ -1135,12 +1134,12 @@ ACEXML_Parser::parse_element_decl (ACEXML_ENV_SINGLE_ARG_DECL) ACEXML_CHECK_RETURN (-1); break; default: // error - this->report_fatal_error (ACE_TEXT ("Error reading ELEMENT definition.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_ERDELE ACEXML_ENV_ARG_PARAMETER); return -1; } if (this->skip_whitespace (0) != '>') { - this->report_fatal_error (ACE_TEXT ("Expecting '>' in ELEMENT definition.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_GREAT ACEXML_ENV_ARG_PARAMETER); return -1; } return 0; @@ -1154,7 +1153,7 @@ ACEXML_Parser::parse_entity_decl (ACEXML_ENV_SINGLE_ARG_DECL) if ((this->parse_token (ACE_TEXT ("NTITY")) < 0) || this->skip_whitespace_count (&nextch) == 0) { - this->report_fatal_error (ACE_TEXT ("Expecting keyword `ENTITY'") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_EENTITY ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -1165,7 +1164,7 @@ ACEXML_Parser::parse_entity_decl (ACEXML_ENV_SINGLE_ARG_DECL) this->get (); // consume the '%' if (this->skip_whitespace_count (&nextch) == 0) { - this->report_fatal_error (ACE_TEXT ("Can't use a reference when defining entity name") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_INVREF ACEXML_ENV_ARG_PARAMETER); return -1; } } @@ -1173,7 +1172,7 @@ ACEXML_Parser::parse_entity_decl (ACEXML_ENV_SINGLE_ARG_DECL) ACEXML_Char *entity_name = this->read_name (); if (entity_name == 0) { - this->report_fatal_error (ACE_TEXT ("Error reading ENTITY name.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error (ACEXML_ENTNAME ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -1185,7 +1184,7 @@ ACEXML_Parser::parse_entity_decl (ACEXML_ENV_SINGLE_ARG_DECL) if (this->get_quoted_string (entity_value) != 0) { - this->report_fatal_error(ACE_TEXT("Error reading ENTITY value.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ENTVALUE ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -1193,7 +1192,7 @@ ACEXML_Parser::parse_entity_decl (ACEXML_ENV_SINGLE_ARG_DECL) { if (this->entities_.add_entity (entity_name, entity_value) != 0) { - this->report_fatal_error(ACE_TEXT("Error storing entity definition (duplicate definition?)") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_DUPENT ACEXML_ENV_ARG_PARAMETER); return -1; } } @@ -1211,7 +1210,7 @@ ACEXML_Parser::parse_entity_decl (ACEXML_ENV_SINGLE_ARG_DECL) ACEXML_CHECK_RETURN (-1); if (systemid == 0) { - this->report_fatal_error(ACE_TEXT("Invalid ExternalID definition (system ID missing.)") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_INVEXTID ACEXML_ENV_ARG_PARAMETER); return -1; } this->skip_whitespace_count (&nextch); @@ -1219,22 +1218,21 @@ ACEXML_Parser::parse_entity_decl (ACEXML_ENV_SINGLE_ARG_DECL) { if (is_GEDecl == 0) { - this->report_fatal_error(ACE_TEXT("Unexpected keyword NDATA in PEDecl.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_UNDATA ACEXML_ENV_ARG_PARAMETER); return -1; } if ((this->parse_token (ACE_TEXT ("NDATA")) < 0) || this->skip_whitespace_count (&nextch) == 0) { - this->report_fatal_error(ACE_TEXT("Expecting keyword NDATA") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ENDATA ACEXML_ENV_ARG_PARAMETER); return -1; } ACEXML_Char *ndata = this->read_name (); - this->dtd_handler_->unparsedEntityDecl (entity_name, - publicid, - systemid, - ndata ACEXML_ENV_ARG_PARAMETER); + this->dtd_handler_->unparsedEntityDecl (entity_name, publicid, + systemid, ndata + ACEXML_ENV_ARG_PARAMETER); ACEXML_CHECK_RETURN (-1); } else @@ -1258,7 +1256,7 @@ ACEXML_Parser::parse_entity_decl (ACEXML_ENV_SINGLE_ARG_DECL) // End of ENTITY definition if (this->skip_whitespace (0) != '>') { - this->report_fatal_error(ACE_TEXT("Expecting end of ENTITY definition.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_GREAT ACEXML_ENV_ARG_PARAMETER); return -1; } return 0; @@ -1270,14 +1268,14 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) if ((this->parse_token (ACE_TEXT ("ATTLIST")) < 0) || this->skip_whitespace_count () == 0) { - this->report_fatal_error(ACE_TEXT("Expecting keyword `ATTLIST'") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EATTLIST ACEXML_ENV_ARG_PARAMETER); return -1; } ACEXML_Char *element_name = this->read_name (); if (element_name == 0) { - this->report_fatal_error(ACE_TEXT("Error reading element name while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ERDELENAME ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -1290,7 +1288,7 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) ACEXML_Char *att_name = this->read_name (nextch); if (att_name == 0) { - this->report_fatal_error(ACE_TEXT("Error reading attribute name while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EATTNAME ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -1315,7 +1313,7 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) if ((this->parse_token (ACE_TEXT ("DATA")) < 0) || this->skip_whitespace_count () == 0) { - this->report_fatal_error(ACE_TEXT("Expecting keyword `CDATA' while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ECDATA ACEXML_ENV_ARG_PARAMETER); return -1; } // Else, we have successfully identified the type of the @@ -1352,7 +1350,7 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) } } // Admittedly, this error message is not precise enough - this->report_fatal_error(ACE_TEXT("Expecting keyword `ID', `IDREF', or `IDREFS' while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EID ACEXML_ENV_ARG_PARAMETER); return -1; case 'E': // ENTITY or ENTITIES if (this->parse_token (ACE_TEXT ("NTIT")) == 0) @@ -1378,13 +1376,14 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) } } // Admittedly, this error message is not precise enough - this->report_fatal_error(ACE_TEXT("Expecting keyword `ENTITY', or `ENTITIES' while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EENTITIES ACEXML_ENV_ARG_PARAMETER); return -1; case 'N': // NMTOKEN, NMTOKENS, or, NOTATION nextch = this->get (); if (nextch != 'M' || nextch != 'O') { - this->report_fatal_error(ACE_TEXT("Expecting keyword `NMTOKEN', `NMTOKENS', or `NOTATION' while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ENMTOKEN + ACEXML_ENV_ARG_PARAMETER); return -1; } if (nextch == 'M') @@ -1406,7 +1405,8 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) break; } } - this->report_fatal_error(ACE_TEXT("Expecting keyword `NMTOKEN' or `NMTOKENS' while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ENMTOKENS + ACEXML_ENV_ARG_PARAMETER); return -1; } else // NOTATION @@ -1414,13 +1414,15 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) if ((this->parse_token (ACE_TEXT ("TATION")) < 0) || this->skip_whitespace_count () == 0) { - this->report_fatal_error(ACE_TEXT("Expecting keyword `NOTATION' while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ENOTATION + ACEXML_ENV_ARG_PARAMETER); return -1; } if (this->get () != '(') { - this->report_fatal_error(ACE_TEXT("Expecting `(' following NOTATION while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_LPAREN + ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -1430,7 +1432,8 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) ACEXML_Char *notation_name = this->read_name (); if (notation_name == 0) { - this->report_fatal_error(ACE_TEXT("Error reading NOTATION name while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ENOTNAME + ACEXML_ENV_ARG_PARAMETER); return -1; } // @@ get another notation name, set up validator as such @@ -1448,7 +1451,8 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) ACEXML_Char *token_name = this->read_name (); // @@ need a special read_nmtoken? if (token_name == 0) { - this->report_fatal_error(ACE_TEXT("Error reading enumerated nmtoken name while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ENMNAME + ACEXML_ENV_ARG_PARAMETER); return -1; } // @@ get another nmtoken, set up validator as such @@ -1460,7 +1464,8 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) break; default: { - this->report_fatal_error(ACE_TEXT("Invalid Attribute Type while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_INVATTRTYPE + ACEXML_ENV_ARG_PARAMETER); return -1; } ACE_NOTREACHED (break); @@ -1483,7 +1488,8 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) case 'R': if (this->parse_token (ACE_TEXT ("EQUIRED")) < 0) { - this->report_fatal_error(ACE_TEXT("Expecting keyword `#REQUIRED' while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EREQUIRED + ACEXML_ENV_ARG_PARAMETER); return -1; } // We now know this attribute is required @@ -1492,7 +1498,8 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) case 'I': if (this->parse_token (ACE_TEXT ("MPLIED")) < 0) { - this->report_fatal_error(ACE_TEXT("Expecting keyword `#IMPLIED' while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EIMPLIED + ACEXML_ENV_ARG_PARAMETER); return -1; } // We now know this attribute is impleid. @@ -1502,7 +1509,8 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) if (this->parse_token (ACE_TEXT ("IXED")) < 0 || this->skip_whitespace_count () == 0) { - this->report_fatal_error(ACE_TEXT("Expecting keyword `#FIXED' while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EFIXED + ACEXML_ENV_ARG_PARAMETER); return -1; } // We now know this attribute is fixed. @@ -1510,7 +1518,8 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) ACEXML_Char *fixed_attr; if (this->get_quoted_string (fixed_attr) != 0) { - this->report_fatal_error(ACE_TEXT("Error parsing `#FIXED' attribute value while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EINVFIXED + ACEXML_ENV_ARG_PARAMETER); return -1; } // @@ set up validator @@ -1524,7 +1533,8 @@ ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL) ACEXML_Char *fixed_attr; if (this->get_quoted_string (fixed_attr) != 0) { - this->report_fatal_error(ACE_TEXT("Error parsing `#FIXED' attribute value while defining ATTLIST.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EINVFIXED + ACEXML_ENV_ARG_PARAMETER); return -1; } // @@ set up validator @@ -1546,14 +1556,14 @@ ACEXML_Parser::parse_notation_decl (ACEXML_ENV_SINGLE_ARG_DECL) if (this->parse_token (ACE_TEXT ("NOTATION")) < 0 || this->skip_whitespace_count () == 0) { - this->report_fatal_error(ACE_TEXT("Expecting keyword `NOTATION'") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ENOTATION ACEXML_ENV_ARG_PARAMETER); return -1; } ACEXML_Char *notation = this->read_name (); if (notation == 0) { - this->report_fatal_error(ACE_TEXT("Invalid notation name.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_INVNOTNAME ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -1565,7 +1575,7 @@ ACEXML_Parser::parse_notation_decl (ACEXML_ENV_SINGLE_ARG_DECL) if (this->get () != '>') { - this->report_fatal_error(ACE_TEXT("Expecting NOTATION closing '>'.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_GREAT ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -1590,12 +1600,12 @@ ACEXML_Parser::parse_external_id_and_ref (ACEXML_Char *&publicId, if (this->parse_token (ACE_TEXT ("YSTEM")) < 0 || this->skip_whitespace_count () == 0) { - this->report_fatal_error(ACE_TEXT("Expecting keyword 'SYSTEM'") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ESYSTEM ACEXML_ENV_ARG_PARAMETER); return -1; } if (this->get_quoted_string (systemId) != 0) { - this->report_fatal_error(ACE_TEXT("Error while parsing SYSTEM literal for SYSTEM id.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ELITERAL ACEXML_ENV_ARG_PARAMETER); return -1; } this->locator_.setSystemId (systemId); @@ -1604,12 +1614,12 @@ ACEXML_Parser::parse_external_id_and_ref (ACEXML_Char *&publicId, if (this->parse_token (ACE_TEXT ("UBLIC")) < 0 || this->skip_whitespace_count () == 0) { - this->report_fatal_error(ACE_TEXT("Expecting keyword 'PUBLIC'") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EPUBLIC ACEXML_ENV_ARG_PARAMETER); return -1; } if (this->get_quoted_string (publicId) != 0) { - this->report_fatal_error(ACE_TEXT("Error while parsing public literal for PUBLIC id.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ELITERAL ACEXML_ENV_ARG_PARAMETER); return -1; } this->locator_.setPublicId (publicId); @@ -1619,14 +1629,15 @@ ACEXML_Parser::parse_external_id_and_ref (ACEXML_Char *&publicId, { if (this->get_quoted_string (systemId) != 0) { - this->report_fatal_error(ACE_TEXT("Error while parsing system literal for PUBLIC id.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ELITERAL + ACEXML_ENV_ARG_PARAMETER); return -1; } this->locator_.setSystemId (systemId); } break; default: - this->report_fatal_error(ACE_TEXT("Expecting either keyword `SYSTEM' or `PUBLIC'.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ESYSPUB ACEXML_ENV_ARG_PARAMETER); return -1; } return 0; @@ -1646,7 +1657,7 @@ ACEXML_Parser::parse_children_definition (ACEXML_ENV_SINGLE_ARG_DECL) case '#': // Mixed element, if (this->parse_token (ACE_TEXT ("#PCDATA")) < 0) { - this->report_fatal_error(ACE_TEXT("Expecting keyword `#PCDATA' while defining an element.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EPCDATA ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -1656,7 +1667,7 @@ ACEXML_Parser::parse_children_definition (ACEXML_ENV_SINGLE_ARG_DECL) { if (this->get () != '|') { - this->report_fatal_error(ACE_TEXT("Expecting end of Mixed section while defining an element.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_EMIXED ACEXML_ENV_ARG_PARAMETER); return -1; } this->skip_whitespace_count (); @@ -1672,7 +1683,7 @@ ACEXML_Parser::parse_children_definition (ACEXML_ENV_SINGLE_ARG_DECL) if (this->get () != ')' || (subelement_number && this->get () != '*')) { - this->report_fatal_error(ACE_TEXT("Expecting closing `)*' or ')' while defining an element.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ERPAREN ACEXML_ENV_ARG_PARAMETER); return -1; } // @@ close the element definition in the validator. @@ -1694,7 +1705,7 @@ ACEXML_Parser::parse_child (int skip_open_paren ACEXML_ENV_ARG_DECL) if (skip_open_paren == 0 && this->get () != '(') { - this->report_fatal_error(ACE_TEXT("Expecting opening `(' while defining an element.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_LPAREN ACEXML_ENV_ARG_PARAMETER); return -1; } @@ -1714,7 +1725,7 @@ ACEXML_Parser::parse_child (int skip_open_paren ACEXML_ENV_ARG_DECL) ACEXML_Char *subelement = this->read_name (); if (subelement == 0) { - this->report_fatal_error(ACE_TEXT("Error reading sub-element name while defining an element.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ESUBELE ACEXML_ENV_ARG_PARAMETER); return -1; } // @@ Inform validator of the new element here. @@ -1734,7 +1745,7 @@ ACEXML_Parser::parse_child (int skip_open_paren ACEXML_ENV_ARG_DECL) case '|': break; default: - this->report_fatal_error(ACE_TEXT("Expecting `,', `|', or `)' while defining an element.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ECHOICE ACEXML_ENV_ARG_PARAMETER); return -1; } break; @@ -1748,13 +1759,13 @@ ACEXML_Parser::parse_child (int skip_open_paren ACEXML_ENV_ARG_DECL) case ',': break; default: - this->report_fatal_error(ACE_TEXT("Expecting `,', `|', or `)'while defining an element.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ECHOICE ACEXML_ENV_ARG_PARAMETER); return -1; } case ')': break; default: - this->report_fatal_error(ACE_TEXT("Expecting `,', `|', or `)' while defining an element.") ACEXML_ENV_ARG_PARAMETER); + this->report_fatal_error(ACEXML_ECHOICE ACEXML_ENV_ARG_PARAMETER); return -1; } this->get (); // consume , | or ) @@ -1830,9 +1841,7 @@ ACEXML_Parser::parse_token (const ACEXML_Char* keyword) const ACEXML_Char* ptr = keyword; ACEXML_Char ch; for (; *ptr != 0 && ((ch = this->get()) == *ptr); ++ptr) - { - // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ch = %c : ptr = %c"), ch, *ptr)); - } + ; if (*ptr == 0) return 0; else @@ -1871,7 +1880,6 @@ ACEXML_Parser::get_quoted_string (ACEXML_Char *&str) const ACEXML_String *replace = 0; ACEXML_String charval; ACEXML_Char buffer[6]; - size_t i = 0; switch (ch) { @@ -1880,8 +1888,9 @@ ACEXML_Parser::get_quoted_string (ACEXML_Char *&str) { if (this->parse_char_reference (buffer, 6) != 0) { -// xmlenv.exception (new ACEXML_SAXParseException -// (ACE_TEXT ("CharRef does not resolves to a valid character"))); + // [WFC: Legal Character] + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Invalid character reference\n"))); return -1; } charval.set (buffer, 0); @@ -1892,11 +1901,10 @@ ACEXML_Parser::get_quoted_string (ACEXML_Char *&str) if (replace == 0) { - // xmlenv.exception (new ACEXML_SAXParseException - // (ACE_TEXT ("Undefined reference"))); + ACE_ERROR ((LM_ERROR, ACE_TEXT ("Undefined reference\n"))); return -1; } - for (i = 0; i < replace->length (); ++i) + for (size_t i = 0; i < replace->length (); ++i) this->obstack_.grow ((*replace)[i]); // handle reference here. break; diff --git a/ACEXML/parser/parser/Parser.dsp b/ACEXML/parser/parser/Parser.dsp index 838bc6d306d..76a8f3f5ad8 100644 --- a/ACEXML/parser/parser/Parser.dsp +++ b/ACEXML/parser/parser/Parser.dsp @@ -116,6 +116,10 @@ SOURCE=.\Parser.h SOURCE=.\Parser_export.h
# End Source File
+# Begin Source File
+
+SOURCE=.\ParserErrors.h
+# End Source File
# End Group
# Begin Group "Resource Files"
diff --git a/ACEXML/parser/parser/Parser.h b/ACEXML/parser/parser/Parser.h index e45e290ca79..f84ac2986d8 100644 --- a/ACEXML/parser/parser/Parser.h +++ b/ACEXML/parser/parser/Parser.h @@ -31,6 +31,7 @@ #include "ace/Containers_T.h" #include "ace/Auto_Ptr.h" #include "ACEXML/parser/parser/Entity_Manager.h" +#include "ACEXML/parser/parser/ParserErrors.h" /** * @class ACEXML_Parser Parser.h "ACEXML/parser/parser/Parser.h" @@ -387,15 +388,6 @@ protected: /// Peek a character. ACEXML_Char peek (void); - /** - * Check if more data can be added to a character buffer in obstack. - * If not, the existing data in the buffer will be cleared out by - * freezing the segment and pass it out thru a content_handler_->characters () - * call. @a counter records the length of the existing data in - * obstack. - */ - int try_grow_cdata (size_t size, size_t &len ACEXML_ENV_ARG_DECL); - // Feature names: /** @@ -440,19 +432,19 @@ private: * Dispatch errors to ErrorHandler. * */ - void report_error (const ACEXML_Char* message ACEXML_ENV_ARG_DECL); + void report_error (ACEXML_Error minor_code ACEXML_ENV_ARG_DECL); /** * Dispatch warnings to ErrorHandler. * */ - void report_warning (const ACEXML_Char* message ACEXML_ENV_ARG_DECL); + void report_warning (ACEXML_Error minor_code ACEXML_ENV_ARG_DECL); /** * Dispatch fatal errors to ErrorHandler. * */ - void report_fatal_error (const ACEXML_Char* message ACEXML_ENV_ARG_DECL); + void report_fatal_error (ACEXML_Error minor_code ACEXML_ENV_ARG_DECL); /** * Dispatch prefix mapping calls to the ContentHandler. @@ -500,6 +492,9 @@ private: // Locator ACEXML_LocatorImpl locator_; + // Flag set if the document is a standalone XML document + int standalone_; + // Feature flags & int simple_parsing_; int namespaces_; diff --git a/ACEXML/parser/parser/ParserErrors.h b/ACEXML/parser/parser/ParserErrors.h new file mode 100644 index 00000000000..6bb3435139a --- /dev/null +++ b/ACEXML/parser/parser/ParserErrors.h @@ -0,0 +1,93 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ParserErrors.h + * + * $Id$ + * + * @author Krishnakumar B <kitty@cs.wustl.edu> + */ +//============================================================================= + +#ifndef _ACEXML_PARSER_ERRORS_H_ +#define _ACEXML_PARSER_ERRORS_H_ + +#include "ace/pre.h" +#include "ACEXML/parser/parser/Parser_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +enum ACEXML_Error { + ACEXML_INVIP, + ACEXML_LESS, + ACEXML_GREAT, + ACEXML_INVCO, + ACEXML_DUPDOC, + ACEXML_EOF, + ACEXML_INVXMLDECL, + ACEXML_INVVERSION, + ACEXML_ENOTSUP, + ACEXML_ENCMISMATCH, + ACEXML_EINT, + ACEXML_INVPI, + ACEXML_INVDOCKEYWORD, + ACEXML_INVDOCNAME, + ACEXML_MISSINGROOT, + ACEXML_RDATTR, + ACEXML_DUPPREFIX, + ACEXML_DUPATTR, + ACEXML_NSERR, + ACEXML_ECHAR, + ACEXML_ETAG, + ACEXML_ECDATASEC, + ACEXML_MKDECLKEYWORD, + ACEXML_MKINVCH, + ACEXML_MKDECL, + ACEXML_EELEMENT, + ACEXML_ERDELENAME, + ACEXML_EEMPTY, + ACEXML_EANY, + ACEXML_ERDELE, + ACEXML_EENTITY, + ACEXML_INVREF, + ACEXML_ENTNAME, + ACEXML_ENTVALUE, + ACEXML_DUPENT, + ACEXML_INVEXTID, + ACEXML_UNDATA, + ACEXML_ENDATA, + ACEXML_EATTLIST, + ACEXML_EATTNAME, + ACEXML_ECDATA, + ACEXML_EID, + ACEXML_EENTITIES, + ACEXML_ENMTOKEN, + ACEXML_ENMTOKENS, + ACEXML_ENOTATION, + ACEXML_LPAREN, + ACEXML_ENOTNAME, + ACEXML_ENMNAME, + ACEXML_INVATTRTYPE, + ACEXML_EREQUIRED, + ACEXML_EIMPLIED, + ACEXML_EFIXED, + ACEXML_EINVFIXED, + ACEXML_INVNOTNAME, + ACEXML_ESYSTEM, + ACEXML_EPUBLIC, + ACEXML_ELITERAL, + ACEXML_ESYSPUB, + ACEXML_EPCDATA, + ACEXML_EMIXED, + ACEXML_ERPAREN, + ACEXML_ESUBELE, + ACEXML_ECHOICE, + ACEXML_INVCHAR +}; + +#include "ace/post.h" + +#endif /* _ACEXML_PARSER_ERRORS_H_ */ diff --git a/ChangeLog b/ChangeLog index 63a8902a892..1b9d74cd763 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,45 @@ +Wed Oct 23 17:27:14 2002 Krishnakumar B <kitty@cs.wustl.edu> + + * ACEXML/common/Encoding.cpp: + * ACEXML/common/Encoding.h: + + Use UTF-16 instead of UTF-16LE/UTF-16BE as the specification + doesn't require mentioning the endianness of the input. + + * ACEXML/common/Transcode.h: Fixed some minor typos. + + * ACEXML/examples/SAXPrint/namespaces.xml: New file which tests + out the namespaces feature much better. + + * ACEXML/apps/svcconf/Makefile: + * ACEXML/parser/parser/Makefile: + + Updated dependencies. + + * ACEXML/parser/parser/ParserErrors.h: New file which contains the + error codes of all the error spit out by the parser. + + * ACEXML/examples/SAXPrint/Print_Handler.cpp: + * ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp: + + Make sure that the characters() function describes the arguments + as start and length instead of start and end. + + * ACEXML/parser/parser/Parser.dsp: Added ParserErrors.h to the + project file. + + * ACEXML/parser/parser/Parser.cpp: + * ACEXML/parser/parser/Parser.h: + + Use minor codes when reporting error in the parser. This cleans + up a lot of repeated error messages and indenting so that we + don't need to spill over 80 columns and have a standardized way + of reporting errors. Rewrote parse_cdata() so that is is much + simpler. Removed try_grow_cdata() as it is no longer needed. + Handle the case when the parser was accepting invalid character + references(). + + Wed Oct 23 17:20:18 UTC 2002 Don Hinton <dhinton@ieee.org> * ace/Service_Object.{h,cpp} (suspend, resume, fini): @@ -6,11 +48,11 @@ Wed Oct 23 17:20:18 UTC 2002 Don Hinton <dhinton@ieee.org> propagated. * ace/Service_Repository.cpp (suspend, resume, fini): - Changed to propagate the return value from the + Changed to propagate the return value from the ACE_Service_Type instead of always 0. Tue Oct 22 16:26:56 2002 Rich Seibel <seibel_r@ociweb.com> - + * ace/Basic_Types.h: Added a test for _BYTE_ORDER, same as BYTE_ORDER and __BYTE_ORDER. VxWorks defines this. Also note, compilers diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a index 63a8902a892..1b9d74cd763 100644 --- a/ChangeLogs/ChangeLog-03a +++ b/ChangeLogs/ChangeLog-03a @@ -1,3 +1,45 @@ +Wed Oct 23 17:27:14 2002 Krishnakumar B <kitty@cs.wustl.edu> + + * ACEXML/common/Encoding.cpp: + * ACEXML/common/Encoding.h: + + Use UTF-16 instead of UTF-16LE/UTF-16BE as the specification + doesn't require mentioning the endianness of the input. + + * ACEXML/common/Transcode.h: Fixed some minor typos. + + * ACEXML/examples/SAXPrint/namespaces.xml: New file which tests + out the namespaces feature much better. + + * ACEXML/apps/svcconf/Makefile: + * ACEXML/parser/parser/Makefile: + + Updated dependencies. + + * ACEXML/parser/parser/ParserErrors.h: New file which contains the + error codes of all the error spit out by the parser. + + * ACEXML/examples/SAXPrint/Print_Handler.cpp: + * ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp: + + Make sure that the characters() function describes the arguments + as start and length instead of start and end. + + * ACEXML/parser/parser/Parser.dsp: Added ParserErrors.h to the + project file. + + * ACEXML/parser/parser/Parser.cpp: + * ACEXML/parser/parser/Parser.h: + + Use minor codes when reporting error in the parser. This cleans + up a lot of repeated error messages and indenting so that we + don't need to spill over 80 columns and have a standardized way + of reporting errors. Rewrote parse_cdata() so that is is much + simpler. Removed try_grow_cdata() as it is no longer needed. + Handle the case when the parser was accepting invalid character + references(). + + Wed Oct 23 17:20:18 UTC 2002 Don Hinton <dhinton@ieee.org> * ace/Service_Object.{h,cpp} (suspend, resume, fini): @@ -6,11 +48,11 @@ Wed Oct 23 17:20:18 UTC 2002 Don Hinton <dhinton@ieee.org> propagated. * ace/Service_Repository.cpp (suspend, resume, fini): - Changed to propagate the return value from the + Changed to propagate the return value from the ACE_Service_Type instead of always 0. Tue Oct 22 16:26:56 2002 Rich Seibel <seibel_r@ociweb.com> - + * ace/Basic_Types.h: Added a test for _BYTE_ORDER, same as BYTE_ORDER and __BYTE_ORDER. VxWorks defines this. Also note, compilers |