summaryrefslogtreecommitdiff
path: root/ACE/ACEXML
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/ACEXML')
-rw-r--r--ACE/ACEXML/ACEXML.mwc5
-rw-r--r--ACE/ACEXML/ChangeLog980
-rw-r--r--ACE/ACEXML/Makefile.am17
-rw-r--r--ACE/ACEXML/README17
-rw-r--r--ACE/ACEXML/apps/Makefile.am13
-rw-r--r--ACE/ACEXML/apps/svcconf/ACEXML_XML_Svc_Conf_Parser.pc.in11
-rw-r--r--ACE/ACEXML/apps/svcconf/Makefile.am55
-rw-r--r--ACE/ACEXML/apps/svcconf/README4
-rw-r--r--ACE/ACEXML/apps/svcconf/Svcconf.cpp120
-rw-r--r--ACE/ACEXML/apps/svcconf/Svcconf.h44
-rw-r--r--ACE/ACEXML/apps/svcconf/Svcconf_Handler.cpp771
-rw-r--r--ACE/ACEXML/apps/svcconf/Svcconf_Handler.h292
-rw-r--r--ACE/ACEXML/apps/svcconf/Svcconf_Handler.i133
-rw-r--r--ACE/ACEXML/apps/svcconf/svcconf.dtd60
-rw-r--r--ACE/ACEXML/apps/svcconf/svcconf.mpc6
-rw-r--r--ACE/ACEXML/common/ACEXML.pc.in11
-rw-r--r--ACE/ACEXML/common/ACEXML_Export.h49
-rw-r--r--ACE/ACEXML/common/Attributes.cpp11
-rw-r--r--ACE/ACEXML/common/Attributes.h130
-rw-r--r--ACE/ACEXML/common/AttributesImpl.cpp293
-rw-r--r--ACE/ACEXML/common/AttributesImpl.h309
-rw-r--r--ACE/ACEXML/common/AttributesImpl.i154
-rw-r--r--ACE/ACEXML/common/Attributes_Def_Builder.cpp14
-rw-r--r--ACE/ACEXML/common/Attributes_Def_Builder.h153
-rw-r--r--ACE/ACEXML/common/CharStream.cpp7
-rw-r--r--ACE/ACEXML/common/CharStream.h88
-rw-r--r--ACE/ACEXML/common/ContentHandler.cpp11
-rw-r--r--ACE/ACEXML/common/ContentHandler.h131
-rw-r--r--ACE/ACEXML/common/DTDHandler.cpp11
-rw-r--r--ACE/ACEXML/common/DTDHandler.h78
-rw-r--r--ACE/ACEXML/common/DTD_Manager.cpp8
-rw-r--r--ACE/ACEXML/common/DTD_Manager.h82
-rw-r--r--ACE/ACEXML/common/DefaultHandler.cpp159
-rw-r--r--ACE/ACEXML/common/DefaultHandler.h191
-rw-r--r--ACE/ACEXML/common/Element_Def_Builder.cpp9
-rw-r--r--ACE/ACEXML/common/Element_Def_Builder.h133
-rw-r--r--ACE/ACEXML/common/Encoding.cpp59
-rw-r--r--ACE/ACEXML/common/Encoding.h61
-rw-r--r--ACE/ACEXML/common/EntityResolver.cpp11
-rw-r--r--ACE/ACEXML/common/EntityResolver.h61
-rw-r--r--ACE/ACEXML/common/Env.cpp34
-rw-r--r--ACE/ACEXML/common/Env.h72
-rw-r--r--ACE/ACEXML/common/Env.i25
-rw-r--r--ACE/ACEXML/common/ErrorHandler.cpp11
-rw-r--r--ACE/ACEXML/common/ErrorHandler.h75
-rw-r--r--ACE/ACEXML/common/Exception.cpp36
-rw-r--r--ACE/ACEXML/common/Exception.h87
-rw-r--r--ACE/ACEXML/common/Exception.i13
-rw-r--r--ACE/ACEXML/common/FileCharStream.cpp255
-rw-r--r--ACE/ACEXML/common/FileCharStream.h130
-rw-r--r--ACE/ACEXML/common/HttpCharStream.cpp464
-rw-r--r--ACE/ACEXML/common/HttpCharStream.h140
-rw-r--r--ACE/ACEXML/common/InputSource.cpp106
-rw-r--r--ACE/ACEXML/common/InputSource.h131
-rw-r--r--ACE/ACEXML/common/Locator.cpp11
-rw-r--r--ACE/ACEXML/common/Locator.h74
-rw-r--r--ACE/ACEXML/common/LocatorImpl.cpp49
-rw-r--r--ACE/ACEXML/common/LocatorImpl.h159
-rw-r--r--ACE/ACEXML/common/LocatorImpl.i65
-rw-r--r--ACE/ACEXML/common/Makefile.am135
-rw-r--r--ACE/ACEXML/common/Mem_Map_Stream.cpp264
-rw-r--r--ACE/ACEXML/common/Mem_Map_Stream.h191
-rw-r--r--ACE/ACEXML/common/NamespaceSupport.cpp247
-rw-r--r--ACE/ACEXML/common/NamespaceSupport.h235
-rw-r--r--ACE/ACEXML/common/SAXExceptions.cpp261
-rw-r--r--ACE/ACEXML/common/SAXExceptions.h208
-rw-r--r--ACE/ACEXML/common/SAXExceptions.i57
-rw-r--r--ACE/ACEXML/common/StrCharStream.cpp129
-rw-r--r--ACE/ACEXML/common/StrCharStream.h102
-rw-r--r--ACE/ACEXML/common/StreamFactory.cpp56
-rw-r--r--ACE/ACEXML/common/StreamFactory.h58
-rw-r--r--ACE/ACEXML/common/Transcode.cpp311
-rw-r--r--ACE/ACEXML/common/Transcode.h172
-rw-r--r--ACE/ACEXML/common/URL_Addr.cpp177
-rw-r--r--ACE/ACEXML/common/URL_Addr.h135
-rw-r--r--ACE/ACEXML/common/URL_Addr.inl65
-rw-r--r--ACE/ACEXML/common/Validator.cpp8
-rw-r--r--ACE/ACEXML/common/Validator.h64
-rw-r--r--ACE/ACEXML/common/XMLFilter.h56
-rw-r--r--ACE/ACEXML/common/XMLFilterImpl.cpp339
-rw-r--r--ACE/ACEXML/common/XMLFilterImpl.h294
-rw-r--r--ACE/ACEXML/common/XMLFilterImpl.i14
-rw-r--r--ACE/ACEXML/common/XMLReader.cpp11
-rw-r--r--ACE/ACEXML/common/XMLReader.h136
-rw-r--r--ACE/ACEXML/common/XML_Codecs.cpp94
-rw-r--r--ACE/ACEXML/common/XML_Codecs.h73
-rw-r--r--ACE/ACEXML/common/XML_Macros.h443
-rw-r--r--ACE/ACEXML/common/XML_Types.h83
-rw-r--r--ACE/ACEXML/common/XML_Util.cpp46
-rw-r--r--ACE/ACEXML/common/XML_Util.h33
-rw-r--r--ACE/ACEXML/common/ZipCharStream.cpp255
-rw-r--r--ACE/ACEXML/common/ZipCharStream.h144
-rw-r--r--ACE/ACEXML/common/codecs.mpb8
-rw-r--r--ACE/ACEXML/common/common.mpc33
-rw-r--r--ACE/ACEXML/docs/TODO.txt17
-rw-r--r--ACE/ACEXML/docs/bugs.txt17
-rw-r--r--ACE/ACEXML/docs/guidelines.txt39
-rw-r--r--ACE/ACEXML/docs/parser_features.txt25
-rw-r--r--ACE/ACEXML/docs/readme.txt36
-rw-r--r--ACE/ACEXML/examples/Makefile.am13
-rw-r--r--ACE/ACEXML/examples/SAXPrint/Makefile.am48
-rw-r--r--ACE/ACEXML/examples/SAXPrint/Print_Handler.cpp254
-rw-r--r--ACE/ACEXML/examples/SAXPrint/Print_Handler.h187
-rw-r--r--ACE/ACEXML/examples/SAXPrint/SAXPrint.mpc6
-rw-r--r--ACE/ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp244
-rw-r--r--ACE/ACEXML/examples/SAXPrint/SAXPrint_Handler.h195
-rw-r--r--ACE/ACEXML/examples/SAXPrint/SAXPrint_Handler.i13
-rw-r--r--ACE/ACEXML/examples/SAXPrint/broken.xml5
-rw-r--r--ACE/ACEXML/examples/SAXPrint/main.cpp206
-rw-r--r--ACE/ACEXML/examples/SAXPrint/namespaces.xml95
-rw-r--r--ACE/ACEXML/examples/SAXPrint/ns.svc.conf.xml46
-rw-r--r--ACE/ACEXML/examples/SAXPrint/simple.svcconf.xml38
-rw-r--r--ACE/ACEXML/examples/SAXPrint/svc.conf.xml58
-rw-r--r--ACE/ACEXML/parser/Makefile.am13
-rw-r--r--ACE/ACEXML/parser/debug_validator/Debug_Attributes_Builder.cpp215
-rw-r--r--ACE/ACEXML/parser/debug_validator/Debug_Attributes_Builder.h170
-rw-r--r--ACE/ACEXML/parser/debug_validator/Debug_DTD_Manager.cpp71
-rw-r--r--ACE/ACEXML/parser/debug_validator/Debug_DTD_Manager.h76
-rw-r--r--ACE/ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h38
-rw-r--r--ACE/ACEXML/parser/debug_validator/Debug_Element_Builder.cpp148
-rw-r--r--ACE/ACEXML/parser/debug_validator/Debug_Element_Builder.h127
-rw-r--r--ACE/ACEXML/parser/debug_validator/Element_Tree.cpp72
-rw-r--r--ACE/ACEXML/parser/debug_validator/Element_Tree.h160
-rw-r--r--ACE/ACEXML/parser/debug_validator/Element_Tree.i92
-rw-r--r--ACE/ACEXML/parser/parser/ACEXML_Parser.pc.in11
-rw-r--r--ACE/ACEXML/parser/parser/Entity_Manager.cpp20
-rw-r--r--ACE/ACEXML/parser/parser/Entity_Manager.h100
-rw-r--r--ACE/ACEXML/parser/parser/Entity_Manager.i66
-rw-r--r--ACE/ACEXML/parser/parser/Makefile.am73
-rw-r--r--ACE/ACEXML/parser/parser/Parser.cpp3397
-rw-r--r--ACE/ACEXML/parser/parser/Parser.h904
-rw-r--r--ACE/ACEXML/parser/parser/Parser.i257
-rw-r--r--ACE/ACEXML/parser/parser/ParserContext.cpp16
-rw-r--r--ACE/ACEXML/parser/parser/ParserContext.h85
-rw-r--r--ACE/ACEXML/parser/parser/ParserContext.inl76
-rw-r--r--ACE/ACEXML/parser/parser/ParserInternals.cpp394
-rw-r--r--ACE/ACEXML/parser/parser/ParserInternals.h104
-rw-r--r--ACE/ACEXML/parser/parser/Parser_export.h47
-rw-r--r--ACE/ACEXML/parser/parser/parser.mpc14
-rw-r--r--ACE/ACEXML/tests/ContentHandler_Test.cpp103
-rw-r--r--ACE/ACEXML/tests/HttpCharStream_Test.cpp40
-rw-r--r--ACE/ACEXML/tests/Makefile.am114
-rw-r--r--ACE/ACEXML/tests/NamespaceSupport_Test.cpp150
-rw-r--r--ACE/ACEXML/tests/Transcoder_Test.cpp71
-rw-r--r--ACE/ACEXML/tests/tests.mpc30
-rw-r--r--ACE/ACEXML/tests/util/Makefile.am43
-rw-r--r--ACE/ACEXML/tests/util/test.cpp111
-rw-r--r--ACE/ACEXML/tests/util/util.mpc4
148 files changed, 20580 insertions, 0 deletions
diff --git a/ACE/ACEXML/ACEXML.mwc b/ACE/ACEXML/ACEXML.mwc
new file mode 100644
index 00000000000..dd297256b34
--- /dev/null
+++ b/ACE/ACEXML/ACEXML.mwc
@@ -0,0 +1,5 @@
+// -*- MPC -*-
+// $Id$
+
+workspace {
+}
diff --git a/ACE/ACEXML/ChangeLog b/ACE/ACEXML/ChangeLog
new file mode 100644
index 00000000000..2bce4374135
--- /dev/null
+++ b/ACE/ACEXML/ChangeLog
@@ -0,0 +1,980 @@
+Tue Jun 20 08:23:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * ACEXML/parser/parser/Parser.cpp:
+ 64bit fix
+
+Thu Mar 30 13:14:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * common/NamespaceSupport.cpp:
+ Fixed value might be unitialized warnings
+
+Tue Mar 14 20:58:12 UTC 2006 jiang,shanshan <shanshan.jiang@vanderbilt.edu>
+
+ * ACEXML/common/FileCharStream.cpp
+ * ACEXML/common/HttpCharStream.cpp
+ * ACEXML/common/Transcode.cpp
+ * ACEXML/common/XML_Macros.h
+ * ACEXML/parser/parser/Parser.cpp
+ * ACEXML/parser/parser/Parser.i
+ Updated these files to solve the warnings when setting up "VC level 4 warnings"
+ on Windows. These warnings include "unreachable code", "assignment within
+ conditional expression", "conversion from some type to another type, possible
+ loss of data", "local variable may be used without having been initialized" and
+ so on.
+ Thanks to Lukas Gruetzmacher <gruetzmacher at ais-dresden dot de> for
+ motivating the fix to these "VC level 4 warnings".
+
+Fri Feb 10 23:45:14 UTC 2006 Steve Huston <shuston@riverace.com>
+
+ * common/NamespaceSupport.cpp: Add missing template instantiations to
+ match change below.
+
+Fri Feb 10 12:22:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * common/NamespaceSupport.cpp:
+ Fixed compile error in unicode build
+
+Thu Feb 9 22:49:18 UTC 2006 Krishnakumar B <kitty@nospam.invalid.domain>
+
+ * common/NamespaceSupport.h:
+ * common/NamespaceSupport.cpp: Use a normal ACE_Unbounded_Stack
+ instead of yet another custom stack.
+
+ * parser/parser/Parser.h:
+ * parser/parser/Parser.cpp:
+
+ Fixed a mismatched push/pop of the namespace context due to
+ popping namespace contexts without matching the end of the
+ element that caused a push. This resulted in more pops that
+ push and corrupting the memory. Also fixed an indirection into
+ a pointer that might have been corrupt when calling
+ startNamespacePrefix().
+
+Tue Jan 24 23:09:08 UTC 2006 Krishnakumar B <kitty@nospam.invalid.domain>
+
+ * apps/svcconf/Svcconf.cpp:
+ * apps/svcconf/Svcconf.h:
+
+ Removed the overridden operator new/delete. I don't think that
+ they serve any purpose, and end up hiding the default variations.
+
+Mon Jan 23 14:11:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * common/ZipCharStream.h:
+ Updated include of zziplib.h to zzip/zzip.h to get rid of deprecated
+ warnings
+
+Wed Jan 4 22:44:38 UTC 2006 J.T. Conklin <jtc@acorntoolworks.com>
+
+ * ChangeLog:
+
+ Untabify.
+ Delete-trailing-whitespace.
+
+ Changed "add-log-time-format" to a really ugly lambda expression
+ that formats changelog timestamps in UTC and works with both GNU
+ Emacs and XEmacs.
+
+Thu May 26 07:35:12 UTC 2005 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * common/XML_Util.h:
+ Fixed pragma once warning
+
+Tue May 24 18:39:02 2005 J.T. Conklin <jtc@acorntoolworks.com>
+
+ * common/Makefile.am:
+
+ Regenerate.
+
+ * common/common.mpc:
+
+ Added XML_Util.h to Header_Files section.
+
+Tue May 24 09:18:34 2005 Justin Michel <michel_j@ociweb.com>
+
+ * tests/util/test.cpp:
+
+ Fixed for loop scoping problem for non-standard compilers.
+
+Mon May 23 14:52:19 2005 Justin Michel <michel_j@ociweb.com>
+
+ * tests/util/util.mpc:
+
+ Add missing $ Id tag.
+
+Mon May 23 13:02:25 2005 Justin Michel <michel_j@ociweb.com>
+
+ * common/XML_Util.h:
+ * common/XML_Util.cpp:
+
+ Added new ACEXML_escape_string() functions to allow replacement of
+ illegal characters, (', ", &, <, >, etc.) with the escaped versions.
+ (&quot;, &lt;, etc.)
+
+ * tests/util/test.cpp:
+ * tests/util/util.mpc:
+
+ This is a performance test used while making the above functions, and
+ testing performance with ACE_String_Base.
+
+Fri Apr 22 21:34:19 2005 Ossama Othman <ossama@dre.vanderbilt.edu>
+
+ * parser/parser/Parser.cpp (parse_entity_decl):
+
+ Fixed "variable may be used uninitialized" warning.
+
+Fri Apr 22 11:09:59 2005 J.T. Conklin <jtc@acorntoolworks.com>
+
+ * parser/parser/Makefile.am:
+ * common/Makefile.am:
+
+ Regenerated.
+
+ * parser/parser/parser.mpc:
+ * common/common.mpc:
+
+ Add Pkgconfig_Files section.
+
+Wed Apr 20 12:20:26 2005 Ossama Othman <ossama@dre.vanderbilt.edu>
+
+ * common/Attributes.h:
+ * common/ContentHandler.h:
+ * common/DTDHandler.h:
+ * common/EntityResolver.h:
+ * common/ErrorHandler.h:
+ * common/Locator.h:
+ * common/XMLReader.h:
+
+ Added virtual destructors to address g++ 4.0 warnings.
+
+ * common/Attributes.cpp:
+ * common/ContentHandler.cpp:
+ * common/DTDHandler.cpp:
+ * common/EntityResolver.cpp:
+ * common/ErrorHandler.cpp:
+ * common/Locator.cpp:
+ * common/XMLReader.cpp:
+
+ New files containing destructors.
+
+ * common/NamespaceSupport.cpp (getURI):
+
+ Fixed "variable may be used uninitialized" warning.
+
+Mon Apr 18 14:10:12 UTC 2005 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * parser/parser/Entity_Manager.cpp:
+ Removed not uses static const
+
+ * parser/parser/Entity_Manager.i:
+ Initialise pointer with 0
+
+Sun Feb 13 23:54:25 2005 Ossama Othman <ossama@dre.vanderbilt.edu>
+
+ From Lothar Werzinger <lothar at xcerla dot com>
+ * apps/svcconf/Svcconf_Handler.cpp:
+
+ Enhanced error messages.
+
+Wed Jan 5 14:08:12 UTC 2004 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * common/DefaultHandler.{h,cpp,i}:
+ * common/NamespaceSupport.{h,cpp,i}:
+ * common/Transcode.{h,cpp,i}:
+ * examples/SAXPrint/Print_Handler.{cpp,i}:
+ Removed .i file and updated h/cpp file
+
+ * common/Makefile.am:
+ Updated
+
+Tue Aug 17 19:07:11 2004 J.T. Conklin <jtc@acorntoolworks.com>
+
+ * common/NamespaceSupport.cpp:
+
+ Changed ACE_NEW_RETURN to use "NS_Node_T" instead of "struct
+ NS_Node_T" --- the latter triggers a gcc 3.3 parser bug when
+ used with the "new (std::nothrow)" version of ACE_NEW_RETURN.
+ Fortunately, the "struct" is unnecessary.
+
+Sat Feb 21 23:51:25 2004 . <.@isis.vanderbilt.edu>
+
+ * common/Exception.h:
+ * common/Exception.cpp:
+ * common/SAXExceptions.h:
+ * common/SAXExceptions.cpp:
+
+ Fixed a few bugs in the way the exceptions were set-up in the
+ case when exceptions=0. Provided implementations for operator
+ assignment and duplicate(). This should fix problems with
+ throwing and catching exceptions when exceptions=0.
+
+Sat Jan 31 20:06:57 2004 Krishnakumar B <kitty@cse.wustl.edu>
+
+ * parser/parser/Parser.cpp (parse_PE_reference): Added ACE_TEXT
+ to satisfy WCHAR windows builds. Thanks to Johnny for reporting
+ these errors.
+
+Fri Jan 30 16:04:43 2004 Krishnakumar B <kitty@cse.wustl.edu>
+
+ * parser/parser/Parser.cpp: Rewrote a simple string manipulation
+ involving ACE_String_Base<char>::operator +() to use const char*
+ instead of char, so that we don't need an explicit template
+ instantiation for it.
+
+ * examples/SAXPrint/main.cpp: Added missing explicit template
+ instantiations for ACE_Auto_Basic_Ptr.
+
+ Thanks to Olli Savia <ops@iki.fi> for reporting problems with
+ explicit template instantiation on LynxOS.
+
+Thu Jan 8 18:40:34 2004 Krishnakumar B <kitty@nospam.invalid.domain>
+
+
+ * common/CharStream.h: Added a new rewind() method so that we can
+ reuse the same parser instance to parse the same file multiple
+ times.
+
+ * common/FileCharStream.cpp:
+ * common/HttpCharStream.h:
+ * common/HttpCharStream.cpp:
+ * common/StrCharStream.cpp:
+ * common/ZipCharStream.cpp:
+
+ Fixed implementation of rewind().
+
+ * common/Mem_Map_Stream.cpp:
+
+ Fixed memory leak caused by the Svc_Handler not getting deleted.
+
+ * apps/svcconf/Makefile.ACEXML_XML_Svc_Conf_Parser:
+ * parser/parser/Makefile.ACEXML_Parser:
+ * examples/SAXPrint/Makefile.SAXPrint:
+ * common/Makefile.ACEXML:
+ * tests/Makefile.ContentHandler_Test:
+ * tests/Makefile.HttpCharStream_Test:
+ * tests/Makefile.NamespaceSupport_Test:
+ * tests/Makefile.Transcoder_Test:
+
+ Updated dependencies.
+
+ * examples/SAXPrint/main.cpp:
+
+ Added code to test the parser to parse the same file multiple
+ times. This still needs some cleaning.
+
+ * parser/parser/Entity_Manager.h:
+ * parser/parser/Entity_Manager.i:
+ * parser/parser/Entity_Manager.cpp:
+
+ Use a pointer to ACE_Hash_Map_Manager_Ex and delete it on every
+ reset() of the Entity_Manager. This should fix all the problems
+ with SIGFPE's when we try to recover from a parse error.
+
+ * parser/parser/Parser.cpp:
+ * parser/parser/ParserContext.h:
+ * parser/parser/ParserContext.inl:
+
+ Fixed memory leaks reported by Ken Sedgewick <ken@bonsai.com>.
+ This should fix Bugzill bug 1694. While at it, fix bugs in
+ handling of entity references in INCLUDE/IGNORE sections,
+ ATTLIST sections.
+
+
+Thu Dec 18 13:13:57 2003 Krishnakumar B <kitty@nospam.invalid.domain>
+
+ * common/Transcode.h (ACEXML_Transcoder):
+ * common/Transcode.cpp (ACEXML_Transcoder):
+
+ Renamed the ACEXML_Transcoder::STATUS enum to use ACEXML
+ prefixes. Thanks to Johnny Willemsen <jwillemsen@remedy.nl> for
+ reporting the clash with native #defines on Tru64.
+
+Sat Jul 19 18:38:50 UTC 2003 Don Hinton <dhinton@dresystems.com>
+
+ * ACEXML/apps/svcconf/Svcconf.h:
+ * ACEXML/common/*.h:
+ * ACEXML/parser/*.h:
+ * ACEXML/parser/parser/*.h:
+ Added "/**/" between the #include and filename for pre.h and
+ post.h so Doxygen won't include them in the file reference tree
+ graphs.
+
+Fri Jul 18 10:29:55 2003 Krishnakumar B <kitty@nospam.invalid.domain>
+
+ * tests/NamespaceSupport_Test.cpp (ACE_TMAIN): Added
+ initialization of ACEXML_NamespaceSupport so that we don't
+ crash.
+
+ * tests/ContentHandler_Test.cpp: Removed "</xml>" at the end of
+ the ACEXML_StrCharStream. XML is not HTML. Added a print
+ statement to the catch clause so that we know what is happening
+ when exception occurs.
+
+Mon Jul 14 18:49:01 UTC 2003 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * apps/svcconf/Makefile:
+ * common/Makefile:
+ * examples/SAXPrint/Makefile:
+ * parser/parser/Makefile:
+ * tests/Makefile:
+ Removed windows specific rules. They are not needed and only
+ cause problems when using a different command shell then cmd
+ like msys. This solves errors in the MinGW build.
+Sat Jul 5 13:33:36 UTC 2003 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * Makefile:
+ Removed windows specific rules. They are not needed and only
+ cause problems when using a different command shell then cmd
+ like msys. This solves errors in the MinGW build.
+
+Fri Jun 27 12:55:33 UTC 2003 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * parser/parser/Entity_Manager.h:
+ * parser/parser/Entity_Manager.i:
+ Removed not useful const return qualifier to resolve intel
+ compiler warnings.
+
+Thu Jun 26 01:47:03 UTC 2003 Don Hinton <dhinton@dresystems.com>
+
+ * parser/parser/Parser.i:
+ Added (int) cast to table index to get rid of a warning.
+
+Tue Jun 24 23:31:44 2003 Nanbor Wang <nanbor@cs.wustl.edu>
+
+ * apps/svcconf/Svcconf.cpp: Turned off validation temporarily when
+ handling svc.conf files. All of the converted svc.conf.xml
+ files do not have associate doctype at the moment.
+
+Tue Jun 24 15:38:49 UTC 2003 Don Hinton <dhinton@dresystems.h>
+
+ * common/NamespaceSupport.i:
+ Added include of ACE.h.
+
+Sun Jun 1 09:09:22 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
+
+ * parser/parser/Parser.cpp:
+ * parser/parser/Entity_Manager.cpp: Added explicit template
+ instantiations.
+
+Fri May 30 14:16:33 2003 Krishnakumar B <kitty@spam.invalid.domain>
+
+ * examples/svcconf/.depend.Makefile.Svcconf:
+ * examples/svcconf/Makefile:
+ * examples/svcconf/Makefile.Svcconf:
+ * examples/svcconf/Makefile.Svcconf.bor:
+ * examples/svcconf/Makefile.bor:
+ * examples/svcconf/README:
+ * examples/svcconf/Svcconf.dsp:
+ * examples/svcconf/Svcconf.dsw:
+ * examples/svcconf/Svcconf.mpc:
+ * examples/svcconf/Svcconf_Handler.cpp:
+ * examples/svcconf/Svcconf_Handler.h:
+ * examples/svcconf/Svcconf_Handler.i:
+ * examples/svcconf/main.cpp:
+
+ Removed directories causing problems with Win XP release.
+
+ * ACEXML.dsw:
+ * Makefile:
+ * Makefile.bor:
+ * apps/svcconf/Makefile:
+ * apps/svcconf/Makefile.ACEXML_XML_Svc_Conf_Parser.bor:
+ * apps/svcconf/Makefile.bor:
+ * common/Makefile:
+ * common/Makefile.ACEXML.bor:
+ * common/Makefile.bor:
+ * examples/SAXPrint/Makefile:
+ * examples/SAXPrint/Makefile.SAXPrint.bor:
+ * examples/SAXPrint/Makefile.bor:
+ * parser/parser/Makefile:
+ * parser/parser/Makefile.ACEXML_Parser.bor:
+ * parser/parser/Makefile.bor:
+ * tests/.depend.Makefile.ContentHandler_Test:
+ * tests/.depend.Makefile.HttpCharStream_Test:
+ * tests/.depend.Makefile.NamespaceSupport_Test:
+ * tests/.depend.Makefile.Transcoder_Test::
+ * tests/Makefile:
+ * tests/Makefile.ContentHandler_Test:
+ * tests/Makefile.ContentHandler_Test.bor:
+ * tests/Makefile.HttpCharStream_Test.bor:
+ * tests/Makefile.NamespaceSupport_Test.bor:
+ * tests/Makefile.Transcoder_Test.bor:
+ * tests/Makefile.bor:
+
+ More build related delicacies needed updating because of the
+ previous change.
+
+Fri May 30 13:56:40 2003 Krishnakumar B <kitty@spam.invalid.domain>
+
+ * common/XML_Common.dsp: Removed old dsp left over from previous
+ merge.
+
+Fri May 30 13:54:57 2003 Krishnakumar B <kitty@spam.invalid.domain>
+
+ * parser/parser/Parser.dsp: Removed this erroneous dsp file left
+ over from the merge.
+
+Fri May 30 13:50:11 2003 Krishnakumar B <kitty@spam.invalid.domain>
+
+ * common/ZipCharStream.h: Removed broken logic to undefine macro
+ version of read. We don't want read to be a macro in ACEXML.
+ Present because of brokenness in ZZIPLIB.
+
+Fri May 30 13:36:39 2003 Krishnakumar B <kitty@spam.invalid.domain>
+
+ * parser/parser/Parser.cpp (parse_ignoresect): Fixed a couple of
+ warnings. Break out of infinite loop.
+
+ * apps/svcconf/.depend.Makefile.ACEXML_XML_Svc_Conf_Parser:
+ * common/.depend.Makefile.ACEXML:
+ * examples/SAXPrint/.depend.Makefile.SAXPrint:
+ * examples/svcconf/.depend.Makefile.Svcconf:
+ * parser/parser/.depend.Makefile.ACEXML_Parser:
+
+ Added missing dependency files. This should clear out the red.
+
+ * examples/svcconf/main.cpp:
+ * common/HttpCharStream.cpp:
+ * parser/parser/Parser.i:
+
+ Fixed warnings with BCB. Thanks to Johnny for reporting these.
+
+Thu May 29 23:13:40 2003 Krishnakumar B <kitty@spam.invalid.domain>
+
+ * examples/SAXPrint/SAXPrint_Handler.cpp: Fixed some minor
+ warnings.
+
+Thu May 29 23:09:27 2003 Krishnakumar B <kitty@spam.invalid.domain>
+
+ * parser/parser/Makefile.Parser:
+
+ Removed extra file left over by mistake.
+
+Thu May 29 23:00:24 2003 Krishnakumar B <kitty@spam.invalid.domain>
+
+ * tests/Makefile.ContentHandler_Test:
+ * tests/Makefile:
+
+ This file got left out by mistake during the big merge.
+
+Thu May 29 22:03:40 2003 Krishnakumar B <kitty@spam.invalid.domain>
+
+ * ACEXML/ACEXML.mwc:
+ * ACEXML/ChangeLog:
+ * ACEXML/apps/svcconf/ACEXML_XML_Svc_Conf_Parser.dsp:
+ * ACEXML/apps/svcconf/Makefile.ACEXML_XML_Svc_Conf_Parser:
+ * ACEXML/apps/svcconf/Makefile.ACEXML_XML_Svc_Conf_Parser.bor:
+ * ACEXML/common/ACEXML.dsp:
+ * ACEXML/common/Makefile.ACEXML:
+ * ACEXML/common/Makefile.ACEXML.bor:
+ * ACEXML/examples/SAXPrint/Makefile.SAXPrint:
+ * ACEXML/examples/SAXPrint/Makefile.SAXPrint.bor:
+ * ACEXML/examples/svcconf/Makefile:
+ * ACEXML/examples/svcconf/Makefile.Svcconf:
+ * ACEXML/examples/svcconf/Makefile.Svcconf.bor:
+ * ACEXML/examples/svcconf/Svcconf.mpc:
+ * ACEXML/parser/parser/ACEXML_Parser.dsp:
+ * ACEXML/parser/parser/Makefile.ACEXML_Parser:
+ * ACEXML/parser/parser/Makefile.ACEXML_Parser.bor:
+ * ACEXML/parser/parser/Makefile.Parser:
+ * ACEXML/tests/Makefile.ContentHandler_Test.bor:
+ * ACEXML/tests/Makefile.HttpCharStream_Test:
+ * ACEXML/tests/Makefile.HttpCharStream_Test.bor:
+ * ACEXML/tests/Makefile.NamespaceSupport_Test:
+ * ACEXML/tests/Makefile.NamespaceSupport_Test.bor:
+ * ACEXML/tests/Makefile.Transcoder_Test:
+ * ACEXML/tests/Makefile.Transcoder_Test.bor:
+
+ New files to build ACEXML generated using MPC.
+
+ * ACEXML/apps/svcconf/svcconf.dtd:
+
+ Moved the DTD from a hidden location to a prominent one.
+
+ * ACEXML/examples/SAXPrint/namespaces.xml:
+
+ New file to test namespace support.
+
+ * ACEXML/common/ZipCharStream.cpp:
+ * ACEXML/common/ZipCharStream.h:
+
+ New files to support reading files from within a ZIP archive as
+ a stream.
+
+ * ACEXML/parser/parser/ParserContext.cpp:
+ * ACEXML/parser/parser/ParserContext.h:
+ * ACEXML/parser/parser/ParserContext.inl:
+
+ New files to support a per stream context encountered when
+ parsing references.
+
+ * ACEXML/parser/parser/ParserInternals.cpp:
+ * ACEXML/parser/parser/ParserInternals.h:
+
+ Move some common functions from Parser.cpp to these files.
+
+ * ACEXML/ACEXML.dsw:
+ * ACEXML/Makefile:
+ * ACEXML/Makefile.bor:
+ * ACEXML/apps/svcconf/Makefile:
+ * ACEXML/apps/svcconf/Makefile.bor:
+ * ACEXML/common/Makefile:
+ * ACEXML/common/Makefile.bor:
+ * ACEXML/examples/SAXPrint/Makefile:
+ * ACEXML/examples/SAXPrint/Makefile.bor:
+ * ACEXML/examples/SAXPrint/SAXPrint.dsp:
+ * ACEXML/examples/SAXPrint/SAXPrint.mpc:
+ * ACEXML/examples/svcconf/Makefile.bor:
+ * ACEXML/examples/svcconf/Svcconf.dsp:
+ * ACEXML/parser/parser/Makefile:
+ * ACEXML/parser/parser/Makefile.bor:
+ * ACEXML/tests/ContentHandler_Test.cpp:
+ * ACEXML/tests/ContentHandler_Test.dsp:
+ * ACEXML/tests/HttpCharStream_Test.cpp:
+ * ACEXML/tests/HttpCharStream_Test.dsp:
+ * ACEXML/tests/Makefile:
+ * ACEXML/tests/Makefile.bor:
+ * ACEXML/tests/NamespaceSupport_Test.dsp:
+ * ACEXML/tests/Transcoder_Test.dsp:
+
+ Build related files changed with the introduction of MPC to
+ build ACEXML.
+
+ * ACEXML/examples/SAXPrint/ns.svc.conf.xml:
+ * ACEXML/examples/SAXPrint/svc.conf.xml:
+
+ New files to test specific features of the parser.
+
+ * ACEXML/apps/svcconf/Svcconf.cpp:
+ * ACEXML/common/Attributes.h:
+ * ACEXML/common/Attributes_Def_Builder.h:
+ * ACEXML/common/CharStream.h:
+ * ACEXML/common/DefaultHandler.cpp:
+ * ACEXML/common/Encoding.cpp:
+ * ACEXML/common/Encoding.h:
+ * ACEXML/common/Exception.cpp:
+ * ACEXML/common/FileCharStream.cpp:
+ * ACEXML/common/FileCharStream.h:
+ * ACEXML/common/HttpCharStream.cpp:
+ * ACEXML/common/HttpCharStream.h:
+ * ACEXML/common/InputSource.cpp:
+ * ACEXML/common/InputSource.h:
+ * ACEXML/common/LocatorImpl.cpp:
+ * ACEXML/common/LocatorImpl.h:
+ * ACEXML/common/Mem_Map_Stream.cpp:
+ * ACEXML/common/NamespaceSupport.cpp:
+ * ACEXML/common/NamespaceSupport.h:
+ * ACEXML/common/SAXExceptions.cpp:
+ * ACEXML/common/StrCharStream.cpp:
+ * ACEXML/common/StrCharStream.h:
+ * ACEXML/common/StreamFactory.cpp:
+ * ACEXML/common/Transcode.cpp:
+ * ACEXML/common/Transcode.h:
+ * ACEXML/common/Transcode.i:
+ * ACEXML/examples/SAXPrint/Print_Handler.cpp:
+ * ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp:
+ * ACEXML/examples/SAXPrint/main.cpp:
+ * ACEXML/examples/svcconf/main.cpp:
+ * ACEXML/parser/parser/Parser.cpp:
+ * ACEXML/parser/parser/Parser.h:
+ * ACEXML/parser/parser/Parser.i:
+ * ACEXML/parser/parser/Entity_Manager.cpp:
+ * ACEXML/parser/parser/Entity_Manager.h:
+ * ACEXML/parser/parser/Entity_Manager.i:
+
+ Merge from the Validator branch. It is not close to conformance
+ related to Validation but is quite stable as a parser which
+ recognizes the complete XML grammar.
+
+Fri Jan 24 20:28:22 2003 Krishnakumar B <kitty@insanely.long.id.truncated>
+
+ * parser/parser/Parser.cpp (pop_context): Bail out if there is
+ only one element on the context stack. Bad things [TM] will happen
+ if we pop the only context available.
+
+Mon Nov 25 04:25:15 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * parser/parser/Parser.cpp (reset):
+ * parser/parser/Parser.h:
+
+ Fixed a bunch of compilation errors. Removed unnecessary
+ creation and destroyal of ACEXML_Strings which seems to speed up
+ the parser quite a bit.
+
+ * examples/SAXPrint/SAXPrint_Handler.cpp:
+ * examples/SAXPrint/main.cpp:
+
+ Don't report startPrefixMapping() and endPrefixMapping() as they
+ obstruct the pretty-printing of SAXPrint. They are bogus anyway.
+
+Wed Nov 20 22:58:12 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * parser/parser/Parser.cpp (parse_char_reference):
+
+ Fixed stupid thinko in conditional parsing of a hex character
+ reference.
+
+ * common/Mem_Map_Stream.cpp:
+
+ We can use the old way of fetching on-demand and don't need to
+ use a while loop.
+
+ * common/NamespaceSupport.cpp:
+
+ Fixed a long-standing bug with core dumping. With these changes,
+ we are able to parse the XML specification itself. Is this
+ called Meta or what ?
+
+Wed Nov 20 20:44:56 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * common/Mem_Map_Stream.cpp (grow_file_and_remap):
+
+ Fixed bug where we were trying to remap two different files at
+ the same location without closing the first.
+
+ * common/HttpCharStream.cpp (get_url):
+
+ Don't try to parse an empty file. Removes a nasty SIGSEGV.
+
+Wed Nov 20 01:06:26 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * common/Mem_Map_Stream.cpp:
+
+ Minor indenting changes.
+
+ * tests/HttpCharStream_Test.cpp:
+
+ Modified test to show bug in ACE_File_Addr.
+
+Tue Nov 19 20:46:35 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * examples/SAXPrint/Print_Handler.cpp (warning):
+
+ Missed syncing the function prototypes last time.
+
+Tue Nov 19 20:18:09 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * parser/parser/Parser.h:
+ * parser/parser/Parser.cpp (normalize_systemid):
+
+ Fix an off-by-one error in normalization. The document's base
+ URI is never empty. Now we parse relative document URI
+ correctly.
+
+ Implement the previously unimplemented parsing from a systemId.
+
+ * common/InputSource.cpp:
+ * common/InputSource.h:
+
+ Implement creating an InputSource from a systemId.
+
+ * common/CharStream.h:
+
+ Added a new method getSystemId().
+
+ * common/FileCharStream.cpp:
+ * common/FileCharStream.h:
+ * common/HttpCharStream.cpp:
+ * common/HttpCharStream.h:
+ * common/ZipCharStream.cpp:
+ * common/ZipCharStream.h:
+ * common/StrCharStream.cpp:
+ * common/StrCharStream.h:
+
+ Added implementation for getSystemId().
+
+ * examples/SAXPrint/Print_Handler.cpp:
+ * examples/SAXPrint/SAXPrint_Handler.cpp:
+
+ Synched up the printing of exception messages.
+
+ * examples/SAXPrint/main.cpp:
+
+ Fixed broken internal string version of a sample XML file.
+
+Tue Nov 19 15:02:06 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * apps/svcconf/XML_Svc_Conf_Parser.dsp:
+ * common/XML_Common.dsp:
+ * examples/SAXPrint/SAXPrint.dsp:
+ * parser/debug_validator/Debug_Validator.dsp:
+ * parser/parser/Parser.dsp:
+
+ Modified to accomodate zlib and zziplig. Will probably change
+ before the merge.
+
+ * parser/parser/Parser.cpp:
+
+ Try to parse external DTD only if validation is required.
+
+Mon Nov 18 22:29:39 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * ACEXML/Makefile:
+
+ Deleted this file in the previous check-in. Re-add it.
+
+Mon Nov 18 22:19:47 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * ACEXML/common/common.mpc:
+ * ACEXML/parser/parser/parser.mpc:
+ * ACEXML/parser/debug_validator/validator.mpc:
+ * ACEXML/apps/svcconf/svcconf.mpc:
+ * ACEXML/examples/svcconf/Svcconf.mpc:
+ * ACEXML/examples/SAXPrint/saxprint.mpc:
+ * ACEXML/tests/tests.mpc:
+ * ACEXML/ACEXML.mwc:
+
+ New MPC files and Workspace file.
+
+ * ACEXML/common/Makefile.XML_Common:
+ * ACEXML/apps/svcconf/Makefile.XML_Svc_Conf_Parser:
+ * ACEXML/parser/parser/Makefile.Parser:
+ * ACEXML/parser/debug_validator/Makefile.Validator:
+ * ACEXML/examples/SAXPrint/Makefile.SAXPrint:
+ * ACEXML/examples/svcconf/Makefile.Svcconf:
+ * ACEXML/tests/Makefile.HttpCharStream_Test:
+ * ACEXML/tests/Makefile.NamespaceSupport_Test:
+ * ACEXML/tests/Makefile.Transcoder_Test:
+
+ New Makefiles generated by MPC.
+
+ * ACEXML/common/Makefile:
+ * ACEXML/parser/parser/Makefile:
+ * ACEXML/parser/Makefile:
+ * ACEXML/examples/Makefile:
+ * ACEXML/apps/Makefile:
+ * ACEXML/apps/svcconf/Makefile:
+ * ACEXML/examples/SAXPrint/Makefile:
+ * ACEXML/tests/Makefile:
+
+ Removed old Makefiles.
+
+ * ACEXML/parser/parser/Parser.cpp:
+ * ACEXML/common/StreamFactory.cpp:
+ * ACEXML/common/ZipCharStream.cpp:
+ * ACEXML/common/ZipCharStream.h:
+
+ Fixed compilation errors.
+
+Mon Nov 18 20:30:30 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * ACEXML/common/CharStream.h:
+ * ACEXML/common/Encoding.cpp:
+ * ACEXML/common/FileCharStream.cpp:
+ * ACEXML/common/FileCharStream.h:
+ * ACEXML/common/StrCharStream.cpp:
+ * ACEXML/common/StrCharStream.h:
+ * ACEXML/common/HttpCharStream.cpp:
+ * ACEXML/common/HttpCharStream.h:
+
+ Fixed a number of minor typos and debugging statements.
+
+ * ACEXML/common/LocatorImpl.cpp: Check for a valid string before
+ assigning it to the new Locator.
+
+ * ACEXML/common/NamespaceSupport.cpp:
+
+ Make sure that we don't have a null prefix before trying to
+ dereference the prefix.
+
+ * ACEXML/common/ZipCharStream.cpp:
+ * ACEXML/common/ZipCharStream.h:
+
+ New stream which reads files from a ZIP archive.
+
+ * ACEXML/common/StreamFactory.cpp:
+
+ Modified to accomodate ZipCharStream.
+
+ * ACEXML/examples/SAXPrint/Print_Handler.cpp:
+ * ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp:
+ * ACEXML/examples/SAXPrint/main.cpp:
+
+ Commented out a lot of unnecessary debug statements.
+
+ * ACEXML/parser/parser/Parser.cpp:
+ * ACEXML/parser/parser/Parser.h:
+
+ Lots of bugfixes. Finally we parse the XML version of XHTML
+ specification without dumping core.
+
+Sat Nov 16 21:18:55 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * ACEXML/parser/parser/Parser.cpp:
+ * ACEXML/parser/parser/Parser.h:
+
+ More bugs fixed. Add support for parsing PE references within
+ attribute list declarations and clean up the same. Add support
+ for parsing PE references within element declarations.
+
+Tue Nov 12 19:48:34 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * ACEXML/parser/parser/ParserContext.cpp:
+ * ACEXML/parser/parser/ParserContext.h:
+ * ACEXML/parser/parser/ParserContext.inl:
+
+ New files which hold the ParserContext needed to handle the
+ switching of input streams on the fly.
+
+ * ACEXML/parser/parser/ParserInternals.cpp:
+ * ACEXML/parser/parser/ParserInternals.h:
+
+ Moved some generic code from Parser.cpp to here.
+
+ * ACEXML/apps/svcconf/Makefile:
+ * ACEXML/common/Makefile:
+ * ACEXML/parser/parser/Makefile:
+
+ Updated dependencies.
+
+ * ACEXML/common/Attributes_Def_Builder.h:
+
+ No need to typedef in C++.
+
+ * ACEXML/common/DefaultHandler.cpp:
+
+ Minor typos.
+
+ * ACEXML/common/Encoding.cpp:
+
+ If auto-detection of encoding fails, assume that it is UTF-8.
+
+ * ACEXML/common/Exception.cpp:
+
+ Change the error message from ACE_DEBUG to ACE_ERROR.
+
+ * ACEXML/common/FileCharStream.cpp: Handle BOM of UTF-8 in
+ addition to UTF-16. Cleanup unnecessary parens.
+
+ * ACEXML/common/HttpCharStream.cpp:
+ * ACEXML/common/HttpCharStream.h:
+
+ Add support for auto-detection of encoding.
+
+ * ACEXML/common/InputSource.cpp:
+ * ACEXML/common/InputSource.h:
+
+ Fixes for use with ACEXML_Parser_Context.
+
+ * ACEXML/common/LocatorImpl.cpp:
+ * ACEXML/common/LocatorImpl.h:
+
+ Fixed bug in copy constructor which resulted in locator
+ information not getting set properly.
+
+ * ACEXML/common/NamespaceSupport.cpp:
+ * ACEXML/common/NamespaceSupport.h:
+
+ Implement reset() method.
+
+ * ACEXML/common/SAXExceptions.cpp:
+
+ Change the error message from ACE_DEBUG to ACE_ERROR.
+
+ * ACEXML/common/StrCharStream.cpp:
+
+ Handle copying of bytes according to sizeof (ACE_WCHAR).
+
+ * ACEXML/common/StreamFactory.cpp: Create the appropriate stream
+ given an URI. We don't try to normalize the URI here. It is done
+ in the Parser.
+
+ * ACEXML/common/Transcode.cpp:
+ * ACEXML/common/Transcode.i:
+
+ Moved some very big functions from .i to .cpp.
+
+ * ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp:
+ * ACEXML/examples/SAXPrint/main.cpp:
+
+ Updates to reflect the new calling convention in the Parser.
+
+ * ACEXML/parser/parser/Entity_Manager.cpp:
+ * ACEXML/parser/parser/Entity_Manager.h:
+ * ACEXML/parser/parser/Entity_Manager.i:
+
+ Implemented support for resolving SYSTEM and PUBLIC ids from
+ the Entity_Manager.
+
+ * ACEXML/parser/parser/Parser.cpp:
+ * ACEXML/parser/parser/Parser.h:
+ * ACEXML/parser/parser/Parser.i:
+
+ Implemented support for external parameter and entity
+ references. Rewrote a lot of the basic parsing functionality to
+ adhere to the standard. Implment partial support for validation
+ of XML files.
+
+
+Fri Oct 25 15:44:04 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * ACEXML/parser/parser/Parser.i: Handle end-of-line as required by
+ the spec. Specifically any sequence of 0x0D or 0x0D 0x0A should
+ be normalized to a 0x0A before passing to the XML processor.
+
+ * ACEXML/parser/parser/Parser.cpp: Remove checks for 0x0D as it is
+ handled tranparently now.
+
+Thu Oct 24 21:06:44 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * ACEXML/common/NamespaceSupport.cpp: Define strings normally and
+ not as an array.
+
+ * ACEXML/common/Attributes_Def_Builder.h: No need to typedef in C++.
+
+Thu Oct 24 01:52:46 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * ACEXML\parser\parser\Parser.cpp: Moved out the declaration of
+ variables outside case labels. MSVC doesn't like it.
+
+Wed Oct 23 22:24:59 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * ACEXML/parser/parser/Parser.cpp: Fixed a stupid thinko in array
+ initialization.
+
+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().
+
+Local Variables:
+mode: change-log
+add-log-time-format: (lambda () (progn (setq tz (getenv "TZ")) (set-time-zone-rule "UTC") (setq time (format-time-string "%a %b %e %H:%M:%S %Z %Y" (current-time))) (set-time-zone-rule tz) time))
+indent-tabs-mode: nil
+End:
diff --git a/ACE/ACEXML/Makefile.am b/ACE/ACEXML/Makefile.am
new file mode 100644
index 00000000000..f0541d979c7
--- /dev/null
+++ b/ACE/ACEXML/Makefile.am
@@ -0,0 +1,17 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+SUBDIRS = \
+ common \
+ parser \
+ examples \
+ apps \
+ tests
+
diff --git a/ACE/ACEXML/README b/ACE/ACEXML/README
new file mode 100644
index 00000000000..1e65588029e
--- /dev/null
+++ b/ACE/ACEXML/README
@@ -0,0 +1,17 @@
+$Id$
+
+ACE XML PARSER Framework README file
+
+* Character set
+
+ACE XML only deal with pure unicode encoding. I.e., ACE XML
+does not care about language specific encoding information.
+
+* SAX - The Simple API for XML
+
+ACE XML Parser interfaces follows the the design of SAX 2.0, which is
+a public domain specification for Java. The major difference between
+ACE XML Parser interfaces and SAX is that we added an reference of
+ACEXML_Env to every SAX method to accomodate platforms/compilers that
+don't support C++ exceptions. SAX is defined by David Megginson
+<david@megginson.com>
diff --git a/ACE/ACEXML/apps/Makefile.am b/ACE/ACEXML/apps/Makefile.am
new file mode 100644
index 00000000000..81f0c9cbd88
--- /dev/null
+++ b/ACE/ACEXML/apps/Makefile.am
@@ -0,0 +1,13 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+SUBDIRS = \
+ svcconf
+
diff --git a/ACE/ACEXML/apps/svcconf/ACEXML_XML_Svc_Conf_Parser.pc.in b/ACE/ACEXML/apps/svcconf/ACEXML_XML_Svc_Conf_Parser.pc.in
new file mode 100644
index 00000000000..3cda818ca76
--- /dev/null
+++ b/ACE/ACEXML/apps/svcconf/ACEXML_XML_Svc_Conf_Parser.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ACEXML_XML_Svc_Conf_Parser
+Description: ACE XML Service Configurator Parser
+Requires: ACEXML_Parser
+Version: @VERSION@
+Libs: -L${libdir} -lACEXML_XML_Svc_Conf_Parser
+Cflags: -I${includedir}
diff --git a/ACE/ACEXML/apps/svcconf/Makefile.am b/ACE/ACEXML/apps/svcconf/Makefile.am
new file mode 100644
index 00000000000..68f7bc37589
--- /dev/null
+++ b/ACE/ACEXML/apps/svcconf/Makefile.am
@@ -0,0 +1,55 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+includedir = @includedir@/ACEXML/apps/svcconf
+
+ACE_BUILDDIR = $(top_builddir)
+ACE_ROOT = $(top_srcdir)
+
+
+## Makefile.ACEXML_XML_Svc_Conf_Parser.am
+
+if BUILD_ACEXML
+if !BUILD_ACE_FOR_TAO
+
+lib_LTLIBRARIES = libACEXML_XML_Svc_Conf_Parser.la
+
+libACEXML_XML_Svc_Conf_Parser_la_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(ACE_ROOT)/ACEXML/common
+
+libACEXML_XML_Svc_Conf_Parser_la_SOURCES = \
+ Svcconf.cpp \
+ Svcconf_Handler.cpp
+
+libACEXML_XML_Svc_Conf_Parser_la_LDFLAGS = \
+ -release @ACE_VERSION_NAME@
+
+libACEXML_XML_Svc_Conf_Parser_la_LIBADD = \
+ $(ACE_BUILDDIR)/ACEXML/parser/parser/libACEXML_Parser.la \
+ $(ACE_BUILDDIR)/ACEXML/common/libACEXML.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+nobase_include_HEADERS = \
+ Svcconf.h \
+ Svcconf_Handler.h \
+ Svcconf_Handler.i
+
+endif !BUILD_ACE_FOR_TAO
+endif BUILD_ACEXML
+
+## Clean up template repositories, etc.
+clean-local:
+ -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.*
+ -rm -f gcctemp.c gcctemp so_locations *.ics
+ -rm -rf cxx_repository ptrepository ti_files
+ -rm -rf templateregistry ir.out
+ -rm -rf ptrepository SunWS_cache Templates.DB
diff --git a/ACE/ACEXML/apps/svcconf/README b/ACE/ACEXML/apps/svcconf/README
new file mode 100644
index 00000000000..8a39a40bfe3
--- /dev/null
+++ b/ACE/ACEXML/apps/svcconf/README
@@ -0,0 +1,4 @@
+$Id$
+
+This directory implement a DLL that contains the parser for XML based
+service configurator.
diff --git a/ACE/ACEXML/apps/svcconf/Svcconf.cpp b/ACE/ACEXML/apps/svcconf/Svcconf.cpp
new file mode 100644
index 00000000000..482970b1515
--- /dev/null
+++ b/ACE/ACEXML/apps/svcconf/Svcconf.cpp
@@ -0,0 +1,120 @@
+// $Id$
+
+
+#include "Svcconf.h"
+#include "ACEXML/common/FileCharStream.h"
+#include "ACEXML/common/StrCharStream.h"
+#include "ACEXML/parser/parser/Parser.h"
+
+#if (ACE_USES_CLASSIC_SVC_CONF == 0)
+
+extern "C" ACE_Proper_Export_Flag ACE_XML_Svc_Conf *
+_ACEXML_create_XML_Svc_Conf_Object (void)
+{
+ ACE_XML_Svc_Conf *retp = 0;
+
+ ACE_NEW_RETURN (retp,
+ ACEXML_Svcconf_Parser (),
+ 0);
+
+ return retp;
+}
+
+ACEXML_Svcconf_Parser::ACEXML_Svcconf_Parser ()
+{
+ this->parser_.setContentHandler (&this->svcconf_handler_);
+ this->parser_.setDTDHandler (&this->svcconf_handler_);
+ this->parser_.setErrorHandler (&this->svcconf_handler_);
+ this->parser_.setEntityResolver (&this->svcconf_handler_);
+ ACEXML_TRY_NEW_ENV
+ {
+ this->parser_.setFeature (ACE_TEXT ("http://xml.org/sax/features/validation"),
+ 0
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_TRY_CHECK;
+ }
+ ACEXML_CATCH (ACEXML_SAXException, ex)
+ {
+ ex.print (); // Can't do much except printing the error.
+ return;
+ }
+ ACEXML_ENDTRY;
+}
+
+ACEXML_Svcconf_Parser::~ACEXML_Svcconf_Parser ()
+{
+
+}
+
+
+int
+ACEXML_Svcconf_Parser::parse_file (const ACE_TCHAR file[])
+{
+ if (file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: No filename specified\n"), -1);
+
+ ACEXML_FileCharStream *fstm = 0;
+ ACE_NEW_RETURN (fstm,
+ ACEXML_FileCharStream (),
+ 1);
+
+ if (fstm->open (file) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("ACEXML_Svcconf_Parser: Fail to open XML file: %s\n"),
+ file),
+ -1);
+
+ this->input_stream_.setCharStream (fstm);
+
+ ACEXML_TRY_NEW_ENV
+ {
+ this->parser_.parse (&this->input_stream_ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_TRY_CHECK;
+ }
+ ACEXML_CATCH (ACEXML_SAXException, ex)
+ {
+ ex.print ();
+ return -1;
+ }
+ ACEXML_ENDTRY;
+ return 0;
+}
+
+
+int
+ACEXML_Svcconf_Parser::parse_string (const ACE_TCHAR str[])
+{
+ if (str == 0)
+ ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: Can't parse a null string\n"), -1);
+
+ ACEXML_StrCharStream *stm = 0;
+ ACE_NEW_RETURN (stm, ACEXML_StrCharStream, -1);
+ if (stm->open (str, ACE_TEXT ("Svcconf")) < 0)
+ ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: Unable to create "
+ "input stream.\n"), -1);
+
+ this->input_stream_.setCharStream (stm);
+ ACEXML_TRY_NEW_ENV
+ {
+ this->parser_.parse (&this->input_stream_ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_TRY_CHECK;
+ }
+ ACEXML_CATCH (ACEXML_SAXException, ex)
+ {
+ ex.print ();
+ return -1;
+ }
+ ACEXML_ENDTRY;
+ return 0;
+}
+
+#else
+
+# if defined (_AIX) && \
+ (defined (__IBMCPP__) && (__IBMCPP__ >= 500) && (__IBMCPP__ < 600))
+// This simply shuts up the AIX linker that complains there are no
+// csects or exported symbols when building with Visual Age C++ 5.
+extern "C" void ace_shut_up_aix_ld (void) {};
+# endif /* AIX && __IBMCPP__ == 500 */
+
+#endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */
diff --git a/ACE/ACEXML/apps/svcconf/Svcconf.h b/ACE/ACEXML/apps/svcconf/Svcconf.h
new file mode 100644
index 00000000000..9879776fce5
--- /dev/null
+++ b/ACE/ACEXML/apps/svcconf/Svcconf.h
@@ -0,0 +1,44 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ * @file Svcconf.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef ACEXML_SVCCONF_H
+#define ACEXML_SVCCONF_H
+
+#include /**/ "ace/pre.h"
+#include "ace/XML_Svc_Conf.h"
+#include "ACEXML/parser/parser/Parser.h"
+#include "Svcconf_Handler.h"
+
+#if (ACE_USES_CLASSIC_SVC_CONF == 0)
+
+class ACEXML_Svcconf_Parser : public ACE_XML_Svc_Conf
+{
+public:
+ ACEXML_Svcconf_Parser ();
+
+ virtual ~ACEXML_Svcconf_Parser ();
+
+ virtual int parse_file (const ACE_TCHAR file[]);
+
+ virtual int parse_string (const ACE_TCHAR str[]);
+
+protected:
+ ACEXML_Parser parser_;
+ ACEXML_Svcconf_Handler svcconf_handler_;
+ ACEXML_InputSource input_stream_;
+};
+
+#endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */
+
+#include /**/ "ace/post.h"
+#endif /* ACEXML_SVCCONF_H */
diff --git a/ACE/ACEXML/apps/svcconf/Svcconf_Handler.cpp b/ACE/ACEXML/apps/svcconf/Svcconf_Handler.cpp
new file mode 100644
index 00000000000..f9105555580
--- /dev/null
+++ b/ACE/ACEXML/apps/svcconf/Svcconf_Handler.cpp
@@ -0,0 +1,771 @@
+// $Id$
+
+#include "Svcconf_Handler.h"
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+#include "ace/Service_Config.h"
+#include "ace/Service_Types.h"
+#include "ace/Service_Repository.h"
+#include "ace/DLL.h"
+#include "ace/ARGV.h"
+#include "ace/Module.h"
+#include "ace/OS_NS_strings.h"
+#include "ace/SString.h"
+
+#if (ACE_USES_CLASSIC_SVC_CONF == 0)
+
+#if !defined (__ACEXML_INLINE__)
+# include "Svcconf_Handler.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_Svcconf_Handler::ACEXML_Svcconf_Handler (void)
+ : in_stream_def_ (0),
+ in_module_ (0),
+ stream_svc_type_ (0),
+ stream_ (0)
+{
+ // no-op
+}
+
+ACEXML_Svcconf_Handler::~ACEXML_Svcconf_Handler (void)
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::characters (const ACEXML_Char *,
+ int,
+ int ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::endDocument ( ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::endElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (ACE_OS::strcmp (qName, ACE_TEXT ("dynamic")) == 0)
+ {
+ ACE_Parsed_Info *active_info = (this->in_stream_def_ == 0 ?
+ &this->parsed_info_ :
+ &this->stream_info_);
+
+ ACE_DLL svc_dll;
+
+ if (svc_dll.open (active_info->path ()) == -1)
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Cannot locate DLL: '"));
+ msg += ACE_CString (ACE_TEXT (active_info->path ()));
+ msg += ACE_CString (ACE_TEXT ("' for entity '"));
+ msg += ACE_CString (ACE_TEXT (active_info->name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+
+ void *(*func) (ACE_Service_Object_Exterminator *) = 0;
+ ACE_Service_Object_Exterminator gobbler = 0;
+ void *symbol = 0;
+
+ long temp_ptr =
+ reinterpret_cast<long> (svc_dll.symbol (active_info->init_func ()));
+ func = reinterpret_cast<void *(*)(ACE_Service_Object_Exterminator *)> (temp_ptr);
+
+ if (func == 0)
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Cannot locate init function: '"));
+ msg += ACE_CString (ACE_TEXT (active_info->init_func ()));
+ msg += ACE_CString (ACE_TEXT ("' for entity '"));
+ msg += ACE_CString (ACE_TEXT (active_info->name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+ symbol = (*func)(&gobbler); // target object created in the loaded DLL.
+
+ ACE_Service_Type_Impl *stp = ACE_Service_Config::create_service_type_impl
+ (active_info->name (),
+ active_info->service_type (),
+ symbol,
+ ACE_Service_Type::DELETE_THIS |
+ ACE_Service_Type::DELETE_OBJ,
+ gobbler);
+
+ if (this->in_stream_def_)
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Create dynamic %s for stream\n"),
+// this->stream_info_.name ()));
+ if (active_info->service_type () == ACE_Service_Type::STREAM)
+ {
+ this->stream_ = (ACE_Stream_Type *) stp;
+ }
+ else
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Expecting Stream type in stream header"));
+ msg += ACE_CString (ACE_TEXT (" for entity '"));
+ msg += ACE_CString (ACE_TEXT (active_info->name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+
+ this->stream_svc_type_ =
+ ACE_Service_Config::create_service_type (this->stream_info_.name (),
+ this->stream_,
+ svc_dll,
+ this->stream_info_.active ());
+
+ }
+ else
+ {
+ if (this->in_module_)
+ {
+ ACE_ARGV args (active_info->init_params ());
+
+ ACE_Module_Type *mt = (ACE_Module_Type *) stp;
+
+ ACE_Module<ACE_SYNCH> *mp = (ACE_Module<ACE_SYNCH> *) mt->object ();
+
+ if (ACE_OS::strcmp (mp->name (), active_info->name ()) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("warning: assigning Module_Type name %s to Module %s since names differ\n"),
+ active_info->name (),
+ mp->name ()));
+ mp->name (active_info->name ());
+ }
+
+ if (mt->init (args.argc (), args.argv ()) == -1
+ || this->stream_->push (mt) == -1)
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Error initializing module"));
+ msg += ACE_CString (ACE_TEXT (" for entity '"));
+ msg += ACE_CString (ACE_TEXT (active_info->name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+
+
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Push dynamic %s into stream %s\n"),
+// this->parsed_info_.name (),
+// this->stream_info_.name ()));
+ }
+ else
+ {
+ ACE_Service_Type *stype =
+ ACE_Service_Config::create_service_type (active_info->name (),
+ stp,
+ svc_dll,
+ active_info->active ());
+ // @@ Check error here.
+
+ // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply dynamic %s\n"),
+// this->parsed_info_.name ()));
+ if (ACE_Service_Config::initialize (stype,
+ active_info->init_params ()) == -1)
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Failed to initialize dynamic service"));
+ msg += ACE_CString (ACE_TEXT (" for entity '"));
+ msg += ACE_CString (ACE_TEXT (active_info->name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+ }
+ this->parsed_info_.reset ();
+ }
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("static")) == 0)
+ {
+ if (this->in_stream_def_)
+ {
+ // @@ Couldn't make sense out of the original Svc_Conf.y.
+ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Create static %s for stream\n"),
+ this->stream_info_.name ()));
+ }
+ else
+ {
+ if (this->in_module_)
+ {
+ // @@ Couldn't make sense out of the original Svc_Conf.y.
+ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Push static %s into stream %s\n"),
+ this->parsed_info_.name (),
+ this->stream_info_.name ()));
+ }
+ else
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply static %s\n"),
+// this->parsed_info_.name ()));
+ if (ACE_Service_Config::initialize (this->parsed_info_.name (),
+ this->parsed_info_.init_params ()) == -1)
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Failed to initialize static service"));
+ msg += ACE_CString (ACE_TEXT (" for entity '"));
+ msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+ }
+ this->parsed_info_.reset ();
+ }
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("module")) == 0)
+ {
+ this->in_module_ = 0;
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("streamdef")) == 0)
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply stream %s of type %s\n"),
+// this->stream_info_.name (),
+// this->stream_info_.name ()));
+ ACE_Service_Config::initialize (this->stream_svc_type_,
+ this->stream_info_.init_params ());
+
+ this->stream_info_.reset ();
+ this->stream_svc_type_ = 0;
+ this->stream_ = 0;
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("stream")) == 0)
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply stream %s of type %s\n"),
+// this->stream_info_.name (),
+// this->stream_info_.name ()));
+ this->stream_info_.reset ();
+ }
+ else
+ {
+ }
+}
+
+void
+ACEXML_Svcconf_Handler::endPrefixMapping (const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::ignorableWhitespace (const ACEXML_Char *,
+ int,
+ int ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::processingInstruction (const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::setDocumentLocator (ACEXML_Locator* locator)
+{
+ this->locator_ = locator;
+}
+
+void
+ACEXML_Svcconf_Handler::skippedEntity (const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::startDocument ( ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // no-op
+}
+
+void
+ACEXML_Svcconf_Handler::startElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (ACE_OS::strcmp (qName, ACE_TEXT ("dynamic")) == 0)
+ {
+ this->get_dynamic_attrs (alist ACEXML_ENV_ARG_PARAMETER);
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("initializer")) == 0)
+ {
+ this->get_initializer_attrs (alist ACEXML_ENV_ARG_PARAMETER);
+
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("static")) == 0)
+ {
+ this->get_static_attrs (alist ACEXML_ENV_ARG_PARAMETER);
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("stream")) == 0)
+ {
+ this->get_stream_id (alist ACEXML_ENV_ARG_PARAMETER);
+
+ if (ACE_Service_Repository::instance()->find
+ (this->stream_info_.name (),
+ (const ACE_Service_Type **) &this->stream_svc_type_) == -1)
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Cannot find stream '"));
+ msg += ACE_CString (ACE_TEXT (this->stream_info_.name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+ this->stream_ = this->stream_svc_type_ == 0
+ ? 0
+ : dynamic_cast<ACE_Stream_Type *> (const_cast<ACE_Service_Type_Impl *> (this->stream_svc_type_->type ()));
+
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Retrieve stream %s from repository\n"),
+// this->stream_info_.name ()));
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("streamdef")) == 0)
+ {
+ this->in_stream_def_ = 1;
+ // @@ Set up stream service object
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("module")) == 0)
+ {
+ this->in_stream_def_ = 0;
+ this->in_module_ = 1;
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("resume")) == 0)
+ {
+ this->get_id (alist ACEXML_ENV_ARG_PARAMETER);
+ if (this->in_module_)
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s in stream %s\n"),
+// this->parsed_info_.name (),
+// this->stream_info_.name ()));
+ ACE_Module_Type *mt = (this->stream_ == 0)
+ ? 0
+ : this->stream_->find (this->parsed_info_.name ());
+
+ if (mt == 0)
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Can't locate module '"));
+ msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+
+ mt->resume ();
+ }
+ else
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s\n"),
+// this->parsed_info_.name ()));
+ if (ACE_Service_Config::resume (this->parsed_info_.name ()) == -1)
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Resume failed"));
+ msg += ACE_CString (ACE_TEXT (" for entity '"));
+ msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+ }
+ this->parsed_info_.reset ();
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("suspend")) == 0)
+ {
+ this->get_id (alist ACEXML_ENV_ARG_PARAMETER);
+ if (this->in_module_)
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s in stream %s\n"),
+// this->parsed_info_.name (),
+// this->stream_info_.name ()));
+ ACE_Module_Type *mt = (this->stream_ == 0)
+ ? 0
+ : this->stream_->find (this->parsed_info_.name ());
+
+ if (mt == 0)
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Can't locate module '"));
+ msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+
+ mt->suspend ();
+ }
+ else
+ {
+ // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s\n"),
+ // this->parsed_info_.name ()));
+ if (ACE_Service_Config::suspend (this->parsed_info_.name ()) == -1)
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Suspend failed"));
+ msg += ACE_CString (ACE_TEXT (" for entity '"));
+ msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+ }
+ this->parsed_info_.reset ();
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("remove")) == 0)
+ {
+ this->get_id (alist ACEXML_ENV_ARG_PARAMETER);
+ if (this->in_module_)
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s in stream %s\n"),
+// this->parsed_info_.name (),
+// this->stream_info_.name ()));
+ ACE_Module_Type *mt = (this->stream_ == 0)
+ ? 0
+ : this->stream_->find (this->parsed_info_.name ());
+
+ if (mt == 0)
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Can't locate module '"));
+ msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+
+ this->stream_->remove (mt);
+ }
+ else
+ {
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s\n"),
+// this->parsed_info_.name ()));
+ if (ACE_Service_Config::remove (this->parsed_info_.name ()) == -1)
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Remove failed"));
+ msg += ACE_CString (ACE_TEXT (" for entity '"));
+ msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW (ACEXML_SAXException (msg.c_str ()));
+ }
+ }
+ this->parsed_info_.reset ();
+ }
+ else if (ACE_OS::strcmp (qName, ACE_TEXT ("ACE_Svc_Conf")) == 0)
+ {
+ // Main document tag. no-op.
+// ACE_DEBUG ((LM_INFO, ACE_TEXT ("ACE_Svc_Conf tag\n")));
+ }
+ else
+ {
+ // @@ Error. Perhaps we should relay to user event handler here, if available.
+ }
+
+ return;
+}
+
+void
+ACEXML_Svcconf_Handler::startPrefixMapping (const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+// *** Methods inherit from ACEXML_DTDHandler.
+
+void
+ACEXML_Svcconf_Handler::notationDecl (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_Svcconf_Handler::unparsedEntityDecl (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+// Methods inherit from ACEXML_EnitityResolver.
+
+ACEXML_InputSource *
+ACEXML_Svcconf_Handler::resolveEntity (const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+ return 0;
+}
+
+// Methods inherit from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+void
+ACEXML_Svcconf_Handler::error (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG, "%s: line :%d col: %d ", this->locator_->getSystemId(),
+ this->locator_->getLineNumber(),
+ this->locator_->getColumnNumber()));
+ ex.print();
+}
+
+void
+ACEXML_Svcconf_Handler::fatalError (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG, "%s: line :%d col: %d ", this->locator_->getSystemId(),
+ this->locator_->getLineNumber(),
+ this->locator_->getColumnNumber()));
+ ex.print();
+}
+
+void
+ACEXML_Svcconf_Handler::warning (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG, "%s: line :%d col: %d ", this->locator_->getSystemId(),
+ this->locator_->getLineNumber(),
+ this->locator_->getColumnNumber()));
+ ex.print();
+}
+
+int
+ACEXML_Svcconf_Handler::get_stream_id (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
+{
+ if (alist != 0)
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
+ {
+ this->stream_info_.name (alist->getValue (i));
+ }
+ else
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Invalid stream attribute '"));
+ msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
+ msg += ACE_CString (ACE_TEXT ("' for entity '"));
+ msg += ACE_CString (ACE_TEXT (this->stream_info_.name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()),
+ -1);
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Svcconf_Handler::get_id (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
+{
+ if (alist != 0)
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
+ {
+ this->parsed_info_.name (alist->getValue (i));
+ }
+ else
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Invalid attribute '"));
+ msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
+ msg += ACE_CString (ACE_TEXT ("', expecting 'id'"));
+ msg += ACE_CString (ACE_TEXT (" for entity '"));
+ msg += ACE_CString (ACE_TEXT (this->parsed_info_.name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()),
+ -1);
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Svcconf_Handler::get_dynamic_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
+{
+ if (alist != 0)
+ {
+ ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
+ &this->parsed_info_ :
+ &this->stream_info_);
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
+ {
+ info->name (alist->getValue (i));
+ }
+ else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("status")) == 0)
+ {
+ if (ACE_OS::strcmp (alist->getValue (i), ACE_TEXT ("inactive")) == 0)
+ {
+ info->active (0);
+ }
+ else if (ACE_OS::strcmp (alist->getValue (i), ACE_TEXT ("active")) == 0)
+ {
+ info->active (1);
+ }
+ else
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Invalid attribute value '"));
+ msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
+ msg += ACE_CString (ACE_TEXT ("', expecting 'active' or 'inactive'"));
+ msg += ACE_CString (ACE_TEXT (" for entity '"));
+ msg += ACE_CString (ACE_TEXT (info->name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()),
+ -1);
+ }
+ }
+ else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("type")) == 0)
+ {
+ if (ACE_OS::strcasecmp (alist->getValue (i), ACE_TEXT ("service_object")) == 0)
+ {
+ info->service_type (ACE_Service_Type::SERVICE_OBJECT);
+ }
+ else if (ACE_OS::strcasecmp (alist->getValue (i), ACE_TEXT ("stream")) == 0)
+ {
+ info->service_type (ACE_Service_Type::STREAM);
+ }
+ else if (ACE_OS::strcasecmp (alist->getValue (i), ACE_TEXT ("module")) == 0)
+ {
+ info->service_type (ACE_Service_Type::MODULE);
+ }
+ else
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Invalid Service_Object attribute value'"));
+ msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
+ msg += ACE_CString (ACE_TEXT ("' for entity '"));
+ msg += ACE_CString (ACE_TEXT (info->name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()),
+ -1);
+ }
+ }
+ else
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Invalid attribute'"));
+ msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
+ msg += ACE_CString (ACE_TEXT ("' for entity '"));
+ msg += ACE_CString (ACE_TEXT (info->name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()), -1);
+ }
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Svcconf_Handler::get_initializer_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
+{
+ if (alist != 0)
+ {
+ ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
+ &this->parsed_info_ :
+ &this->stream_info_);
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("init")) == 0)
+ {
+ info->init_func (alist->getValue (i));
+ }
+ else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("path")) == 0)
+ {
+ info->path (alist->getValue (i));
+ }
+ else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0)
+ {
+ info->init_params (alist->getValue (i));
+ }
+ else
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Invalid initializer attribute'"));
+ msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
+ msg += ACE_CString (ACE_TEXT ("' for entity '"));
+ msg += ACE_CString (ACE_TEXT (info->name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()), -1);
+ }
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Svcconf_Handler::get_static_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL)
+{
+ if (alist != 0)
+ {
+ ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ?
+ &this->parsed_info_ :
+ &this->stream_info_);
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0)
+ {
+ info->name (alist->getValue (i));
+ }
+ else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0)
+ {
+ info->init_params (alist->getValue (i));
+ }
+ else
+ {
+ // build the error message
+ ACE_CString msg (ACE_TEXT ("Invalid static attribute '"));
+ msg += ACE_CString (ACE_TEXT (alist->getQName (i)));
+ msg += ACE_CString (ACE_TEXT ("' for entity '"));
+ msg += ACE_CString (ACE_TEXT (info->name ()));
+ msg += ACE_CString (ACE_TEXT ("'\n"));
+
+ ACEXML_THROW_RETURN (ACEXML_SAXException (msg.c_str ()), -1);
+ }
+ }
+ }
+ return 0;
+}
+
+#endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */
diff --git a/ACE/ACEXML/apps/svcconf/Svcconf_Handler.h b/ACE/ACEXML/apps/svcconf/Svcconf_Handler.h
new file mode 100644
index 00000000000..c9093f9bd7a
--- /dev/null
+++ b/ACE/ACEXML/apps/svcconf/Svcconf_Handler.h
@@ -0,0 +1,292 @@
+// $Id$
+
+//=============================================================================
+/**
+ * @file Svcconf_Handler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef ACEXML_SVCCONF_HANDLER_H
+#define ACEXML_SVCCONF_HANDLER_H
+
+#include "ACEXML/common/DefaultHandler.h"
+#include "ace/Service_Types.h"
+
+#if (ACE_USES_CLASSIC_SVC_CONF == 0)
+
+class ACE_Parsed_Info
+{
+public:
+ ACE_Parsed_Info ();
+ ~ACE_Parsed_Info ();
+
+ /**
+ * Set/get name of a parsed entity.
+ */
+ int name (const ACEXML_Char *n);
+ const ACEXML_Char *name (void);
+
+ /**
+ * Set/get type of a dynamic node.
+ */
+ int service_type (int type);
+ int service_type (void);
+
+ /**
+ * Set/Get active status.
+ */
+ int active (int a);
+ int active (void);
+
+ /**
+ * Set/get initializer path.
+ */
+ int path (const ACEXML_Char *n);
+ const ACEXML_Char *path (void);
+
+ /**
+ * Set/get initializer init function.
+ */
+ int init_func (const ACEXML_Char *n);
+ const ACEXML_Char *init_func (void);
+
+ /**
+ * Set/get initializer init parameter.
+ */
+ int init_params (const ACEXML_Char *n);
+ const ACEXML_Char *init_params (void);
+
+ /**
+ * Reset Parsed_Info.
+ */
+ void reset (void);
+
+protected:
+ ACEXML_Char *name_;
+ int service_type_;
+ int active_;
+ ACEXML_Char *path_;
+ ACEXML_Char *init_func_;
+ ACEXML_Char *init_params_;
+};
+
+/**
+ * @class ACEXML_Svcconf_Handler
+ *
+ * @brief ACEXML_Svcconf_Handler is an example SAX event handler.
+ *
+ * This SAX event handler try to regenerate the XML document it
+ * reads with correct indentation.
+ */
+class ACEXML_Svcconf_Handler : public ACEXML_DefaultHandler
+{
+public:
+ /*
+ * Default constructor.
+ */
+ ACEXML_Svcconf_Handler (void);
+
+ /*
+ * Default destructor.
+ */
+ virtual ~ACEXML_Svcconf_Handler (void);
+
+ // Methods inherit from ACEXML_ContentHandler.
+
+ /*
+ * Receive notification of character data.
+ */
+ virtual void characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the end of a document.
+ */
+ virtual void endDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the end of an element.
+ */
+ virtual void endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * End the scope of a prefix-URI mapping.
+ */
+ virtual void endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of ignorable whitespace in element content.
+ */
+ virtual void ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a processing instruction.
+ */
+ virtual void processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive an object for locating the origin of SAX document events.
+ */
+ virtual void setDocumentLocator (ACEXML_Locator *locator) ;
+
+ /*
+ * Receive notification of a skipped entity.
+ */
+ virtual void skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the beginning of a document.
+ */
+ virtual void startDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the beginning of an element.
+ */
+ virtual void startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Begin the scope of a prefix-URI Namespace mapping.
+ */
+ virtual void startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // *** Methods inherit from ACEXML_DTDHandler.
+
+ /*
+ * Receive notification of a notation declaration event.
+ */
+ virtual void notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of an unparsed entity declaration event.
+ */
+ virtual void unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // Methods inherit from ACEXML_EnitityResolver.
+
+ /*
+ * Allow the application to resolve external entities.
+ */
+ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // Methods inherit from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+ virtual void error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a non-recoverable error.
+ */
+ virtual void fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a warning.
+ */
+ virtual void warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+protected:
+ /**
+ * Get the only attribute in <stream> or <streamdef>.
+ */
+ int get_stream_id (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL);
+
+ /**
+ * Get the only attribute in <resume>, <suspend>, <remove>
+ */
+ int get_id (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL);
+
+ /**
+ * Get the dynamic tag attributes.
+ */
+ int get_dynamic_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL);
+
+ /**
+ * Get the initializer tag attributes.
+ */
+ int get_initializer_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL);
+
+ /**
+ * Get the static tag attributes.
+ */
+ int get_static_attrs (ACEXML_Attributes *alist ACEXML_ENV_ARG_DECL);
+
+private:
+ /// We are parsing a stream definition
+ int in_stream_def_;
+
+ /// We are defining a steam module
+ int in_module_;
+
+ /// @a stream_ holds the actually Stream_Type object managed by @a stream_svc_type_.
+ ACE_Service_Type *stream_svc_type_;
+ ACE_Stream_Type *stream_;
+
+ //ACE_SHLIB_HANDLE dll_handle_;
+
+ ACE_Parsed_Info parsed_info_;
+
+ ACE_Parsed_Info stream_info_;
+
+ ACEXML_Locator* locator_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "Svcconf_Handler.i"
+#endif /* __ACEXML_INLINE__ */
+
+#endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */
+
+#endif /* ACEXML_SVCCONF_HANDLER_H */
diff --git a/ACE/ACEXML/apps/svcconf/Svcconf_Handler.i b/ACE/ACEXML/apps/svcconf/Svcconf_Handler.i
new file mode 100644
index 00000000000..605dec5f2f7
--- /dev/null
+++ b/ACE/ACEXML/apps/svcconf/Svcconf_Handler.i
@@ -0,0 +1,133 @@
+// -*- C++ -*- $Id$
+
+ACE_INLINE
+ACE_Parsed_Info::ACE_Parsed_Info ()
+ : name_ (0),
+ service_type_ (ACE_Service_Type::INVALID_TYPE),
+ active_ (1),
+ path_ (0),
+ init_func_ (0),
+ init_params_ (0)
+{
+}
+
+ACE_INLINE
+ACE_Parsed_Info::~ACE_Parsed_Info ()
+{
+ delete[] this->name_;
+ delete[] this->path_;
+ delete[] this->init_func_;
+ delete[] this->init_params_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::name (const ACEXML_Char *n)
+{
+ if (this->name_ == 0)
+ {
+ this->name_ = ACE::strnew (n);
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE const ACEXML_Char *
+ACE_Parsed_Info::name (void)
+{
+ return this->name_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::service_type (int type)
+{
+ if (this->service_type_ == -1)
+ {
+ this->service_type_ = type;
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::service_type (void)
+{
+ return this->service_type_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::active (int a)
+{
+ this->active_ = a;
+ return 0;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::active (void)
+{
+ return this->active_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::path (const ACEXML_Char *p)
+{
+ if (this->path_ == 0)
+ {
+ this->path_ = ACE::strnew (p);
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE const ACEXML_Char *
+ACE_Parsed_Info::path (void)
+{
+ return this->path_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::init_func (const ACEXML_Char *n)
+{
+ if (this->init_func_ == 0)
+ {
+ this->init_func_ = ACE::strnew (n);
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE const ACEXML_Char *
+ACE_Parsed_Info::init_func (void)
+{
+ return this->init_func_;
+}
+
+ACE_INLINE int
+ACE_Parsed_Info::init_params (const ACEXML_Char *n)
+{
+ if (this->init_params_ == 0)
+ {
+ this->init_params_ = ACE::strnew (n);
+ return 0;
+ }
+ return -1;
+}
+
+ACE_INLINE const ACEXML_Char *
+ACE_Parsed_Info::init_params (void)
+{
+ return this->init_params_;
+}
+
+ACE_INLINE void
+ACE_Parsed_Info::reset (void)
+{
+ delete[] this->name_;
+ this->name_ = 0;
+ this->service_type_ = -1;
+ delete[] this->path_;
+ this->path_ = 0;
+ delete[] this->init_func_;
+ this->init_func_ = 0;
+ delete[] this->init_params_;
+ this->init_params_ = 0;
+}
diff --git a/ACE/ACEXML/apps/svcconf/svcconf.dtd b/ACE/ACEXML/apps/svcconf/svcconf.dtd
new file mode 100644
index 00000000000..b9e6cc41c8e
--- /dev/null
+++ b/ACE/ACEXML/apps/svcconf/svcconf.dtd
@@ -0,0 +1,60 @@
+<!-- $Id$ -->
+<!-- Document Type Definition for XML ACE Service Config files -->
+
+<!-- An ACE_Svc_Conf document contains zero or more entries -->
+<!-- The entries are processed in the order they appear -->
+<!-- in the ACE_Svc_Conf file. -->
+<!ELEMENT ACE_Svc_Conf (dynamic|static|suspend|resume|remove|stream|streamdef)*>
+
+<!-- Streams are separate into two elements. One defines how -->
+<!-- the stream should be constructed and the other defines -->
+<!-- what to do with it. The identity of a stream is defined -->
+<!-- in the first dynamic/static element. -->
+<!ELEMENT streamdef ((dynamic|static),module)>
+<!-- @@ Do we ever need to suspend/resume/remove modules when -->
+<!-- constructing a stream? Should we leave only dynamic -->
+<!-- and static here? -->
+<!ELEMENT module (dynamic|static|suspend|resume|remove)+>
+
+<!-- A 'stream' element controls the stream object -->
+<!-- @@ Likewise, we are reusing the 'module' element here. -->
+<!-- Do we ever need to insert new modules into a stream? -->
+<!-- Nanbor: I guess we can do that. -->
+<!ELEMENT stream (module)>
+<!ATTLIST stream id IDREF #REQUIRED>
+
+<!-- A 'dynamic' entry. -->
+<!-- @@ The kind of attributes the corresponding initializer -->
+<!-- should take seems to be determined by the 'type' -->
+<!-- attribute. Should we further partition the dynamic -->
+<!-- element definition into several elements? E.g. into -->
+<!-- dyn_service_object/dyn_module/dyn_stream? -->
+<!-- Nanbor: Will that be too confusing? -->
+<!ELEMENT dynamic (initializer)>
+<!ATTLIST dynamic id ID #REQUIRED
+ status (active|inactive) "active"
+ type (module|service_object|stream) #REQUIRED>
+
+<!-- Initializing function for dynamic entry. -->
+<!ELEMENT initializer EMPTY>
+<!ATTLIST initializer init CDATA #REQUIRED
+ path CDATA #IMPLIED
+ params CDATA #IMPLIED>
+
+<!-- A 'static' entry takes an ID attribute and an optional -->
+<!-- parameter lists. -->
+<!ELEMENT static EMPTY>
+<!ATTLIST static id ID #REQUIRED
+ params CDATA #IMPLIED>
+
+<!-- A 'suspend' entry takes an ID attribute. -->
+<!ELEMENT suspend EMPTY>
+<!ATTLIST suspend id IDREF #REQUIRED>
+
+<!-- A 'resume' entry takes an ID attribute. -->
+<!ELEMENT resume EMPTY>
+<!ATTLIST resume id IDREF #REQUIRED>
+
+<!-- A 'remove' entry takes an ID attribute. -->
+<!ELEMENT remove EMPTY>
+<!ATTLIST remove id IDREF #REQUIRED>
diff --git a/ACE/ACEXML/apps/svcconf/svcconf.mpc b/ACE/ACEXML/apps/svcconf/svcconf.mpc
new file mode 100644
index 00000000000..9b9f84b5413
--- /dev/null
+++ b/ACE/ACEXML/apps/svcconf/svcconf.mpc
@@ -0,0 +1,6 @@
+// -*- MPC -*-
+// $Id$
+
+project(ACEXML_XML_Svc_Conf_Parser): acelib, acexml, core {
+ sharedname = ACEXML_XML_Svc_Conf_Parser
+}
diff --git a/ACE/ACEXML/common/ACEXML.pc.in b/ACE/ACEXML/common/ACEXML.pc.in
new file mode 100644
index 00000000000..78a706c17c0
--- /dev/null
+++ b/ACE/ACEXML/common/ACEXML.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ACEXML
+Description: ACE XML Library
+Requires: ACE
+Version: @VERSION@
+Libs: -L${libdir} -lACEXML
+Cflags: -I${includedir}
diff --git a/ACE/ACEXML/common/ACEXML_Export.h b/ACE/ACEXML/common/ACEXML_Export.h
new file mode 100644
index 00000000000..39546eeafcc
--- /dev/null
+++ b/ACE/ACEXML/common/ACEXML_Export.h
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ACEXML_Export.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+// Definition for Win32 Export directives.
+// This file is generated automatically by generate_export_file.pl
+// ------------------------------
+#ifndef ACEXML_EXPORT_H
+#define ACEXML_EXPORT_H
+
+#include "ace/config-all.h"
+
+#if defined (ACE_AS_STATIC_LIBS)
+# if !defined (ACEXML_HAS_DLL)
+# define ACEXML_HAS_DLL 0
+# endif /* ! ACEXML_HAS_DLL */
+#else
+# if !defined (ACEXML_HAS_DLL)
+# define ACEXML_HAS_DLL 1
+# endif /* ! ACEXML_HAS_DLL */
+#endif /* ACE_AS_STATIC_LIB */
+
+#if defined (ACEXML_HAS_DLL) && (ACEXML_HAS_DLL == 1)
+# if defined (ACEXML_BUILD_DLL)
+# define ACEXML_Export ACE_Proper_Export_Flag
+# define ACEXML_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define ACEXML_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* ACEXML_BUILD_DLL */
+# define ACEXML_Export ACE_Proper_Import_Flag
+# define ACEXML_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define ACEXML_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* ACEXML_BUILD_DLL */
+#else /* ACEXML_HAS_DLL == 1 */
+# define ACEXML_Export
+# define ACEXML_SINGLETON_DECLARATION(T)
+# define ACEXML_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* ACEXML_HAS_DLL == 1 */
+
+#endif /* ACEXML_EXPORT_H */
+
+// End of auto generated file.
diff --git a/ACE/ACEXML/common/Attributes.cpp b/ACE/ACEXML/common/Attributes.cpp
new file mode 100644
index 00000000000..3f7c758ce8f
--- /dev/null
+++ b/ACE/ACEXML/common/Attributes.cpp
@@ -0,0 +1,11 @@
+#include "Attributes.h"
+
+
+ACE_RCSID (common,
+ Attributes,
+ "$Id$")
+
+
+ACEXML_Attributes::~ACEXML_Attributes (void)
+{
+}
diff --git a/ACE/ACEXML/common/Attributes.h b/ACE/ACEXML/common/Attributes.h
new file mode 100644
index 00000000000..45982ed459e
--- /dev/null
+++ b/ACE/ACEXML/common/Attributes.h
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Attributes.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_ATTRIBUTES_H_
+#define _ACEXML_ATTRIBUTES_H_
+#include /**/ "ace/pre.h"
+
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+
+/**
+ * @class ACEXML_Attributes Attributes.h "ACEXML/common/Attributes.h"
+ *
+ * @brief ACEXML_Attributes defines a collection of attributes of an XML element.
+ *
+ * This is an abstract class (interface in Java) that defines
+ * the API for accessing attributes of an XML entity.
+ *
+ * This interface allows access to a list of attributes in three different ways:
+ *
+ * - by attribute index;
+ * - by Namespace-qualified name; or
+ * - by qualified (prefixed) name.
+ *
+ * The list will not contain attributes that were declared #IMPLIED
+ * but not specified in the start tag. It will also not contain
+ * attributes used as Namespace declarations (xmlns*) unless the
+ * http://xml.org/sax/features/namespace-prefixes feature is set to
+ * true (it is false by default).
+ *
+ * If the namespace-prefixes feature (see above) is false, access by
+ * qualified name may not be available; if the
+ * http://xml.org/sax/features/namespaces feature is false, access by
+ * Namespace-qualified names may not be available.
+ *
+ * This interface replaces the now-deprecated SAX1 AttributeList
+ * interface, which does not contain Namespace support. In addition to
+ * Namespace support, it adds the getIndex methods (below).
+ *
+ * The order of attributes in the list is unspecified, and will vary
+ * from implementation to implementation.
+ */
+class ACEXML_Export ACEXML_Attributes
+{
+public:
+
+ /// Destructor.
+ virtual ~ACEXML_Attributes (void);
+
+ /**
+ * Look up the index of an attribute by XML 1.0 qualified name.
+ */
+ virtual int getIndex (const ACEXML_Char *qName) = 0;
+
+ /**
+ * Look up the index of an attribute by Namespace name.
+ */
+ virtual int getIndex (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart) = 0;
+
+ /**
+ * Return the number of attributes in the list.
+ */
+ virtual size_t getLength (void) = 0;
+
+ /**
+ * Look up an attribute's local name by index.
+ */
+ virtual const ACEXML_Char *getLocalName (size_t index) = 0;
+
+ /**
+ * Look up an attribute's XML 1.0 qualified name by index.
+ */
+ virtual const ACEXML_Char *getQName (size_t index) = 0;
+
+ /**
+ * Look up an attribute's type by index.
+ */
+ virtual const ACEXML_Char *getType (size_t index) = 0;
+
+ /**
+ * Look up an attribute's type by XML 1.0 qualified name.
+ */
+ virtual const ACEXML_Char *getType (const ACEXML_Char *qName) = 0;
+
+ /**
+ * Look up an attribute's type by Namespace name.
+ */
+ virtual const ACEXML_Char *getType (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart) = 0;
+
+ /**
+ * Look up an attribute's Namespace URI by index.
+ */
+ virtual const ACEXML_Char *getURI (size_t index) = 0;
+
+ /**
+ * Look up an attribute's value by index.
+ */
+ virtual const ACEXML_Char *getValue (size_t index) = 0;
+
+ /**
+ * Look up an attribute's value by XML 1.0 qualified name.
+ */
+ virtual const ACEXML_Char *getValue (const ACEXML_Char *qName) = 0;
+
+ /**
+ * Look up an attribute's value by Namespace name.
+ */
+ virtual const ACEXML_Char *getValue (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart) = 0;
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ ATTRIBUTES_H_ */
diff --git a/ACE/ACEXML/common/AttributesImpl.cpp b/ACE/ACEXML/common/AttributesImpl.cpp
new file mode 100644
index 00000000000..a11d34c52e2
--- /dev/null
+++ b/ACE/ACEXML/common/AttributesImpl.cpp
@@ -0,0 +1,293 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/AttributesImpl.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/common/AttributesImpl.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_AttributesImpl::ACEXML_AttributesImpl (int size)
+ : attrs_ (size)
+{
+ this->attrs_.size (0); // attrs array contains nothing
+}
+
+ACEXML_AttributesImpl::ACEXML_AttributesImpl (const
+ ACEXML_AttributesImpl &attrs)
+ : ACEXML_Attributes (attrs),
+ attrs_ (attrs.attrs_.size ())
+{
+ for (size_t i = 0; i < attrs.attrs_.size (); i++)
+ this->attrs_[i] = attrs.attrs_[i];
+}
+
+ACEXML_AttributesImpl::~ACEXML_AttributesImpl (void)
+{
+}
+
+int
+ACEXML_AttributesImpl::addAttribute (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value)
+{
+ if (this->isDuplicate (uri, localName, qName))
+ return -1;
+ size_t length = this->attrs_.size ();
+ this->attrs_.size (length+1);
+ this->setAttribute (length,
+ uri,
+ localName,
+ qName,
+ type,
+ value);
+ return static_cast<int> (length);
+}
+
+int
+ACEXML_AttributesImpl::addAttribute (const ACEXML_Attribute &att)
+{
+ if (this->isDuplicate (att.uri(), att.localName(), att.qName()))
+ return -1;
+ size_t length = this->attrs_.size ();
+ this->attrs_.size (length+1);
+ this->attrs_[length] = att;
+ return static_cast<int> (length);
+}
+
+int
+ACEXML_AttributesImpl::isDuplicate (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName)
+{
+ for (size_t i = 0; i < this->attrs_.size(); ++i)
+ {
+ if (ACE_OS::strcmp (this->attrs_[i].localName(), localName) == 0)
+ {
+ if (qName != 0 && this->attrs_[i].qName() != 0
+ && ACE_OS::strcmp (this->attrs_[i].qName(), qName) == 0)
+ {
+ if (uri != 0 && this->attrs_[i].uri() != 0
+ && ACE_OS::strcmp (this->attrs_[i].uri(), uri) == 0)
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_AttributesImpl::removeAttribute (size_t index)
+{
+ size_t length = this->attrs_.size ();
+
+ if (index >= length)
+ return -1;
+
+ this->attrs_[index] = this->attrs_[length - 1];
+ this->attrs_.size (length - 1);
+
+ return 0;
+}
+
+
+int
+ACEXML_AttributesImpl::getIndex (const ACEXML_Char *qName)
+{
+ for (size_t i = 0; i < this->attrs_.size (); i++)
+ if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0)
+ return static_cast<int> (i);
+
+ return -1;
+}
+
+int
+ACEXML_AttributesImpl::getIndex (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart)
+{
+ for (size_t i = 0; i < this->attrs_.size (); i++)
+ if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 &&
+ ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0)
+ return static_cast<int> (i);
+
+ return -1;
+}
+
+size_t
+ACEXML_AttributesImpl::getLength (void)
+{
+ return this->attrs_.size ();
+}
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getLocalName (size_t index)
+{
+ if (index < this->attrs_.size ())
+ return this->attrs_[index].localName ();
+ return 0;
+}
+
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getQName (size_t index)
+{
+ if (index < this->attrs_.size ())
+ return this->attrs_[index].qName ();
+ return 0;
+}
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getType (size_t index)
+{
+ if (index < this->attrs_.size ())
+ return this->attrs_[index].type ();
+ return 0;
+}
+
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getType (const ACEXML_Char *qName)
+{
+ for (size_t i = 0; i < this->attrs_.size (); i++)
+ if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0)
+ return this->attrs_[i].type ();
+
+ return 0;
+}
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getType (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart)
+{
+ for (size_t i = 0; i < this->attrs_.size (); i++)
+ if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 &&
+ ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0)
+ return this->attrs_[i].type ();
+
+ return 0;
+}
+
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getURI (size_t index)
+{
+ if (index < this->attrs_.size ())
+ return this->attrs_[index].uri ();
+ return 0;
+}
+
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getValue (size_t index)
+{
+ if (index < this->attrs_.size ())
+ return this->attrs_[index].value ();
+ return 0;
+}
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getValue (const ACEXML_Char *qName)
+{
+ for (size_t i = 0; i < this->attrs_.size (); i++)
+ if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0)
+ return this->attrs_[i].value ();
+
+ return 0;
+}
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getValue (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart)
+{
+ for (size_t i = 0; i < this->attrs_.size (); i++)
+ if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 &&
+ ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0)
+ return this->attrs_[i].value ();
+
+ return 0;
+}
+
+int
+ACEXML_AttributesImpl::setAttribute (size_t index,
+ const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value)
+{
+ if (index < this->attrs_.size ())
+ {
+ this->attrs_[index].setAttribute (uri,
+ localName,
+ qName,
+ type,
+ value);
+ return 0;
+ }
+
+ return -1;
+}
+
+
+int
+ACEXML_AttributesImpl::setLocalName (size_t index,
+ const ACEXML_Char *localName)
+{
+ if (index < this->attrs_.size ())
+ {
+ this->attrs_[index].localName (localName);
+ return 0;
+ }
+ return -1;
+}
+
+int
+ACEXML_AttributesImpl::setQName (size_t index,
+ const ACEXML_Char *qName)
+{
+ if (index < this->attrs_.size ())
+ {
+ this->attrs_[index].qName (qName);
+ return 0;
+ }
+ return -1;
+}
+
+
+int
+ACEXML_AttributesImpl::setURI (size_t index,
+ const ACEXML_Char *uri)
+{
+ if (index < this->attrs_.size ())
+ {
+ this->attrs_[index].uri (uri);
+ return 0;
+ }
+ return -1;
+}
+
+int
+ACEXML_AttributesImpl::setType (size_t index,
+ const ACEXML_Char *type)
+{
+ if (index < this->attrs_.size ())
+ {
+ this->attrs_[index].type (type);
+ return 0;
+ }
+ return -1;
+}
+
+int
+ACEXML_AttributesImpl::setValue (size_t index,
+ const ACEXML_Char *value)
+{
+ if (index < this->attrs_.size ())
+ {
+ this->attrs_[index].value (value);
+ return 0;
+ }
+ return -1;
+}
+
diff --git a/ACE/ACEXML/common/AttributesImpl.h b/ACE/ACEXML/common/AttributesImpl.h
new file mode 100644
index 00000000000..85c48ed1c2e
--- /dev/null
+++ b/ACE/ACEXML/common/AttributesImpl.h
@@ -0,0 +1,309 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file AttributesImpl.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef ACEXML_ATTRIBUTESIMPL_H
+#define ACEXML_ATTRIBUTESIMPL_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Attributes.h"
+#include "ace/Containers_T.h"
+
+#if !defined ACEXML_AttributesImpl_Default_Size
+#define ACEXML_AttributesImpl_Default_Size 20
+#endif /* ACEXML_AttributesImpl_Default_Size */
+
+class ACEXML_AttributesImpl;
+
+/**
+ * @class ACEXML_Attribute AttributesImpl.h "ACEXML/common/AttributesImpl.h"
+ *
+ * @brief ACEXML_Attribute defines the data structure of an attribute
+ *
+ * @sa ACEXML_AttributesImpl
+ */
+class ACEXML_Export ACEXML_Attribute
+{
+public:
+ friend class ACEXML_AttributesImpl;
+
+ /// Default constructor.
+ ACEXML_Attribute (void);
+
+ /// Copy constructor.
+ ACEXML_Attribute (const ACEXML_Attribute &attr);
+
+ /// Initialize all constructor.
+ ACEXML_Attribute (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value);
+
+ /// Destructor.
+ ~ACEXML_Attribute (void);
+
+ /// Set all members.
+ void setAttribute (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value);
+
+ /// Get \a uri_.
+ const ACEXML_Char *uri (void) const;
+
+ /// Set \a uri_.
+ void uri (const ACEXML_Char *uri);
+
+ /// Get \a localName_.
+ const ACEXML_Char *localName (void) const;
+
+ /// Set \a localName_.
+ void localName (const ACEXML_Char *localName);
+
+ /// Get \a qName_.
+ const ACEXML_Char *qName (void) const;
+
+ /// Set \a qName_.
+ void qName (const ACEXML_Char *qName);
+
+ /// Get \a type_.
+ const ACEXML_Char *type (void) const;
+
+ /// Set \a type_.
+ void type (const ACEXML_Char *type);
+
+ /// Get \a value_.
+ const ACEXML_Char *value (void) const;
+
+ /// Set \a value_.
+ void value (const ACEXML_Char *value);
+
+ /// Assignment operator.
+ ACEXML_Attribute &operator= (const ACEXML_Attribute &rhs);
+
+ /// Comparison operator.
+ bool operator!= (const ACEXML_Attribute&rhs) const;
+
+private:
+ /// Namespace URI of an attribute
+ ACEXML_Char *uri_;
+
+ ACEXML_Char *localName_;
+ ACEXML_Char *qName_;
+ ACEXML_Char *type_;
+ ACEXML_Char *value_;
+};
+
+/**
+ * @typedef ACE_Array<ACEXML_Attribute> ACEXML_Attribute_Array
+ */
+typedef ACE_Array<ACEXML_Attribute> ACEXML_Attribute_Array;
+
+/**
+ * @class ACEXML_AttributesImpl AttributesImpl.h "ACEXML/common/AttributesImpl.h"
+ *
+ * @brief ACEXML_AttributesImpl provides the default implementation
+ * of interface ACEXML_Attributes.
+ *
+ * This class provides a default implementation of the SAX2 Attributes
+ * interface, with the addition of manipulators so that the list can
+ * be modified or reused.
+ *
+ * There are two typical uses of this class:
+ *
+ * - to take a persistent snapshot of an Attributes object in a
+ * startElement event; or
+ * - to construct or modify an Attributes object in a SAX2 driver or filter.
+ *
+ * This class replaces the now-deprecated SAX1 AttributeListImpl
+ * class; in addition to supporting the updated Attributes interface
+ * rather than the deprecated AttributeList interface, it also
+ * includes a much more efficient implementation using a single array
+ * rather than a set of Vectors.
+ *
+ * @sa ACEXML_Attributes
+ */
+class ACEXML_Export ACEXML_AttributesImpl
+ : public ACEXML_Attributes
+{
+public:
+ /**
+ * Initialize an AttributesImpl that holds <size> attributes.
+ */
+ ACEXML_AttributesImpl (int size = ACEXML_AttributesImpl_Default_Size);
+ ACEXML_AttributesImpl (const ACEXML_AttributesImpl &attrs);
+ virtual ~ACEXML_AttributesImpl (void);
+
+ /**
+ * Add a new attribute using the argument(s) supplied.
+ * Return -1 if an attribute with the same name already exists.
+ */
+ virtual int addAttribute (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value);
+ virtual int addAttribute (const ACEXML_Attribute &att);
+
+ /**
+ * Check for duplicate attributes.
+ */
+ virtual int isDuplicate (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName);
+ /**
+ * Remove an attribute from the array. Notice that this
+ * operation can invalidate previously acquired <index>
+ * value. (It will repack the array.)
+ */
+ virtual int removeAttribute (size_t index);
+
+
+ /**
+ * Look up the index of an attribute by XML 1.0 qualified name.
+ * Return -1 if we fail to find a match.
+ */
+ virtual int getIndex (const ACEXML_Char *qName);
+
+ /**
+ * Look up the index of an attribute by Namespace name.
+ * Return -1 if we fail to find a match.
+ */
+ virtual int getIndex (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart);
+
+ /**
+ * Return the number of attributes in the list.
+ */
+ virtual size_t getLength (void);
+
+ /**
+ * Look up an attribute's local name by index.
+ * Return 0 if index is out of range.
+ */
+ virtual const ACEXML_Char *getLocalName (size_t index);
+
+ /**
+ * Look up an attribute's XML 1.0 qualified name by index.
+ * Return 0 if index is out of range.
+ */
+ virtual const ACEXML_Char *getQName (size_t index);
+
+ /**
+ * Look up an attribute's type by index.
+ * Return 0 if index is out of range.
+ */
+ virtual const ACEXML_Char *getType (size_t index);
+
+ /**
+ * Look up an attribute's type by XML 1.0 qualified name.
+ * Return 0 if we fail to find a match.
+ */
+ virtual const ACEXML_Char *getType (const ACEXML_Char *qName);
+
+ /**
+ * Look up an attribute's type by Namespace name.
+ * Return 0 if we fail to find a match.
+ */
+ virtual const ACEXML_Char *getType (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart);
+
+ /**
+ * Look up an attribute's Namespace URI by index.
+ * Return 0 if index is out of range.
+ */
+ virtual const ACEXML_Char *getURI (size_t index);
+
+ /**
+ * Look up an attribute's value by index.
+ * Return 0 if index is out of range.
+ */
+ virtual const ACEXML_Char *getValue (size_t index);
+
+ /**
+ * Look up an attribute's value by XML 1.0 qualified name.
+ * Return 0 if we fail to find a match.
+ */
+ virtual const ACEXML_Char *getValue (const ACEXML_Char *qName);
+
+ /**
+ * Look up an attribute's value by Namespace name.
+ * Return 0 if we fail to find a match.
+ */
+ virtual const ACEXML_Char *getValue (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart);
+
+ /**
+ * Set an attribute at index. Return -1 if index is out of
+ * range.
+ */
+ virtual int setAttribute (size_t index,
+ const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value);
+
+ /**
+ * Set the localName of the attribute at <index>.
+ * return -1 if <index> is out of range.
+ */
+ virtual int setLocalName (size_t index,
+ const ACEXML_Char *localName);
+
+ /**
+ * Set the qName of the attribute at <index>.
+ * return -1 if <index> is out of range.
+ */
+ virtual int setQName (size_t index,
+ const ACEXML_Char *qName);
+
+ /**
+ * Set the URI of the attribute at <index>.
+ * return -1 if <index> is out of range.
+ */
+ virtual int setURI (size_t index,
+ const ACEXML_Char *uri);
+
+ /**
+ * Set the type of the attribute at <index>.
+ * return -1 if <index> is out of range.
+ */
+ virtual int setType (size_t index,
+ const ACEXML_Char *type);
+
+ /**
+ * Set the value of the attribute at <index>.
+ * return -1 if <index> is out of range.
+ */
+ virtual int setValue (size_t index,
+ const ACEXML_Char *value);
+private:
+ /// Container for all attributes.
+ ACEXML_Attribute_Array attrs_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/AttributesImpl.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* ACEXML_ATTRIBUTESIMPL_H */
diff --git a/ACE/ACEXML/common/AttributesImpl.i b/ACE/ACEXML/common/AttributesImpl.i
new file mode 100644
index 00000000000..75fc288950d
--- /dev/null
+++ b/ACE/ACEXML/common/AttributesImpl.i
@@ -0,0 +1,154 @@
+// -*- C++ -*-
+//
+//$Id$
+
+#include "ace/ACE.h"
+#include "ace/OS_NS_string.h"
+
+ACEXML_INLINE
+ACEXML_Attribute::ACEXML_Attribute (void)
+ : uri_ (0),
+ localName_ (0),
+ qName_ (0),
+ type_ (0),
+ value_ (0)
+{
+}
+
+ACEXML_INLINE
+ACEXML_Attribute::ACEXML_Attribute (const ACEXML_Attribute &attr)
+ : uri_ (ACE::strnew (attr.uri_)),
+ localName_ (ACE::strnew (attr.localName_)),
+ qName_ (ACE::strnew (attr.qName_)),
+ type_ (ACE::strnew (attr.type_)),
+ value_ (ACE::strnew (attr.value_))
+{
+}
+
+ACEXML_INLINE
+ACEXML_Attribute::ACEXML_Attribute (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value)
+ : uri_ (ACE::strnew (uri)),
+ localName_ (ACE::strnew (localName)),
+ qName_ (ACE::strnew (qName)),
+ type_ (ACE::strnew (type)),
+ value_ (ACE::strnew (value))
+{
+}
+
+ACEXML_INLINE
+ACEXML_Attribute::~ACEXML_Attribute (void)
+{
+ delete[] this->uri_;
+ delete[] this->localName_;
+ delete[] this->qName_;
+ delete[] this->type_;
+ delete[] this->value_;
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_Attribute::uri (void) const
+{
+ return this->uri_;
+}
+
+ACEXML_INLINE void
+ACEXML_Attribute::uri (const ACEXML_Char *uri)
+{
+ delete[] this->uri_;
+ this->uri_ = ACE::strnew (uri);
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_Attribute::localName (void) const
+{
+ return this->localName_;
+}
+
+ACEXML_INLINE void
+ACEXML_Attribute::localName (const ACEXML_Char *localName)
+{
+ delete[] this->localName_;
+ this->localName_ = ACE::strnew (localName);
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_Attribute::qName (void) const
+{
+ return this->qName_;
+}
+
+ACEXML_INLINE void
+ACEXML_Attribute::qName (const ACEXML_Char *qName)
+{
+ delete[] this->qName_;
+ this->qName_ = ACE::strnew (qName);
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_Attribute::type (void) const
+{
+ return this->type_;
+}
+
+ACEXML_INLINE void
+ACEXML_Attribute::type (const ACEXML_Char *type)
+{
+ delete[] this->type_;
+ this->type_ = ACE::strnew (type);
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_Attribute::value (void) const
+{
+ return this->value_;
+}
+
+ACEXML_INLINE void
+ACEXML_Attribute::value (const ACEXML_Char *value)
+{
+ delete[] this->value_;
+ this->value_ = ACE::strnew (value);
+}
+
+ACEXML_INLINE void
+ACEXML_Attribute::setAttribute (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value)
+{
+ this->uri (uri);
+ this->qName (qName);
+ this->localName (localName);
+ this->type (type);
+ this->value (value);
+}
+
+ACEXML_INLINE ACEXML_Attribute &
+ACEXML_Attribute::operator= (const ACEXML_Attribute &rhs)
+{
+ if (this != &rhs) // Check for self assignment
+ {
+ this->uri (rhs.uri ());
+ this->qName (rhs.qName ());
+ this->localName (rhs.localName ());
+ this->type (rhs.type ());
+ this->value (rhs.value ());
+ }
+ return *this;
+}
+
+ACEXML_INLINE bool
+ACEXML_Attribute::operator!= (const ACEXML_Attribute &rhs) const
+{
+ return (ACE_OS::strcmp (this->uri_, rhs.uri ()) == 0 &&
+ ACE_OS::strcmp (this->localName_, rhs.localName ()) == 0 &&
+ ACE_OS::strcmp (this->qName_, rhs .qName ()) == 0 &&
+ ACE_OS::strcmp (this->type_, rhs.type ()) == 0 &&
+ ACE_OS::strcmp (this->value_, rhs.value ()) == 0 ? false : true);
+
+}
diff --git a/ACE/ACEXML/common/Attributes_Def_Builder.cpp b/ACE/ACEXML/common/Attributes_Def_Builder.cpp
new file mode 100644
index 00000000000..8b748dce3ce
--- /dev/null
+++ b/ACE/ACEXML/common/Attributes_Def_Builder.cpp
@@ -0,0 +1,14 @@
+// $Id$
+
+#include "ACEXML/common/Attributes_Def_Builder.h"
+
+ACEXML_Attribute_Def_Builder::~ACEXML_Attribute_Def_Builder ()
+{
+
+}
+
+ACEXML_Attributes_Def_Builder::~ACEXML_Attributes_Def_Builder ()
+{
+
+}
+
diff --git a/ACE/ACEXML/common/Attributes_Def_Builder.h b/ACE/ACEXML/common/Attributes_Def_Builder.h
new file mode 100644
index 00000000000..c0b5c144208
--- /dev/null
+++ b/ACE/ACEXML/common/Attributes_Def_Builder.h
@@ -0,0 +1,153 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Attributes_Def_Builder.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_ATTRIBUTES_DEF_BUILDER_H_
+#define _ACEXML_ATTRIBUTES_DEF_BUILDER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/SAXExceptions.h"
+#include "ace/Auto_Ptr.h"
+
+/**
+ * @class ACEXML_Attribute_Def_Builder Attributes_Def_Builder.h "common/Attributes_Def_Builder.h"
+ *
+ * @brief An abstract virtual class defining an interface for building an
+ * attribute definition from DTD.
+ *
+ * This class should be invisible to application programmers and is only
+ * used for validator implementors.
+ */
+class ACEXML_Export ACEXML_Attribute_Def_Builder
+{
+public:
+
+ typedef auto_ptr<ACEXML_Attribute_Def_Builder> VAR;
+
+ enum ATT_TYPE {
+ CDATA,
+ ID,
+ IDREF,
+ IDREFS,
+ ENTITY,
+ ENTITIES,
+ NMTOKEN,
+ NMTOKENS,
+ NOTATION,
+ ENUMERATION,
+ ERROR_TYPE
+ };
+
+ enum DEFAULT_DECL {
+ REQUIRED,
+ IMPLIED,
+ FIXED,
+ INVALID
+ };
+
+ virtual ~ACEXML_Attribute_Def_Builder () = 0;
+
+ /**
+ * Specify the name of the attribute.
+ */
+ virtual int setName (const ACEXML_Char *n) = 0;
+
+ /**
+ * Get the name of the attribute.
+ */
+ virtual const ACEXML_Char *getName (void) = 0;
+
+ /**
+ * Set the attribute type.
+ */
+ virtual int setAttType (const ATT_TYPE type ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Insert an element for NOTATION or ENUMERATION type attribute.
+ */
+ virtual int insertList (const ACEXML_Char *Name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Set default attribute declaration.
+ */
+ virtual int setDefault (const DEFAULT_DECL def,
+ const ACEXML_Char *value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Check validity of the current attribute definition being built.
+ *
+ * @retval 0 if the attribute is not a valid combo.
+ */
+ virtual int validAttr (void) = 0;
+
+ /**
+ * Dump the content of the attribute definition.
+ */
+ virtual void dump (void) = 0;
+};
+
+/**
+ * @ class ACEXML_Attributes_Def_Builder Attributes_Def_Builder.h "common/Attributes_Def_Builder.h"
+ *
+ * @ brief An abstract virtual class defining an interface for building
+ * attribute definitions from DTD.
+ *
+ * This class should be invisible to application programmers and
+ * is only used for validator implementors.
+ */
+class ACEXML_Export ACEXML_Attributes_Def_Builder
+{
+public:
+
+ typedef auto_ptr<ACEXML_Attributes_Def_Builder> VAR;
+
+ virtual ~ACEXML_Attributes_Def_Builder () = 0;
+
+ /**
+ * Set the element name that the attribute builder applies.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int setElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Acquire an Attribute_Builder.
+ */
+ virtual ACEXML_Attribute_Def_Builder *getAttribute_Def_Builder () = 0;
+
+ /**
+ * Add a definition for one attribute.
+ */
+ virtual int insertAttribute (ACEXML_Attribute_Def_Builder *def ACEXML_ENV_ARG_DECL) = 0;
+
+
+ /**
+ * Dump the content of the attribute definition.
+ */
+ virtual void dump (void) = 0;
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ATTRIBUTES_DEF_BUILDER_H_ */
diff --git a/ACE/ACEXML/common/CharStream.cpp b/ACE/ACEXML/common/CharStream.cpp
new file mode 100644
index 00000000000..2c6ea29600f
--- /dev/null
+++ b/ACE/ACEXML/common/CharStream.cpp
@@ -0,0 +1,7 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/CharStream.h"
+
+ACEXML_CharStream::~ACEXML_CharStream (void)
+{
+}
diff --git a/ACE/ACEXML/common/CharStream.h b/ACE/ACEXML/common/CharStream.h
new file mode 100644
index 00000000000..e0355d4721a
--- /dev/null
+++ b/ACE/ACEXML/common/CharStream.h
@@ -0,0 +1,88 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file CharStream.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_CHARSTREAM_H_
+#define _ACEXML_CHARSTREAM_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+#include "ACEXML/common/XML_Types.h"
+
+/**
+ * @class ACEXML_CharStream CharStream.h "ACEXML/common/CharStream.h"
+ *
+ * ACEXML_CharStream is an abstract class (interface) which defines the
+ * basic opertions a parser could use to retrieve XML charater sequence.
+ * The sequence can be read from a file or a character buffer.
+ */
+class ACEXML_Export ACEXML_CharStream
+{
+public:
+
+ /**
+ * Virtual destructor, must have.
+ */
+ virtual ~ACEXML_CharStream () = 0;
+
+ /**
+ * Returns the available ACEXML_Char in the buffer. -1
+ * if the object is not initialized properly.
+ */
+ virtual int available (void) = 0;
+
+ /**
+ * Close this stream and release all resources used by it.
+ */
+ virtual int close (void) = 0;
+
+ /**
+ * Read the next ACEXML_Char. Return -1 if we are not able to
+ * return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed.
+ */
+ virtual int get (ACEXML_Char& ch) = 0;
+
+ /**
+ * Read the next batch of ACEXML_Char strings
+ */
+ virtual int read (ACEXML_Char *str, size_t len) = 0;
+
+ /**
+ * Peek the next ACEXML_Char in the CharStream. Return the
+ * character if succeess, -1 if EOS is reached.
+ */
+ virtual int peek (void) = 0;
+
+ /**
+ * Resets the pointer to the beginning of the stream.
+ */
+ virtual void rewind (void) = 0;
+
+ /*
+ * Get the character encoding for a byte stream or URI.
+ */
+ virtual const ACEXML_Char *getEncoding (void) = 0;
+
+ /*
+ * Get the systemId for the underlying CharStream
+ */
+ virtual const ACEXML_Char* getSystemId (void) = 0;
+
+};
+
+#include /**/ "ace/post.h"
+
+
+#endif /* _ACEXML_CHARSTREAM_H_ */
diff --git a/ACE/ACEXML/common/ContentHandler.cpp b/ACE/ACEXML/common/ContentHandler.cpp
new file mode 100644
index 00000000000..633342fd6b1
--- /dev/null
+++ b/ACE/ACEXML/common/ContentHandler.cpp
@@ -0,0 +1,11 @@
+#include "ContentHandler.h"
+
+
+ACE_RCSID (common,
+ ContentHandler,
+ "$Id$")
+
+
+ACEXML_ContentHandler::~ACEXML_ContentHandler (void)
+{
+}
diff --git a/ACE/ACEXML/common/ContentHandler.h b/ACE/ACEXML/common/ContentHandler.h
new file mode 100644
index 00000000000..f1bee32a75d
--- /dev/null
+++ b/ACE/ACEXML/common/ContentHandler.h
@@ -0,0 +1,131 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ContentHandler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_CONTENTHANDLER_H_
+#define _ACEXML_CONTENTHANDLER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/SAXExceptions.h"
+#include "ACEXML/common/Locator.h"
+#include "ACEXML/common/Attributes.h"
+
+/**
+ * @class ACEXML_ContentHandler ContentHandler.h "ACEXML/common/ContentHandler.h"
+ *
+ * @brief ACEXML_ContentHandler
+ *
+ * This is the main interface that most SAX applications implement: if the
+ * application needs to be informed of basic parsing events, it implements
+ * this interface and registers an instance with the SAX parser using the
+ * setContentHandler method. The parser uses the instance to report basic
+ * document-related events like the start and end of elements and character
+ * data.
+ *
+ * The order of events in this interface is very important, and mirrors the
+ * order of information in the document itself. For example, all of an
+ * element's content (character data, processing instructions, and/or
+ * subelements) will appear, in order, between the startElement event and
+ * the corresponding endElement event.
+ */
+class ACEXML_Export ACEXML_ContentHandler
+{
+public:
+
+ virtual ~ACEXML_ContentHandler (void);
+
+ /**
+ * Receive notification of character data.
+ */
+ virtual void characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of the end of a document.
+ */
+ virtual void endDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of the end of an element.
+ */
+ virtual void endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * End the scope of a prefix-URI mapping.
+ */
+ virtual void endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of ignorable whitespace in element content.
+ */
+ virtual void ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of a processing instruction.
+ */
+ virtual void processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive an object for locating the origin of SAX document events.
+ */
+ virtual void setDocumentLocator (ACEXML_Locator *locator) = 0;
+
+ /**
+ * Receive notification of a skipped entity.
+ */
+ virtual void skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of the beginning of a document.
+ */
+ virtual void startDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of the beginning of an element.
+ */
+ virtual void startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Begin the scope of a prefix-URI Namespace mapping.
+ */
+ virtual void startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+};
+
+#include /**/ "ace/post.h"
+
+
+#endif /* _ACEXML_CONTENTHANDLER_H_ */
diff --git a/ACE/ACEXML/common/DTDHandler.cpp b/ACE/ACEXML/common/DTDHandler.cpp
new file mode 100644
index 00000000000..199f469b578
--- /dev/null
+++ b/ACE/ACEXML/common/DTDHandler.cpp
@@ -0,0 +1,11 @@
+#include "DTDHandler.h"
+
+
+ACE_RCSID (common,
+ DTDHandler,
+ "$Id$")
+
+
+ACEXML_DTDHandler::~ACEXML_DTDHandler (void)
+{
+}
diff --git a/ACE/ACEXML/common/DTDHandler.h b/ACE/ACEXML/common/DTDHandler.h
new file mode 100644
index 00000000000..4f5f785552c
--- /dev/null
+++ b/ACE/ACEXML/common/DTDHandler.h
@@ -0,0 +1,78 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file DTDHandler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_DTDHANDLER_H_
+#define _ACEXML_DTDHANDLER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/SAXExceptions.h"
+
+/**
+ * @class ACEXML_DTDHandler DTDHandler.h "ACEXML/common/DTDHandler.h"
+ *
+ * @brief ACEXML_DTDHandler
+ *
+ * If a SAX application needs information about notations and unparsed
+ * entities, then the application implements this interface and registers
+ * an instance with the SAX parser using the parser's setDTDHandler method.
+ * The parser uses the instance to report notation and unparsed entity
+ * declarations to the application.
+ *
+ * Note that this interface includes only those DTD events that the XML
+ * recommendation requires processors to report: notation and unparsed
+ * entity declarations.
+ *
+ * The SAX parser may report these events in any order, regardless of the
+ * order in which the notations and unparsed entities were declared;
+ * however, all DTD events must be reported after the document handler's
+ * startDocument event, and before the first startElement event.
+ *
+ * It is up to the application to store the information for future use
+ * (perhaps in a hash table or object tree). If the application encounters
+ * attributes of type "NOTATION", "ENTITY", or "ENTITIES", it can use the
+ * information that it obtained through this interface to find the entity
+ * and/or notation corresponding with the attribute value.
+ */
+class ACEXML_Export ACEXML_DTDHandler
+{
+public:
+
+ virtual ~ACEXML_DTDHandler (void);
+
+ /**
+ * Receive notification of a notation declaration event.
+ */
+ virtual void notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of an unparsed entity declaration event.
+ */
+ virtual void unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_DTDHANDLER_H_ */
diff --git a/ACE/ACEXML/common/DTD_Manager.cpp b/ACE/ACEXML/common/DTD_Manager.cpp
new file mode 100644
index 00000000000..39b3d2acef0
--- /dev/null
+++ b/ACE/ACEXML/common/DTD_Manager.cpp
@@ -0,0 +1,8 @@
+// $Id$
+
+#include "ACEXML/common/DTD_Manager.h"
+
+ACEXML_DTD_Manager::~ACEXML_DTD_Manager ()
+{
+
+}
diff --git a/ACE/ACEXML/common/DTD_Manager.h b/ACE/ACEXML/common/DTD_Manager.h
new file mode 100644
index 00000000000..51ab3791551
--- /dev/null
+++ b/ACE/ACEXML/common/DTD_Manager.h
@@ -0,0 +1,82 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file DTD_Manager.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_DTD_Manager_H_
+#define _ACEXML_DTD_Manager_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Attributes_Def_Builder.h"
+#include "ACEXML/common/Element_Def_Builder.h"
+#include "ACEXML/common/Validator.h"
+
+/**
+ * @class ACEXML_DTD_Manager DTD_Manager.h "common/DTD_Manager.h"
+ *
+ * @todo Fill in the blank.
+ */
+class ACEXML_Export ACEXML_DTD_Manager
+{
+public:
+ virtual ~ACEXML_DTD_Manager () = 0;
+
+ /**
+ * Acquire a pointer to an element definition builder.
+ * The XML parser use this interface to acquire the
+ * definition builder and use the builder to create
+ * the DTD element definition. The resulting builder
+ * is then registered with the DTD Manager or destroyed
+ * if error occured when the builder encountered errors.
+ *
+ * @retval 0 if error occurs creating the builder.
+ */
+ virtual ACEXML_Element_Def_Builder *getElement_Def_Builder () = 0;
+
+ /**
+ * Insert a new element definition into the DTD Manager.
+ *
+ * @retval 0 if success, -1 if error.
+ */
+ virtual int insertElement_Definition (ACEXML_Element_Def_Builder *def ACEXML_ENV_ARG_DECL) = 0;
+
+ /**
+ * Acquire a pointer to an attributes definition builder.
+ *
+ */
+ virtual ACEXML_Attributes_Def_Builder *getAttribute_Def_Builder () = 0;
+
+ /**
+ * Insert a new attributes definition into the DTD Manager.
+ *
+ * @retval 0 if success, -1 otherwise.
+ */
+ virtual int insertAttributes_Definition (ACEXML_Attributes_Def_Builder *def ACEXML_ENV_ARG_DECL) = 0;
+
+ /**
+ * Acquire an element validator to validate an XML element.
+ *
+ * @todo I haven't figured out what memory management scheme
+ * we should use for the acquired validator.
+ */
+ virtual ACEXML_Validator *getValidator (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_DTD_Manager_H_ */
diff --git a/ACE/ACEXML/common/DefaultHandler.cpp b/ACE/ACEXML/common/DefaultHandler.cpp
new file mode 100644
index 00000000000..25e2f4dcf9d
--- /dev/null
+++ b/ACE/ACEXML/common/DefaultHandler.cpp
@@ -0,0 +1,159 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/DefaultHandler.h"
+
+ACEXML_DefaultHandler::ACEXML_DefaultHandler (void)
+{
+ // no-op
+}
+
+ACEXML_DefaultHandler::~ACEXML_DefaultHandler (void)
+{
+ // no-op
+}
+
+void
+ACEXML_DefaultHandler::characters (const ACEXML_Char *,
+ int,
+ int
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::endDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::endElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::endPrefixMapping (const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::ignorableWhitespace (const ACEXML_Char *,
+ int,
+ int ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::processingInstruction (const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::setDocumentLocator (ACEXML_Locator * )
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::skippedEntity (const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::startDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::startElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *,
+ ACEXML_Attributes * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::startPrefixMapping (const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+ // *** Methods inherited from ACEXML_DTDHandler.
+
+void
+ACEXML_DefaultHandler::notationDecl (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::unparsedEntityDecl (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+ // Methods inherited from ACEXML_EntityResolver.
+
+ACEXML_InputSource *
+ACEXML_DefaultHandler::resolveEntity (const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+ return 0;
+}
+
+ // Methods inherited from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+void
+ACEXML_DefaultHandler::error (ACEXML_SAXParseException & ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::fatalError (ACEXML_SAXParseException & ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::warning (ACEXML_SAXParseException & ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
diff --git a/ACE/ACEXML/common/DefaultHandler.h b/ACE/ACEXML/common/DefaultHandler.h
new file mode 100644
index 00000000000..149254c18e6
--- /dev/null
+++ b/ACE/ACEXML/common/DefaultHandler.h
@@ -0,0 +1,191 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file DefaultHandler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef ACEXML_DEFAULTHANDLER_H
+#define ACEXML_DEFAULTHANDLER_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/ContentHandler.h"
+#include "ACEXML/common/DTDHandler.h"
+#include "ACEXML/common/EntityResolver.h"
+#include "ACEXML/common/ErrorHandler.h"
+
+/**
+ * @class ACEXML_DefaultHandler DefaultHandler.h "ACEXML/common/DefaultHandler.h"
+ *
+ * @brief ACEXML_DefaultHandler
+ *
+ * This class is available as a convenience base class for SAX2
+ * applications: it provides default implementations for all of the
+ * callbacks in the four core SAX2 handler classes:
+ *
+ * - EntityResolver
+ * - DTDHandler
+ * - ContentHandler
+ * - ErrorHandler
+ *
+ * Application writers can extend this class when they need to implement
+ * only part of an interface; parser writers can instantiate this class to
+ * provide default handlers when the application has not supplied its own.
+ */
+class ACEXML_Export ACEXML_DefaultHandler
+ : public ACEXML_ContentHandler,
+ public ACEXML_DTDHandler,
+ public ACEXML_EntityResolver,
+ public ACEXML_ErrorHandler
+{
+public:
+ /**
+ * Default constructor.
+ */
+ ACEXML_DefaultHandler (void);
+
+ /**
+ * destructor.
+ */
+ virtual ~ACEXML_DefaultHandler (void);
+
+ // Methods inherit from ACEXML_ContentHandler.
+
+ /*
+ * Receive notification of character data.
+ */
+ virtual void characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the end of a document.
+ */
+ virtual void endDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the end of an element.
+ */
+ virtual void endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * End the scope of a prefix-URI mapping.
+ */
+ virtual void endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of ignorable whitespace in element content.
+ */
+ virtual void ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of a processing instruction.
+ */
+ virtual void processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive an object for locating the origin of SAX document events.
+ */
+ virtual void setDocumentLocator (ACEXML_Locator *locator) ;
+
+ /*
+ * Receive notification of a skipped entity.
+ */
+ virtual void skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the beginning of a document.
+ */
+ virtual void startDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the beginning of an element.
+ */
+ virtual void startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Begin the scope of a prefix-URI Namespace mapping.
+ */
+ virtual void startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ // *** Methods inherit from ACEXML_DTDHandler.
+
+ /*
+ * Receive notification of a notation declaration event.
+ */
+ virtual void notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of an unparsed entity declaration event.
+ */
+ virtual void unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ // Methods inherit from ACEXML_EnitityResolver.
+
+ /*
+ * Allow the application to resolve external entities.
+ */
+ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ // Methods inherit from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+ virtual void error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of a non-recoverable error.
+ */
+ virtual void fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of a warning.
+ */
+ virtual void warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* ACEXML_DEFAULTHANDLER_H */
diff --git a/ACE/ACEXML/common/Element_Def_Builder.cpp b/ACE/ACEXML/common/Element_Def_Builder.cpp
new file mode 100644
index 00000000000..2bcef84f16d
--- /dev/null
+++ b/ACE/ACEXML/common/Element_Def_Builder.cpp
@@ -0,0 +1,9 @@
+// $Id$
+
+#include "ACEXML/common/Element_Def_Builder.h"
+
+ACEXML_Element_Def_Builder::~ACEXML_Element_Def_Builder ()
+{
+
+}
+
diff --git a/ACE/ACEXML/common/Element_Def_Builder.h b/ACE/ACEXML/common/Element_Def_Builder.h
new file mode 100644
index 00000000000..9854dfad295
--- /dev/null
+++ b/ACE/ACEXML/common/Element_Def_Builder.h
@@ -0,0 +1,133 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Element_Def_Builder.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_ELEMENT_DEF_BUILDER_H_
+#define _ACEXML_ELEMENT_DEF_BUILDER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+#include "ace/Auto_Ptr.h"
+#include "ACEXML/common/XML_Types.h"
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/SAXExceptions.h"
+
+/**
+ * @class ACEXML_Element_Def_Builder Element_Def_Builder.h "common/Element_Def_Builder.h"
+ *
+ * @brief An abstract virtual class that defines the interface to define an
+ * element definition.
+ *
+ * This class defines how to define an element definition after parsing a
+ * DTD.
+ */
+class ACEXML_Export ACEXML_Element_Def_Builder
+{
+public:
+
+ typedef auto_ptr<ACEXML_Element_Def_Builder> VAR;
+
+ typedef enum {
+ EMPTY,
+ ANY,
+ MIXED,
+ CHILDREN,
+ UNDEFINED
+ } CONTENT_TYPE;
+
+ typedef enum {
+ ONE,
+ ZERO_OR_MORE,
+ ONE_OR_MORE,
+ ONE_OR_ZERO
+ } CARDINALITY;
+
+ virtual ~ACEXML_Element_Def_Builder () = 0;
+
+ /**
+ * Define the name of the element.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int setElementName (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Define the content type of the element.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int setContentType (CONTENT_TYPE type ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Insert one more element into Mixed definition.
+ */
+ virtual int insertMixedElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Start a new group of children.
+ */
+ virtual int startChildGroup () = 0;
+
+ /**
+ * End a new group of children.
+ *
+ * @retval 0 on success.
+ */
+ virtual int endChildGroup (CARDINALITY card ACEXML_ENV_ARG_DECL) = 0;
+
+ /**
+ * Set the type of current child group to Choice.
+ *
+ * @retval 0 on success, -1 if the type of the child group has
+ * already been set and this action conflicts with the previous
+ * setting.
+ */
+ virtual int setChoice () = 0;
+
+ /**
+ * Set the type of current child group to Sequence.
+ *
+ * @retval 0 on success, -1 if the type of the child group has
+ * already been set and this action conflicts with the previous
+ * setting.
+ */
+ virtual int setSequence () = 0;
+
+ /**
+ * Insert an new element into the current child group.
+ *
+ * @retval 0 on success, -1 otherwise.
+ */
+ virtual int insertElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Dump the content of the attribute definition.
+ */
+ virtual void dump (void) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ELEMENT_DEF_BUILDER_H_ */
diff --git a/ACE/ACEXML/common/Encoding.cpp b/ACE/ACEXML/common/Encoding.cpp
new file mode 100644
index 00000000000..4531fad20c3
--- /dev/null
+++ b/ACE/ACEXML/common/Encoding.cpp
@@ -0,0 +1,59 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/Encoding.h"
+#include "ace/OS_NS_string.h"
+
+const ACEXML_Char* ACEXML_Encoding::encoding_names_[8] = {
+ ACE_TEXT ("UCS-4BE"),
+ ACE_TEXT ("UCS-4LE"),
+ ACE_TEXT ("UCS-4_2143"),
+ ACE_TEXT ("UCS-4_3412"),
+ ACE_TEXT ("UTF-16"),
+ ACE_TEXT ("UTF-16"),
+ ACE_TEXT ("UTF-8"),
+ ACE_TEXT ("Unsupported Encoding")
+};
+
+const ACEXML_UTF8 ACEXML_Encoding::byte_order_mark_[][4] = {
+ { '\x00', '\x00', '\xFE', '\xFF' }, // UCS-4, big-endian (1234 order)
+ { '\xFF', '\xFE', '\x00', '\x00' }, // UCS-4, little-endian (4321 order)
+ { '\x00', '\x00', '\xFF', '\xFE' }, // UCS-4, unusual octet order (2143)
+ { '\xFE', '\xFF', '\x00', '\x00' }, // UCS-4, unusual octet order (3412)
+ { '\xFE', '\xFF', '\xFF', '\xFF' }, // UTF-16, big-endian (3 & 4 != 0)
+ { '\xFF', '\xFE', '\xFF', '\xFF' }, // UTF-16, little-endian ( 3 & 4 != 0)
+ { '\xEF', '\xBB', '\xBF', '\xFF' } // UTF-8
+};
+
+const ACEXML_UTF8 ACEXML_Encoding::magic_values_[][4] = {
+ { '\x00', '\x00', '\x00', '\x3c' }, //
+ { '\x3c', '\x00', '\x00', '\x00' }, // UCS-4 and variants
+ { '\x00', '\x00', '\x3c', '\x00' }, //
+ { '\x00', '\x3c', '\x00', '\x00' }, //
+ { '\x00', '\x3c', '\x00', '\x3f' }, // UTF-16BE
+ { '\x3c', '\x00', '\x3f', '\x00' }, // UTF-16LE
+ { '\x3c', '\x3f', '\x78', '\x6d' }, // UTF-8
+};
+
+const ACEXML_Char*
+ACEXML_Encoding::get_encoding (const char* input)
+{
+ if ((ACE_OS::memcmp (&ACEXML_Encoding::byte_order_mark_[ACEXML_Encoding::UTF16BE][0], input, 2) == 0)
+ && (input[2] != 0 || input[3] != 0)) // 3 & 4 should not be both zero
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF16BE];
+ else if ((ACE_OS::memcmp (&ACEXML_Encoding::byte_order_mark_[ACEXML_Encoding::UTF16LE][0], input, 2) == 0)
+ && (input[2] != 0 || input[3] != 0)) // 3 & 4 should not be both zero
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF16LE];
+ else if (ACE_OS::memcmp (&ACEXML_Encoding::byte_order_mark_[ACEXML_Encoding::UTF8][0], input, 3) == 0)
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF8];
+ else if (ACE_OS::memcmp (&ACEXML_Encoding::magic_values_[ACEXML_Encoding::UTF16BE][0], input, 4) == 0)
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF16BE];
+ else if (ACE_OS::memcmp (&ACEXML_Encoding::magic_values_[ACEXML_Encoding::UTF16LE][0], input, 4) == 0)
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF16LE];
+ else if (ACE_OS::memcmp (&ACEXML_Encoding::magic_values_[ACEXML_Encoding::UTF8][0], input, 4) == 0)
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF8];
+ else
+ {
+ // ACE_ERROR ((LM_ERROR, "Unknown encoding. Assuming UTF-8\n"));
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF8];
+ }
+}
diff --git a/ACE/ACEXML/common/Encoding.h b/ACE/ACEXML/common/Encoding.h
new file mode 100644
index 00000000000..3e957fabbe1
--- /dev/null
+++ b/ACE/ACEXML/common/Encoding.h
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Encoding.h
+ *
+ * This file provides utility functions to determine the encoding of a file
+ * or a byte stream automatically.
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_ENCODING_H
+#define _ACEXML_ENCODING_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+
+/**
+ * @class ACEXML_Encoding Encoding.h "ACEXML/common/Encoding.h"
+ *
+ * @brief ACEXML_Encoding
+ *
+ * Wrapper class for determining the encoding of a file or a byte stream.
+ */
+class ACEXML_Export ACEXML_Encoding
+{
+public:
+ enum {
+ UCS4BE,
+ UCS4LE,
+ UCS4_2143,
+ UCS4_3412,
+ UTF16BE,
+ UTF16LE,
+ UTF8,
+ OTHER
+ } ENCODING;
+
+ static const ACEXML_Char* encoding_names_[8];
+
+ static const ACEXML_UTF8 byte_order_mark_[][4];
+
+ static const ACEXML_UTF8 magic_values_[][4];
+
+ static const ACEXML_Char* get_encoding (const char* input);
+
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ENCODING_H */
diff --git a/ACE/ACEXML/common/EntityResolver.cpp b/ACE/ACEXML/common/EntityResolver.cpp
new file mode 100644
index 00000000000..bcd08c1af70
--- /dev/null
+++ b/ACE/ACEXML/common/EntityResolver.cpp
@@ -0,0 +1,11 @@
+#include "EntityResolver.h"
+
+
+ACE_RCSID (common,
+ EntityResolver,
+ "$Id$")
+
+
+ACEXML_EntityResolver::~ACEXML_EntityResolver (void)
+{
+}
diff --git a/ACE/ACEXML/common/EntityResolver.h b/ACE/ACEXML/common/EntityResolver.h
new file mode 100644
index 00000000000..80311b34d52
--- /dev/null
+++ b/ACE/ACEXML/common/EntityResolver.h
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file EntityResolver.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_ENTITYHANDLER_H_
+#define _ACEXML_ENTITYHANDLER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/InputSource.h"
+#include "ACEXML/common/SAXExceptions.h"
+
+/**
+ * @class ACEXML_EntityResolver EntityResolver.h "ACEXML/common/EntityResolver.h"
+ *
+ * @brief ACEXML_EntityResolver
+ *
+ * If a SAX application needs to implement customized handling for
+ * external entities, it must implement this interface and register an
+ * instance with the SAX driver using the setEntityResolver method.
+ *
+ * The XML reader will then allow the application to intercept any
+ * external entities (including the external DTD subset and external
+ * parameter entities, if any) before including them.
+ *
+ * Many SAX applications will not need to implement this interface,
+ * but it will be especially useful for applications that build XML
+ * documents from databases or other specialised input sources, or for
+ * applications that use URI types other than URLs.
+ */
+class ACEXML_Export ACEXML_EntityResolver
+{
+public:
+
+ virtual ~ACEXML_EntityResolver (void);
+
+ /**
+ * Allow the application to resolve external entities.
+ */
+ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ENTITYHANDLER_H_ */
diff --git a/ACE/ACEXML/common/Env.cpp b/ACE/ACEXML/common/Env.cpp
new file mode 100644
index 00000000000..6d1ce2158d6
--- /dev/null
+++ b/ACE/ACEXML/common/Env.cpp
@@ -0,0 +1,34 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/Env.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/common/Env.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_Env::ACEXML_Env (void)
+ : exception_ (0)
+{
+}
+
+ACEXML_Env::ACEXML_Env (const ACEXML_Env &rhs)
+ : exception_ (0)
+{
+ if (rhs.exception())
+ this->exception_ = rhs.exception_->duplicate();
+}
+
+ACEXML_Env&
+ACEXML_Env::operator= (const ACEXML_Env& rhs)
+{
+ ACEXML_Env tmp (rhs);
+ ACEXML_Exception* tmp_ex = this->exception_;
+ this->exception_ = tmp.exception_;
+ tmp.exception_ = tmp_ex;
+ return *this;
+}
+
+ACEXML_Env::~ACEXML_Env (void)
+{
+ this->clear();
+}
diff --git a/ACE/ACEXML/common/Env.h b/ACE/ACEXML/common/Env.h
new file mode 100644
index 00000000000..c17bba6a4bc
--- /dev/null
+++ b/ACE/ACEXML/common/Env.h
@@ -0,0 +1,72 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Env.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_ENV_H_
+#define _ACEXML_ENV_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Macros.h"
+#include "ACEXML/common/Exception.h"
+
+/**
+ * @class ACEXML_Env Env.h "ACEXML/common/Env.h"
+ *
+ * @brief ACEXML_Env
+ *
+ * ACEXML_Env is modeled after CORBA_Environment class. It provides a place
+ * holder for callees to propagate exceptions back to callers. ACEXML does
+ * not support native exceptions at this moment.
+ *
+ * @sa ACEXML_Exception
+ */
+class ACEXML_Export ACEXML_Env
+{
+public:
+ /// Default constructor.
+ ACEXML_Env (void);
+
+ /// Copy constructor.
+ ACEXML_Env (const ACEXML_Env& ACEXML_TRY_ENV);
+
+ /// Assignment
+ ACEXML_Env& operator= (const ACEXML_Env& ACEXML_TRY_ENV);
+
+ /// Destructor.
+ ~ACEXML_Env (void);
+
+ /// Return the contained exception.
+ ACEXML_Exception *exception (void) const;
+
+ /// Set the contained exception to @arg ex
+ void exception (ACEXML_Exception* ex);
+
+ /// Clear the exception and reset the evnrionment.
+ void clear (void);
+
+private:
+ /// Place holder for exception (if one occurs.)
+ ACEXML_Exception *exception_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/Env.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ENV_H_ */
diff --git a/ACE/ACEXML/common/Env.i b/ACE/ACEXML/common/Env.i
new file mode 100644
index 00000000000..95c3f41c8aa
--- /dev/null
+++ b/ACE/ACEXML/common/Env.i
@@ -0,0 +1,25 @@
+// -*- C++ -*- $Id$
+
+#include "ace/Log_Msg.h" /* to get ACE_ASSERT */
+#include "ACEXML/common/Exception.h"
+
+ACEXML_INLINE ACEXML_Exception *
+ACEXML_Env::exception (void) const
+{
+ return this->exception_;
+}
+
+ACEXML_INLINE void
+ACEXML_Env::exception (ACEXML_Exception *ex)
+{
+ ACE_ASSERT (ex != this->exception_);
+ this->clear();
+ this->exception_ = ex;
+}
+
+ACEXML_INLINE void
+ACEXML_Env::clear (void)
+{
+ delete this->exception_;
+ this->exception_ = 0;
+}
diff --git a/ACE/ACEXML/common/ErrorHandler.cpp b/ACE/ACEXML/common/ErrorHandler.cpp
new file mode 100644
index 00000000000..42d9552d859
--- /dev/null
+++ b/ACE/ACEXML/common/ErrorHandler.cpp
@@ -0,0 +1,11 @@
+#include "ErrorHandler.h"
+
+
+ACE_RCSID (common,
+ ErrorHandler,
+ "$Id$")
+
+
+ACEXML_ErrorHandler::~ACEXML_ErrorHandler (void)
+{
+}
diff --git a/ACE/ACEXML/common/ErrorHandler.h b/ACE/ACEXML/common/ErrorHandler.h
new file mode 100644
index 00000000000..7103aaceaf5
--- /dev/null
+++ b/ACE/ACEXML/common/ErrorHandler.h
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ErrorHandler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_ERRORHANDLER_H_
+#define _ACEXML_ERRORHANDLER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/SAXExceptions.h"
+
+/**
+ * @class ACEXML_ErrorHandler ErrorHandler.h "ACEXML/common/ErrorHandler.h"
+ *
+ * @brief ACEXML_ErrorHandler
+ *
+ * If a SAX application needs to implement customized error handling,
+ * it must implement this interface and then register an instance with
+ * the XML reader using the setErrorHandler method. The parser will
+ * then report all errors and warnings through this interface.
+ *
+ * @b WARNING: If an application does not register an ErrorHandler,
+ * XML parsing errors will go unreported and bizarre behaviour may
+ * result.
+ *
+ * For XML processing errors, a SAX driver must use this interface
+ * instead of throwing an exception: it is up to the application to
+ * decide whether to throw an exception for different types of errors
+ * and warnings. Note, however, that there is no requirement that the
+ * parser continue to provide useful information after a call to
+ * fatalError (in other words, a SAX driver class could catch an
+ * exception and report a fatalError).
+ */
+class ACEXML_Export ACEXML_ErrorHandler
+{
+public:
+
+ virtual ~ACEXML_ErrorHandler (void);
+
+ /**
+ * Receive notification of a recoverable error.
+ */
+ virtual void error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of a non-recoverable error.
+ */
+ virtual void fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of a warning.
+ */
+ virtual void warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ERRORHANDLER_H_ */
diff --git a/ACE/ACEXML/common/Exception.cpp b/ACE/ACEXML/common/Exception.cpp
new file mode 100644
index 00000000000..65d3c373091
--- /dev/null
+++ b/ACE/ACEXML/common/Exception.cpp
@@ -0,0 +1,36 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/Exception.h"
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_string.h"
+
+const ACEXML_Char *ACEXML_Exception::exception_name_ = ACE_TEXT ("ACEXML_Exception");
+
+const ACEXML_Char *ACEXML_Exception::null_ = ACE_TEXT ("");
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/common/Exception.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_Exception::ACEXML_Exception()
+{
+}
+
+ACEXML_Exception::~ACEXML_Exception()
+{
+}
+
+int
+ACEXML_Exception::is_a (const ACEXML_Char *name)
+{
+ return ACE_OS::strcmp (ACEXML_Exception::exception_name_, name) == 0;
+}
+
+void
+ACEXML_Exception::print (void)
+{
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACEXML: (%P|%t) EXCEPTION : %s\n"),
+ this->exception_name_));
+}
diff --git a/ACE/ACEXML/common/Exception.h b/ACE/ACEXML/common/Exception.h
new file mode 100644
index 00000000000..09995b473fa
--- /dev/null
+++ b/ACE/ACEXML/common/Exception.h
@@ -0,0 +1,87 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Exception.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_EXCEPTION_H_
+#define _ACEXML_EXCEPTION_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+#include "ACEXML/common/XML_Macros.h"
+
+#if defined (ACE_USES_NATIVE_EXCEPTIONS)
+# define ACEXML_RAISE(EXCEPTION) throw EXCEPTION
+#else
+# define ACEXML_RAISE(EXCEPTION)
+#endif
+
+
+/**
+ * @class ACEXML_Exception Exception.h "ACEXML/common/Exception.h"
+ *
+ * @brief ACEXML_Exception
+ *
+ * ACEXML_Exception is the base class for all ACEXML related exceptions.
+ * Since ACEXML currently does not support native exceptions, all
+ * exceptions should be thrown thru ACEXML_Env.
+ *
+ * @sa ACEXML_Env
+ */
+class ACEXML_Export ACEXML_Exception
+{
+public:
+
+ /// Destructor.
+ virtual ~ACEXML_Exception (void);
+
+ /// Throw the exception.
+ virtual void _raise (void) = 0;
+
+ /// Static narrow operation.
+ static ACEXML_Exception* _downcast (ACEXML_Exception* ex);
+
+ /// Return the exception type. (for safe downcast.)
+ virtual const ACEXML_Char *id (void) const ;
+
+ /// Dynamically create a copy of this exception.
+ virtual ACEXML_Exception *duplicate (void) const = 0;
+
+ /// Check whether this is an exception of type specified by <name>.
+ virtual int is_a (const ACEXML_Char *name);
+
+ /// Print out exception using ACE_DEBUG.
+ virtual void print (void) = 0;
+
+protected:
+ /// Default contructor.
+ ACEXML_Exception (void);
+
+ /// All exceptions have names. This name is used to identify the
+ /// type of an exception.
+ static const ACEXML_Char *exception_name_;
+
+ /// A null string that we return when there is no exception.
+ static const ACEXML_Char *null_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/Exception.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_EXCEPTION_H_ */
diff --git a/ACE/ACEXML/common/Exception.i b/ACE/ACEXML/common/Exception.i
new file mode 100644
index 00000000000..e2d97fa37ea
--- /dev/null
+++ b/ACE/ACEXML/common/Exception.i
@@ -0,0 +1,13 @@
+// -*- C++ -*- $Id$
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_Exception::id (void) const
+{
+ return ACEXML_Exception::exception_name_;
+}
+
+ACEXML_INLINE ACEXML_Exception*
+ACEXML_Exception::_downcast (ACEXML_Exception* x)
+{
+ return x;
+}
diff --git a/ACE/ACEXML/common/FileCharStream.cpp b/ACE/ACEXML/common/FileCharStream.cpp
new file mode 100644
index 00000000000..cafc0696b5c
--- /dev/null
+++ b/ACE/ACEXML/common/FileCharStream.cpp
@@ -0,0 +1,255 @@
+// $Id$
+
+#include "ACEXML/common/FileCharStream.h"
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_sys_stat.h"
+
+#if defined (ACE_USES_WCHAR)
+# include "ace/OS_NS_wchar.h"
+#endif /* ACE_USES_WCHAR */
+
+ACEXML_FileCharStream::ACEXML_FileCharStream (void)
+ : filename_ (0), encoding_ (0), size_ (0), infile_ (0), peek_ (0)
+{
+}
+
+ACEXML_FileCharStream::~ACEXML_FileCharStream (void)
+{
+ this->close();
+}
+
+int
+ACEXML_FileCharStream::open (const ACEXML_Char *name)
+{
+ delete[] this->filename_;
+ this->filename_ = 0;
+
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+
+ this->infile_ = ACE_OS::fopen (name, ACE_TEXT ("r"));
+ if (this->infile_ == 0)
+ return -1;
+
+ ACE_stat statbuf;
+ if (ACE_OS::stat (name, &statbuf) < 0)
+ return -1;
+
+ this->size_ = statbuf.st_size;
+ this->filename_ = ACE::strnew (name);
+ return this->determine_encoding();
+}
+
+int
+ACEXML_FileCharStream::determine_encoding (void)
+{
+ if (this->infile_ == 0)
+ return -1;
+
+ char input[4];
+ int retval = 0;
+ int i = 0;
+ for (; i < 4 && retval != -1; ++i)
+ retval = this->getchar_i(input[i]);
+ if (i < 4)
+ return -1;
+
+ // Rewind the stream
+ ACE_OS::rewind (this->infile_);
+
+ const ACEXML_Char* temp = ACEXML_Encoding::get_encoding (input);
+ if (!temp)
+ return -1;
+ else
+ {
+ if (this->encoding_)
+ delete [] this->encoding_;
+ this->encoding_ = ACE::strnew (temp);
+// ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("File's encoding is %s\n"),
+// this->encoding_));
+ }
+ // Move over the byte-order-mark if present.
+ char ch;
+ for (int j = 0; j < 3; ++j)
+ {
+ if (this->getchar_i (ch) < 0)
+ return -1;
+ if (ch == '\xFF' || ch == '\xFE' || ch == '\xEF' || ch == '\xBB' ||
+ ch == '\xBF')
+ continue;
+ else
+ {
+ ungetc (ch, this->infile_);
+ break;
+ }
+ }
+ return 0;
+}
+
+void
+ACEXML_FileCharStream::rewind()
+{
+ if (this->infile_ == 0)
+ return;
+ ACE_OS::rewind (this->infile_);
+ this->determine_encoding();
+}
+
+int
+ACEXML_FileCharStream::available (void)
+{
+ if (this->infile_ == 0)
+ return -1;
+
+ long curr;
+ if ((curr = ACE_OS::ftell (this->infile_)) < 0)
+ return -1;
+ return (this->size_ - curr);
+}
+
+int
+ACEXML_FileCharStream::close (void)
+{
+ if (this->infile_ != 0)
+ {
+ ACE_OS::fclose (this->infile_);
+ this->infile_ = 0;
+ }
+ delete[] this->filename_;
+ this->filename_ = 0;
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+ this->size_ = 0;
+ this->peek_ = 0;
+ return 0;
+}
+
+
+int
+ACEXML_FileCharStream::getchar_i (char& ch)
+{
+ ch = static_cast<char> (ACE_OS::fgetc (this->infile_));
+ return (feof(this->infile_) ? -1 : 0);
+}
+
+int
+ACEXML_FileCharStream::read (ACEXML_Char *str,
+ size_t len)
+{
+ if (this->infile_ == 0)
+ return -1;
+
+ return static_cast<int> (ACE_OS::fread (str, sizeof (ACEXML_Char), len, this->infile_));
+}
+
+int
+ACEXML_FileCharStream::get (ACEXML_Char& ch)
+{
+ if (this->infile_ == 0)
+ return -1;
+#if defined (ACE_USES_WCHAR)
+ return this->get_i (ch);
+#else
+ ch = (ACEXML_Char) ACE_OS::fgetc (this->infile_);
+ return (feof(this->infile_) ? -1 : 0);
+#endif /* ACE_USES_WCHAR */
+}
+
+int
+ACEXML_FileCharStream::peek (void)
+{
+ if (this->infile_ == 0)
+ return -1;
+#if defined (ACE_USES_WCHAR)
+ return this->peek_i();
+#else
+
+ ACEXML_Char ch = static_cast<ACEXML_Char> (ACE_OS::fgetc (this->infile_));
+ ::ungetc (ch, this->infile_);
+ return ch;
+#endif /* ACE_USES_WCHAR */
+}
+
+#if defined (ACE_USES_WCHAR)
+int
+ACEXML_FileCharStream::get_i (ACEXML_Char& ch)
+{
+ if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0)
+ {
+ ch = (ACEXML_Char) ACE_OS::fgetc (this->infile_);
+ return (feof(this->infile_) ? -1 : 0);
+ }
+ // If we have a value in peek_, return it.
+ if (this->peek_ != 0)
+ {
+ ch = this->peek_;
+ this->peek_ = 0;
+ return 0;
+ }
+
+ int BE = (ACE_OS::strcmp (this->encoding_,
+ ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0;
+ ACEXML_Char input[2];
+ int i = 0;
+ for (; i < 2 && !feof (this->infile_); ++i)
+ {
+ input[i] = ACE_OS::fgetwc (this->infile_);
+ }
+ if (i < 2)
+ {
+ ch = 0;
+ return -1;
+ }
+ ch = BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0];
+ return 0;
+}
+
+int
+ACEXML_FileCharStream::peek_i (void)
+{
+ // If we are reading a UTF-8 encoded file, just use the plain unget.
+ if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0)
+ {
+ ACEXML_Char ch = (ACEXML_Char) ACE_OS::fgetc (this->infile_);
+ ::ungetc (ch, this->infile_);
+ return ch;
+ }
+
+ // If somebody had already called peek() and not consumed it, return the
+ // value held in this->peek_.
+ if (this->peek_ != 0)
+ return this->peek_;
+
+ // Peek into the stream. This reads two characters off the stream, keeps
+ // it in peek_.
+ int BE = (ACE_OS::strcmp (this->encoding_,
+ ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0;
+ ACEXML_Char input[2];
+ int i = 0;
+ for (; i < 2 && !feof (this->infile_); ++i)
+ {
+ input[i] = ACE_OS::fgetwc (this->infile_);
+ }
+ if (i < 2)
+ {
+ this->peek_ = 0;
+ return -1;
+ }
+ this->peek_ = BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0];
+ return this->peek_;
+}
+#endif /* ACE_USES_WCHAR */
+
+const ACEXML_Char*
+ACEXML_FileCharStream::getEncoding (void)
+{
+ return this->encoding_;
+}
+
+const ACEXML_Char*
+ACEXML_FileCharStream::getSystemId (void)
+{
+ return this->filename_;
+}
diff --git a/ACE/ACEXML/common/FileCharStream.h b/ACE/ACEXML/common/FileCharStream.h
new file mode 100644
index 00000000000..0f3408ae18e
--- /dev/null
+++ b/ACE/ACEXML/common/FileCharStream.h
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file FileCharStream.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_FILECHARSTREAM_H_
+#define _ACEXML_FILECHARSTREAM_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/CharStream.h"
+#include "ACEXML/common/Encoding.h"
+
+/**
+ * @class ACEXML_FileCharStream FileCharStream.h "ACEXML/common/FileCharStream.h"
+ *
+ * An implementation of ACEXML_CharStream for reading input from a file.
+ */
+class ACEXML_Export ACEXML_FileCharStream : public ACEXML_CharStream
+{
+public:
+ /// Default constructor.
+ ACEXML_FileCharStream (void);
+
+ /// Destructor
+ virtual ~ACEXML_FileCharStream (void);
+
+ /// Open a file.
+ int open (const ACEXML_Char *name);
+
+ /**
+ * Returns the available ACEXML_Char in the buffer. -1
+ * if the object is not initialized properly.
+ */
+ virtual int available (void);
+
+ /**
+ * Close this stream and release all resources used by it.
+ */
+ virtual int close (void);
+
+ /**
+ * Read the next ACEXML_Char. Return -1 if we are not able to
+ * return an ACEXML_Char, 0 if succees.
+ */
+ virtual int get (ACEXML_Char& ch);
+
+ /**
+ * Read the next batch of ACEXML_Char strings
+ */
+ virtual int read (ACEXML_Char *str,
+ size_t len);
+
+ /**
+ * Determine the encoding of the file.
+ */
+ virtual int determine_encoding (void);
+
+
+ /**
+ * Peek the next ACEXML_Char in the CharStream. Return the
+ * character if success, -1 if EOF is reached.
+ */
+ virtual int peek (void);
+
+ /**
+ * Resets the file pointer to the beginning of the stream.
+ */
+ virtual void rewind (void);
+
+ /*
+ * Get the character encoding for the file.
+ */
+ virtual const ACEXML_Char *getEncoding (void);
+
+ /*
+ * Get the systemId for the underlying CharStream
+ */
+ virtual const ACEXML_Char* getSystemId (void);
+
+private:
+
+ /** Read the next character as a normal character. Return -1 if EOF is
+ * reached, else return 0.
+ */
+ int getchar_i (char& ch);
+
+#if defined (ACE_USES_WCHAR)
+ /**
+ * Read the next character from the stream taking into account the
+ * encoding of the file.
+ */
+ int get_i (ACEXML_Char& ch);
+
+ /**
+ * Read the next character from the stream taking into account the
+ * encoding of the file. Subsequent call to get() returns this
+ * character.
+ */
+ int peek_i (void);
+
+#endif /* ACE_USES_WCHAR */
+
+ ACEXML_Char* filename_;
+ ACEXML_Char* encoding_;
+ off_t size_;
+ FILE* infile_;
+ // This is needed to ensure that we can implement a peek operation on a
+ // UTF-16 encoded file. It is a bit hackish, but there is no other way of
+ // implementing a peek() as the standard I/O FILE* guarantees only one
+ // pushback.
+ ACEXML_Char peek_;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_FILECHARSTREAM_H_ */
diff --git a/ACE/ACEXML/common/HttpCharStream.cpp b/ACE/ACEXML/common/HttpCharStream.cpp
new file mode 100644
index 00000000000..b6f5e6aa423
--- /dev/null
+++ b/ACE/ACEXML/common/HttpCharStream.cpp
@@ -0,0 +1,464 @@
+// $Id$
+
+#include "ace/ACE.h"
+#include "ace/ace_wchar.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+#include "ACEXML/common/HttpCharStream.h"
+#include "ACEXML/common/Encoding.h"
+
+ACE_RCSID (common, HttpCharStream, "$Id$")
+
+/* Header FSM states. */
+static const int HDST_LINE1_PROTOCOL = 0;
+static const int HDST_LINE1_WHITESPACE = 1;
+static const int HDST_LINE1_STATUS = 2;
+static const int HDST_BOL = 10;
+static const int HDST_TEXT = 11;
+static const int HDST_LF = 12;
+static const int HDST_CR = 13;
+static const int HDST_CRLF = 14;
+static const int HDST_CRLFCR = 15;
+
+ACEXML_HttpCharStream::ACEXML_HttpCharStream (void)
+ : url_(0),
+ url_addr_(0),
+ stream_(0),
+ connector_(0),
+ size_(0),
+ data_offset_ (0),
+ encoding_ (0)
+{
+
+}
+
+ACEXML_HttpCharStream::~ACEXML_HttpCharStream (void)
+{
+ this->close ();
+}
+
+int
+ACEXML_HttpCharStream::open (const ACEXML_Char *url)
+{
+ this->url_ = ACE::strnew (url);
+
+ ACE_NEW_RETURN (this->url_addr_, ACEXML_URL_Addr, -1);
+ ACE_NEW_RETURN (this->stream_, ACEXML_Mem_Map_Stream, -1);
+
+ if (this->url_addr_->string_to_addr (this->url_) == -1) {
+ this->close();
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "cannot convert URL"), -1);
+ }
+
+ ACE_NEW_RETURN (this->connector_,
+ Connector (0, ACE_NONBLOCK),
+ -1);
+
+ if (this->stream_->open (this->connector_, *this->url_addr_) == -1) {
+ this->close();
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "cannot open backing store"), -1);
+ }
+
+ int result = this->send_request();
+ if (result == -1) {
+ this->close();
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_request"), -1);
+ }
+
+ size_t len = 0;
+ result = this->get_url(len);
+ if (result == -1) {
+ this->close();
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_url"), -1);
+ }
+ if (result != 200) {
+ this->close();
+ ACE_ERROR_RETURN ((LM_ERROR, "Server returned status %d : %s\n",
+ result,
+ "Refer HTTP/1.0 error code for details"), -1);
+ }
+
+ this->size_ = static_cast<off_t> (len);
+ return this->determine_encoding();
+}
+
+// The FSM was taken from the implementation of http_get and that falls
+// under the following license:
+//
+// Copyrigh (c) 2000 by Jef Poskanzer <jef@acme.com>. All rights reserved.
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE.
+
+
+int
+ACEXML_HttpCharStream::get_url (size_t& len)
+{
+ if (this->stream_ == 0)
+ return -1;
+
+ int header_state = HDST_LINE1_PROTOCOL;
+ int status = 0;
+ size_t b = 0;
+ char* buf = 0;
+ size_t buflen = BUFSIZ;
+ for (;;)
+ {
+ if ((buf = const_cast<char*> (this->stream_->recv (buflen))) == 0)
+ if (buflen <= 0)
+ break;
+
+ for (b = 0; b < buflen; ++b)
+ {
+ switch ( header_state )
+ {
+ case HDST_LINE1_PROTOCOL:
+ switch ( buf[b] )
+ {
+ case ' ': case '\t':
+ header_state = HDST_LINE1_WHITESPACE; break;
+ case '\n': header_state = HDST_LF ; break;
+ case '\r': header_state = HDST_CR; break;
+ }
+ break;
+ case HDST_LINE1_WHITESPACE:
+ switch ( buf[b] )
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ status = buf[b] - '0';
+ header_state = HDST_LINE1_STATUS;
+ break;
+ case '\n': header_state = HDST_LF ; break;
+ case '\r': header_state = HDST_CR; break;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+ case HDST_LINE1_STATUS:
+ switch ( buf[b] )
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ status = status * 10 + buf[b] - '0';
+ break;
+ case '\n': header_state = HDST_LF ; break;
+ case '\r': header_state = HDST_CR; break;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+ case HDST_BOL:
+ switch ( buf[b] )
+ {
+ case '\n': header_state = HDST_LF; break;
+ case '\r': header_state = HDST_CR; break;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+ case HDST_TEXT:
+ switch ( buf[b] )
+ {
+ case '\n': header_state = HDST_LF; break;
+ case '\r': header_state = HDST_CR; break;
+ }
+ break;
+
+ case HDST_LF:
+ switch ( buf[b] )
+ {
+ case '\n': goto end_of_headers;
+ case '\r': header_state = HDST_CR; break;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+
+ case HDST_CR:
+ switch ( buf[b] )
+ {
+ case '\n': header_state = HDST_CRLF; break;
+ case '\r': goto end_of_headers;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+
+ case HDST_CRLF:
+ switch ( buf[b] )
+ {
+ case '\n': goto end_of_headers;
+ case '\r': header_state = HDST_CRLFCR; break;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+
+ case HDST_CRLFCR:
+ switch ( buf[b] )
+ {
+ case '\n': case '\r': goto end_of_headers;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+ }
+ }
+ }
+ end_of_headers:
+ if (b == 0)
+ return -1;
+ ++b;
+ // Store the address of the beginning of data. We will use it to seek to
+ // beginning of the data in the URL.
+ char* data_beg = buf + b;
+ buflen = BUFSIZ;
+
+ // Get all of the data. Since this is backed by file store, we won't lose
+ // any of the data.
+ while (( buf = const_cast<char*> (this->stream_->recv (buflen))) != 0)
+ ;
+
+ // Length of data in the URL.
+ len = this->stream_->recv() - data_beg;
+
+ // Move the pointer to the beginning of the file store.
+ this->stream_->rewind();
+
+ this->data_offset_ = data_beg - this->stream_->recv();
+ // Forward to the beginning of data.
+ if (this->stream_->seek (this->data_offset_, SEEK_SET) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%s: %m",
+ "Error in seeking to beginning of data"), -1);
+
+ return status;
+}
+
+
+int
+ACEXML_HttpCharStream::send_request (void)
+{
+ char* path = ACE::strnew (ACE_TEXT_ALWAYS_CHAR (this->url_addr_->get_path_name()));
+ ACE_Auto_Basic_Array_Ptr<char> path_ptr (path);
+ size_t commandsize = ACE_OS::strlen (path)
+ + ACE_OS::strlen (this->url_addr_->get_host_name ())
+ + 20 // Extra
+ + 1 // NUL byte
+ + 16 ; // Protocol filler...
+
+ char* command;
+ ACE_NEW_RETURN (command, char[commandsize], -1);
+
+ // Ensure that the <command> memory is deallocated.
+ ACE_Auto_Basic_Array_Ptr<char> cmd_ptr (command);
+
+ int bytes = ACE_OS::sprintf (command, "GET %s HTTP/1.0\r\n", path);
+ bytes += ACE_OS::sprintf (&command[bytes], "Host: %s\r\n",
+ this->url_addr_->get_host_name ());
+ bytes += ACE_OS::sprintf (&command[bytes], "\r\n");
+
+ ACE_Time_Value tv (ACE_DEFAULT_TIMEOUT);
+
+ // Send the command to the connected server.
+ int retval = this->stream_->send_n (command, bytes, &tv);
+ if (retval <= 0)
+ return -1;
+ return retval;
+}
+
+
+int
+ACEXML_HttpCharStream::available (void)
+{
+ if (this->stream_ == 0)
+ return -1;
+ return static_cast<int> (this->stream_->available());
+}
+
+int
+ACEXML_HttpCharStream::close (void)
+{
+ delete[] this->url_;
+ this->url_ = 0;
+
+ delete this->url_addr_;
+ this->url_addr_ = 0;
+
+ delete this->stream_;
+ this->stream_ = 0;
+
+ delete this->connector_;
+ this->connector_ = 0;
+
+ this->size_ = 0;
+ this->data_offset_ = 0;
+
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+
+ return 0;
+}
+
+int
+ACEXML_HttpCharStream::determine_encoding (void)
+{
+ if (this->stream_ == 0)
+ return -1;
+
+ char input[4] = {0, 0, 0, 0};
+ int i = 0;
+ for (; i < 4 && input[i] != (char)-1; ++i)
+ input[i] = static_cast<char> (this->stream_->peek_char(i));
+ if (i < 4)
+ return -1;
+ const ACEXML_Char* temp = ACEXML_Encoding::get_encoding (input);
+ if (!temp)
+ return -1;
+ else
+ {
+ if (this->encoding_)
+ delete [] this->encoding_;
+ this->encoding_ = ACE::strnew (temp);
+ // ACE_DEBUG ((LM_DEBUG, "URI's encoding is %s\n", this->encoding_));
+ }
+ // Move over the byte-order-mark if present.
+ for (int j = 0; j < 3; ++j)
+ {
+ if (input[i] == '\xFF' || input[i] == '\xFE' || input[i] == '\xEF' ||
+ input[i] == '\xBB' || input[i] == '\xBF')
+ {
+ this->stream_->get_char();
+ continue;
+ }
+ break;
+ }
+ return 0;
+}
+
+void
+ACEXML_HttpCharStream::rewind (void)
+{
+ if (this->stream_ == 0)
+ return;
+ this->stream_->rewind();
+
+ // Forward to the beginning of data.
+ if (this->stream_->seek (this->data_offset_, SEEK_SET) == -1)
+ ACE_ERROR ((LM_ERROR, "%s: %m", "Error in seeking to beginning of data"));
+ this->determine_encoding();
+}
+
+const ACEXML_Char*
+ACEXML_HttpCharStream::getEncoding (void)
+{
+ return this->encoding_;
+}
+
+const ACEXML_Char*
+ACEXML_HttpCharStream::getSystemId (void)
+{
+ return this->url_;
+}
+
+
+int
+ACEXML_HttpCharStream::read (ACEXML_Char *str,
+ size_t len)
+{
+ if (this->stream_ == 0)
+ return -1;
+ len = len * sizeof (ACEXML_Char);
+ char* temp = const_cast<char*> (this->stream_->recv (len));
+ str = ACE_TEXT_CHAR_TO_TCHAR (temp);
+ if (str == 0)
+ return -1;
+ return static_cast<int> (len);
+}
+
+
+int
+ACEXML_HttpCharStream::get (ACEXML_Char& ch)
+{
+ if (this->stream_ == 0)
+ return -1;
+#if defined (ACE_USES_WCHAR)
+ return this->get_i (ch);
+#else
+ ch = (ACEXML_Char) this->stream_->get_char();
+ return (ch == (ACEXML_Char)EOF ? -1 :0);
+#endif /* ACE_USES_WCHAR */
+}
+
+int
+ACEXML_HttpCharStream::peek (void)
+{
+ if (this->stream_ == 0)
+ return -1;
+
+#if defined (ACE_USES_WCHAR)
+ return this->peek_i();
+#else
+ return this->stream_->peek_char (0);
+#endif /* ACE_USES_WCHAR */
+}
+
+
+#if defined (ACE_USES_WCHAR)
+int
+ACEXML_HttpCharStream::get_i (ACEXML_Char& ch)
+{
+ if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0)
+ {
+ ch = (ACEXML_Char) this->stream_->get_char();
+ return (ch == (ACEXML_Char)EOF ? -1 : 0);
+ }
+ int BE = (ACE_OS::strcmp (this->encoding_,
+ ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0;
+ ACEXML_Char input[2] = {0};
+ int i = 0;
+ for (; i < 2 && (input[i] = this->stream_->get_char()) > 0; ++i)
+ ;
+ if (i < 2)
+ {
+ ch = 0;
+ return input[i];
+ }
+ ch = BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0];
+ return 0;
+}
+
+int
+ACEXML_HttpCharStream::peek_i (void)
+{
+ // If we are reading a UTF-8 encoded file, just use the plain unget.
+ if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0)
+ {
+ ACEXML_Char ch = (ACEXML_Char) this->stream_->peek_char (0);
+ return ch;
+ }
+
+ int BE = (ACE_OS::strcmp (this->encoding_,
+ ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0;
+ // Peek into the stream.
+ ACEXML_Char input[2];
+ int i = 0;
+ for (; i < 2 && (input[i] = this->stream_->peek_char (i)) > 0; ++i)
+ ;
+ if (i < 2)
+ return -1;
+ return (BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0]);
+}
+#endif /* ACE_USES_WCHAR */
diff --git a/ACE/ACEXML/common/HttpCharStream.h b/ACE/ACEXML/common/HttpCharStream.h
new file mode 100644
index 00000000000..ba29e756e5b
--- /dev/null
+++ b/ACE/ACEXML/common/HttpCharStream.h
@@ -0,0 +1,140 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file HttpCharStream.h
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_HTTPCHARSTREAM_H_
+#define _ACEXML_HTTPCHARSTREAM_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/CharStream.h"
+#include "ACEXML/common/URL_Addr.h"
+#include "ACEXML/common/Mem_Map_Stream.h"
+
+/**
+ * @class ACEXML_HttpCharStream HttpCharStream.h "ACEXML/common/HttpCharStream.h"
+ *
+ * An implementation of ACEXML_CharStream for reading input from a URL.
+ */
+class ACEXML_Export ACEXML_HttpCharStream : public ACEXML_CharStream
+{
+public:
+ /// Default constructor.
+ ACEXML_HttpCharStream (void);
+
+ /// Destructor
+ virtual ~ACEXML_HttpCharStream (void);
+
+ /// Open an URL.
+ int open (const ACEXML_Char *url);
+
+ /**
+ * Returns the available ACEXML_Char in the buffer. -1
+ * if the object is not initialized properly.
+ */
+ virtual int available (void);
+
+ /**
+ * Close this stream and release all resources used by it.
+ */
+ virtual int close (void);
+
+ /**
+ * Read the next ACEXML_Char. Return -1 if we are not able to
+ * return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed.
+ */
+ virtual int get (ACEXML_Char& ch);
+
+ /**
+ * Read the next batch of ACEXML_Char strings
+ */
+ virtual int read (ACEXML_Char *str, size_t len);
+
+ /**
+ * Peek the next ACEXML_Char in the CharStream. Return the
+ * character if succeess, -1 if EOS is reached.
+ */
+ virtual int peek (void);
+
+ /**
+ * Resets the file pointer to the beginning of the stream.
+ */
+ virtual void rewind (void);
+
+ /**
+ * Determine the encoding of the file.
+ */
+ virtual int determine_encoding (void);
+
+ /**
+ * Get the encoding of the file
+ */
+ virtual const ACEXML_Char* getEncoding (void);
+
+ /*
+ * Get the systemId for the underlying CharStream
+ */
+ virtual const ACEXML_Char* getSystemId (void);
+
+
+private:
+
+#if defined (ACE_USES_WCHAR)
+ /**
+ * Read the next character from the stream taking into account the
+ * encoding of the file.
+ */
+ int get_i (ACEXML_Char& ch);
+
+ /**
+ * Read the next character from the stream taking into account the
+ * encoding of the file. Subsequent call to get() returns this
+ * character.
+ */
+ int peek_i (void);
+
+#endif /* ACE_USES_WCHAR */
+
+ /**
+ * Send a HTTP/1.1 request to fetch the contents of the URL.
+ */
+ int send_request (void);
+
+ /**
+ * Fetch the URL and save it in backing store.
+ */
+ int get_url (size_t& len);
+
+ ACEXML_Char *url_;
+
+ ACEXML_URL_Addr* url_addr_;
+
+ ACEXML_Mem_Map_Stream* stream_;
+
+ Connector* connector_;
+
+ off_t size_;
+
+ off_t data_offset_;
+
+ ACEXML_Char* encoding_;
+
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_HTTPCHARSTREAM_H_ */
diff --git a/ACE/ACEXML/common/InputSource.cpp b/ACE/ACEXML/common/InputSource.cpp
new file mode 100644
index 00000000000..8673420d732
--- /dev/null
+++ b/ACE/ACEXML/common/InputSource.cpp
@@ -0,0 +1,106 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/InputSource.h"
+#include "ACEXML/common/StreamFactory.h"
+#include "ace/ACE.h"
+#include "ace/Swap.h"
+
+ACEXML_InputSource::ACEXML_InputSource (void)
+ : charStream_ (0),
+ encoding_ (0),
+ publicId_ (0),
+ systemId_ (0)
+{
+}
+
+ACEXML_InputSource::ACEXML_InputSource (ACEXML_CharStream *stm)
+ : charStream_ (stm),
+ encoding_ (ACE::strnew (stm->getEncoding())),
+ publicId_ (0),
+ systemId_ (stm->getSystemId() ? ACE::strnew (stm->getSystemId()): 0)
+{
+}
+
+ /*
+ * Create a new input source with a character stream.
+ *
+ */
+
+ACEXML_InputSource::ACEXML_InputSource (const ACEXML_Char *systemId)
+ : charStream_ (0),
+ encoding_ (0),
+ publicId_ (0),
+ systemId_ (ACE::strnew (systemId))
+{
+ ACEXML_StreamFactory factory;
+ ACEXML_CharStream* stm = factory.create_stream (this->systemId_);
+ if (stm)
+ {
+ this->setCharStream (stm);
+ this->setEncoding (this->charStream_->getEncoding());
+ }
+}
+
+ACEXML_InputSource::~ACEXML_InputSource (void)
+{
+ delete[] this->publicId_;
+ this->publicId_ = 0;
+ delete[] this->systemId_;
+ this->systemId_ = 0;
+ delete this->charStream_;
+ this->charStream_ = 0;
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+}
+
+ACEXML_CharStream *
+ACEXML_InputSource::getCharStream (void) const
+{
+ return this->charStream_;
+}
+
+const ACEXML_Char *
+ACEXML_InputSource::getEncoding (void) const
+{
+ return this->encoding_;
+}
+
+const ACEXML_Char *
+ACEXML_InputSource::getPublicId (void) const
+{
+ return this->publicId_;
+}
+
+const ACEXML_Char *
+ACEXML_InputSource::getSystemId (void) const
+{
+ return this->systemId_;
+}
+
+void
+ACEXML_InputSource::setCharStream (ACEXML_CharStream *stm)
+{
+ delete this->charStream_;
+ this->charStream_ = stm;
+}
+
+void
+ACEXML_InputSource::setEncoding (const ACEXML_Char *encoding)
+{
+ delete[] this->encoding_;
+ this->encoding_ = ACE::strnew (encoding);
+}
+
+void
+ACEXML_InputSource::setPublicId (const ACEXML_Char *publicId)
+{
+ delete[] this->publicId_;
+ this->publicId_ = ACE::strnew (publicId);
+}
+
+void
+ACEXML_InputSource::setSystemId (const ACEXML_Char *systemId)
+{
+ delete[] this->systemId_;
+ this->systemId_ = ACE::strnew (systemId);
+}
diff --git a/ACE/ACEXML/common/InputSource.h b/ACE/ACEXML/common/InputSource.h
new file mode 100644
index 00000000000..ae2b70b130e
--- /dev/null
+++ b/ACE/ACEXML/common/InputSource.h
@@ -0,0 +1,131 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file InputSource.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_INPUTSOURCE_H_
+#define _ACEXML_INPUTSOURCE_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/CharStream.h"
+
+/**
+ * @class ACEXML_InputSource InputSource.h "ACEXML/common/InputSource.h"
+ *
+ * @brief ACEXML_InputSource encapsulates the actual input stream with some
+ * added information.
+ *
+ * This class allows a SAX application to encapsulate information
+ * about an input source in a single object, which may include a
+ * public identifier, a system identifier, a byte stream (possibly
+ * with a specified encoding), and/or a character stream.
+ *
+ * There are two places that the application will deliver this input
+ * source to the parser: as the argument to the Parser.parse method,
+ * or as the return value of the EntityResolver.resolveEntity method.
+ *
+ * The SAX parser will use the InputSource object to determine how to
+ * read XML input. If there is a character stream available, the
+ * parser will read that stream directly; if not, the parser will use
+ * a byte stream, if available; if neither a character stream nor a
+ * byte stream is available, the parser will attempt to open a URI
+ * connection to the resource identified by the system identifier.
+ *
+ * An InputSource object belongs to the application: the SAX parser
+ * shall never modify it in any way (it may modify a copy if
+ * necessary).
+ *
+ * @sa ACEXML_CharStream
+ */
+class ACEXML_Export ACEXML_InputSource
+{
+public:
+ /**
+ * Default constructor.
+ */
+ ACEXML_InputSource (void);
+
+
+ /**
+ * Create a new input source with a ACEXML_Char stream.
+ * Notice that ACEXML_InputSource assumes the ownership
+ * of <stream>
+ */
+ explicit ACEXML_InputSource (ACEXML_CharStream *stream);
+
+ /**
+ * Create a new input source with a system identifier.
+ */
+ ACEXML_InputSource (const ACEXML_Char *systemId);
+
+ /**
+ * Default destructor.
+ */
+ virtual ~ACEXML_InputSource (void);
+
+ /**
+ * Get the ACEXML_Char stream for this input source.
+ */
+ virtual ACEXML_CharStream *getCharStream (void) const;
+
+ /**
+ * Get the character encoding for a byte stream or URI.
+ */
+ virtual const ACEXML_Char *getEncoding (void) const;
+
+ /**
+ * Get the public identifier for this input source.
+ */
+ virtual const ACEXML_Char *getPublicId (void) const;
+
+ /**
+ * Get the system identifier for this input source.
+ */
+ virtual const ACEXML_Char *getSystemId (void) const;
+
+ /**
+ * Set the ACEXML_Char stream for this input source.
+ * Notice that ACEXML_InputSource assumes the ownership
+ * of <stream>
+ */
+ virtual void setCharStream (ACEXML_CharStream *charStream);
+
+ /**
+ * Set the character encoding, if known.
+ */
+ virtual void setEncoding (const ACEXML_Char *encoding);
+
+ /**
+ * Set the public identifier for this input source.
+ */
+ virtual void setPublicId (const ACEXML_Char *publicId);
+
+ /**
+ * Set the public identifier for this input source.
+ */
+ virtual void setSystemId (const ACEXML_Char *systemId);
+
+private:
+ ACEXML_CharStream *charStream_;
+ ACEXML_Char *encoding_;
+ ACEXML_Char *publicId_;
+ ACEXML_Char *systemId_;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_INPUTSOURCE_H_ */
diff --git a/ACE/ACEXML/common/Locator.cpp b/ACE/ACEXML/common/Locator.cpp
new file mode 100644
index 00000000000..5de6d3a1516
--- /dev/null
+++ b/ACE/ACEXML/common/Locator.cpp
@@ -0,0 +1,11 @@
+#include "Locator.h"
+
+
+ACE_RCSID (common,
+ Locator,
+ "$Id$")
+
+
+ACEXML_Locator::~ACEXML_Locator (void)
+{
+}
diff --git a/ACE/ACEXML/common/Locator.h b/ACE/ACEXML/common/Locator.h
new file mode 100644
index 00000000000..c6504b706a4
--- /dev/null
+++ b/ACE/ACEXML/common/Locator.h
@@ -0,0 +1,74 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Locator.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_LOCATOR_H_
+#define _ACEXML_LOCATOR_H_
+#include /**/ "ace/pre.h"
+
+#include "ACEXML/common/ACEXML_Export.h"
+#include "ACEXML/common/XML_Types.h"
+
+/**
+ * @class ACEXML_Locator Locator.h "ACEXML/common/Locator.h"
+ *
+ * @brief ACEXML_Locator defines operations that an XML locator should support.
+ *
+ * If a SAX parser provides location information to the SAX
+ * application, it does so by implementing this interface and then
+ * passing an instance to the application using the content handler's
+ * setDocumentLocator method. The application can use the object to
+ * obtain the location of any other content handler event in the XML
+ * source document.
+ *
+ * Note that the results returned by the object will be valid only
+ * during the scope of each content handler method: the application
+ * will receive unpredictable results if it attempts to use the
+ * locator at any other time.
+ *
+ * SAX parsers are not required to supply a locator, but they are very
+ * strongly encouraged to do so. If the parser supplies a locator, it
+ * must do so before reporting any other document events. If no
+ * locator has been set by the time the application receives the
+ * startDocument event, the application should assume that a locator
+ * is not available.
+ */
+class ACEXML_Export ACEXML_Locator
+{
+public:
+
+ virtual ~ACEXML_Locator (void);
+
+ /*
+ * Return the column number where the current document event ends.
+ */
+ virtual int getColumnNumber (void) const = 0;
+
+ /*
+ * Return the line number where the current document event ends.
+ */
+ virtual int getLineNumber (void) const = 0;
+
+ /*
+ * Return the public identifier for the current document event.
+ */
+ virtual const ACEXML_Char *getPublicId (void) const = 0;
+
+ /*
+ * Return the system identifier for the current document event.
+ */
+ virtual const ACEXML_Char *getSystemId (void) const = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_LOCATOR_H_ */
diff --git a/ACE/ACEXML/common/LocatorImpl.cpp b/ACE/ACEXML/common/LocatorImpl.cpp
new file mode 100644
index 00000000000..7b98f9178e1
--- /dev/null
+++ b/ACE/ACEXML/common/LocatorImpl.cpp
@@ -0,0 +1,49 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/LocatorImpl.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/common/LocatorImpl.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_LocatorImpl::ACEXML_LocatorImpl (void)
+ : publicId_ (0),
+ systemId_ (0),
+ lineNumber_ (1),
+ columnNumber_ (0)
+{
+}
+
+ACEXML_LocatorImpl::ACEXML_LocatorImpl (const ACEXML_Char* systemId,
+ const ACEXML_Char* publicId)
+ : publicId_ (publicId ? ACE::strnew (publicId) : 0),
+ systemId_ (systemId ? ACE::strnew (systemId) : 0),
+ lineNumber_ (1),
+ columnNumber_ (0)
+{
+}
+
+
+ACEXML_LocatorImpl::ACEXML_LocatorImpl (const ACEXML_Locator& locator)
+ : publicId_ (locator.getPublicId() ? ACE::strnew(locator.getPublicId ()): 0),
+ systemId_ (locator.getSystemId() ? ACE::strnew(locator.getSystemId ()): 0),
+ lineNumber_ (locator.getLineNumber ()),
+ columnNumber_ (locator.getColumnNumber ())
+{
+}
+
+ACEXML_LocatorImpl::~ACEXML_LocatorImpl (void)
+{
+ this->reset();
+}
+
+void
+ACEXML_LocatorImpl::reset (void)
+{
+ delete[] this->publicId_;
+ this->publicId_ = 0;
+ delete[] this->systemId_;
+ this->systemId_ = 0;
+ this->columnNumber_ = 0;
+ this->lineNumber_ = 1;
+}
diff --git a/ACE/ACEXML/common/LocatorImpl.h b/ACE/ACEXML/common/LocatorImpl.h
new file mode 100644
index 00000000000..e5209e13b8d
--- /dev/null
+++ b/ACE/ACEXML/common/LocatorImpl.h
@@ -0,0 +1,159 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file LocatorImpl.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ * @author Krishnakumar Balasubramanian <kitty@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef ACEXML_LOCALTORIMPL_H
+#define ACEXML_LOCALTORIMPL_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Locator.h"
+
+/**
+ * @class ACEXML_LocatorImpl LocatorImpl.h "ACEXML/common/LocatorImpl.h"
+ *
+ * @brief ACEXML_LocatorImpl is an implementation of ACEXML_Locator.
+ *
+ * This class is available mainly for application writers, who can
+ * use it to make a persistent snapshot of a locator at any point
+ * during a document parse:
+ *
+ * @code
+ * ACEXML_Locator locator;
+ * ACEXML_Locator startloc;
+ *
+ * public void setLocator (ACEXML_Locator locator)
+ * {
+ * // note the locator
+ * this.locator = locator;
+ * }
+ *
+ * public void startDocument ()
+ * {
+ * // save the location of the start of the document
+ * // for future use.
+ * ACEXML_Locator startloc = new ACEXML_LocatorImpl(locator);
+ * }
+ * @endcode
+ *
+ * Normally, parser writers will not use this class, since it is more
+ * efficient to provide location information only when requested,
+ * rather than constantly updating a Locator object.
+ *
+ * @todo ACEXML parser doesn't support the use of Locator yet.
+ *
+ * @sa ACEXML_Locator
+ */
+class ACEXML_Export ACEXML_LocatorImpl : public ACEXML_Locator
+{
+public:
+ /*
+ * Default constructor.
+ */
+ ACEXML_LocatorImpl (void);
+
+ /**
+ * Construct a locator with systemId and publicId
+ *
+ */
+ ACEXML_LocatorImpl (const ACEXML_Char* systemId,
+ const ACEXML_Char* publicId);
+ /**
+ * Copy constructor. Create a persistent copy of the current state
+ * of a locator. When the original locator changes, this copy will
+ * still keep the original values (and it can be used outside the
+ * scope of DocumentHandler methods).
+ */
+ ACEXML_LocatorImpl (const ACEXML_Locator& locator);
+
+ /*
+ * Destructor.
+ */
+ virtual ~ACEXML_LocatorImpl (void);
+
+ /*
+ * Return the column number where the current document event ends.
+ */
+ virtual int getColumnNumber (void) const;
+
+ /*
+ * Return the line number where the current document event ends.
+ */
+ virtual int getLineNumber (void) const;
+
+ /*
+ * Return the public identifier for the current document event.
+ */
+ virtual const ACEXML_Char *getPublicId (void) const;
+
+ /*
+ * Return the system identifier for the current document event.
+ */
+ virtual const ACEXML_Char *getSystemId (void) const;
+
+ /*
+ * Set the column number of this locator.
+ */
+ void setColumnNumber (int cn);
+
+ /*
+ * Set the line number of this locator.
+ */
+ void setLineNumber (int ln);
+
+ /*
+ * Set the public identifier of this locator.
+ */
+ void setPublicId (const ACEXML_Char *id);
+
+ /*
+ * Set the system identifier of this locator.
+ */
+ void setSystemId (const ACEXML_Char *id);
+
+ /*
+ * Increment the line number.
+ */
+ void incrLineNumber ();
+
+ /*
+ * Increment the column number.
+ */
+ void incrColumnNumber ();
+
+ /*
+ * Reset the Locator information. This is necessary because one might
+ * want to use the same parser to parse multiple files. In that case,
+ * tying the life of the Locator with the parser is not appropriate. The
+ * parser calls this method as soon as issuing an endDocument() call.
+ */
+ void reset (void);
+
+private:
+ ACEXML_Char *publicId_;
+ ACEXML_Char *systemId_;
+ int lineNumber_;
+ int columnNumber_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/LocatorImpl.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* ACEXML_LOCALTORIMPL_H */
diff --git a/ACE/ACEXML/common/LocatorImpl.i b/ACE/ACEXML/common/LocatorImpl.i
new file mode 100644
index 00000000000..808a8bd4ac4
--- /dev/null
+++ b/ACE/ACEXML/common/LocatorImpl.i
@@ -0,0 +1,65 @@
+// -*- C++ -*- $Id$
+
+#include "ace/ACE.h"
+
+ACEXML_INLINE void
+ACEXML_LocatorImpl::setColumnNumber (int cn)
+{
+ this->columnNumber_ = cn;
+}
+
+ACEXML_INLINE void
+ACEXML_LocatorImpl::setLineNumber (int ln)
+{
+ this->lineNumber_ = ln;
+}
+
+ACEXML_INLINE int
+ACEXML_LocatorImpl::getColumnNumber (void) const
+{
+ return this->columnNumber_;
+}
+
+ACEXML_INLINE int
+ACEXML_LocatorImpl::getLineNumber (void) const
+{
+ return this->lineNumber_;
+}
+
+ACEXML_INLINE void
+ACEXML_LocatorImpl::setPublicId (const ACEXML_Char *id)
+{
+ delete[] this->publicId_;
+ this->publicId_ = ACE::strnew (id);
+}
+
+ACEXML_INLINE void
+ACEXML_LocatorImpl::setSystemId (const ACEXML_Char *id)
+{
+ delete[] this->systemId_;
+ this->systemId_ = ACE::strnew (id);
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_LocatorImpl::getPublicId (void) const
+{
+ return this->publicId_;
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_LocatorImpl::getSystemId (void) const
+{
+ return this->systemId_;
+}
+
+ACEXML_INLINE void
+ACEXML_LocatorImpl::incrLineNumber ()
+{
+ ++this->lineNumber_;
+}
+
+ACEXML_INLINE void
+ACEXML_LocatorImpl::incrColumnNumber ()
+{
+ ++this->columnNumber_;
+}
diff --git a/ACE/ACEXML/common/Makefile.am b/ACE/ACEXML/common/Makefile.am
new file mode 100644
index 00000000000..125d6f63d96
--- /dev/null
+++ b/ACE/ACEXML/common/Makefile.am
@@ -0,0 +1,135 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+includedir = @includedir@/ACEXML/common
+pkgconfigdir = @libdir@/pkgconfig
+
+ACE_BUILDDIR = $(top_builddir)
+ACE_ROOT = $(top_srcdir)
+
+
+## Makefile.ACEXML.am
+
+if !BUILD_ACE_FOR_TAO
+
+lib_LTLIBRARIES = libACEXML.la
+
+libACEXML_la_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -DACEXML_BUILD_DLL
+
+libACEXML_la_SOURCES = \
+ Attributes.cpp \
+ AttributesImpl.cpp \
+ Attributes_Def_Builder.cpp \
+ CharStream.cpp \
+ ContentHandler.cpp \
+ DTDHandler.cpp \
+ DTD_Manager.cpp \
+ DefaultHandler.cpp \
+ Element_Def_Builder.cpp \
+ Encoding.cpp \
+ EntityResolver.cpp \
+ Env.cpp \
+ ErrorHandler.cpp \
+ Exception.cpp \
+ FileCharStream.cpp \
+ HttpCharStream.cpp \
+ InputSource.cpp \
+ Locator.cpp \
+ LocatorImpl.cpp \
+ Mem_Map_Stream.cpp \
+ NamespaceSupport.cpp \
+ SAXExceptions.cpp \
+ StrCharStream.cpp \
+ StreamFactory.cpp \
+ Transcode.cpp \
+ URL_Addr.cpp \
+ Validator.cpp \
+ XMLFilterImpl.cpp \
+ XMLReader.cpp \
+ XML_Codecs.cpp \
+ XML_Util.cpp \
+ ZipCharStream.cpp
+
+libACEXML_la_LDFLAGS = \
+ -release @ACE_VERSION_NAME@
+
+libACEXML_la_LIBADD = \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+nobase_include_HEADERS = \
+ ACEXML_Export.h \
+ Attributes.h \
+ AttributesImpl.h \
+ AttributesImpl.i \
+ Attributes_Def_Builder.h \
+ CharStream.h \
+ ContentHandler.h \
+ DTDHandler.h \
+ DTD_Manager.h \
+ DefaultHandler.h \
+ Element_Def_Builder.h \
+ Encoding.h \
+ EntityResolver.h \
+ Env.h \
+ Env.i \
+ ErrorHandler.h \
+ Exception.h \
+ Exception.i \
+ FileCharStream.h \
+ HttpCharStream.h \
+ InputSource.h \
+ Locator.h \
+ LocatorImpl.h \
+ LocatorImpl.i \
+ Mem_Map_Stream.h \
+ NamespaceSupport.h \
+ SAXExceptions.h \
+ SAXExceptions.i \
+ StrCharStream.h \
+ StreamFactory.h \
+ Transcode.h \
+ URL_Addr.h \
+ URL_Addr.inl \
+ Validator.h \
+ XMLFilter.h \
+ XMLFilterImpl.h \
+ XMLFilterImpl.i \
+ XMLReader.h \
+ XML_Codecs.h \
+ XML_Macros.h \
+ XML_Types.h \
+ XML_Util.h \
+ ZipCharStream.h
+
+pkgconfig_DATA = \
+ ACEXML.pc
+
+CLEANFILES = \
+ ACEXML.pc
+
+ACEXML.pc: ${top_builddir}/config.status ${srcdir}/ACEXML.pc.in
+ ${top_builddir}/config.status --file "$@":${srcdir}/ACEXML.pc.in
+
+endif !BUILD_ACE_FOR_TAO
+
+EXTRA_DIST = \
+ ACEXML.pc.in
+
+
+## Clean up template repositories, etc.
+clean-local:
+ -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.*
+ -rm -f gcctemp.c gcctemp so_locations *.ics
+ -rm -rf cxx_repository ptrepository ti_files
+ -rm -rf templateregistry ir.out
+ -rm -rf ptrepository SunWS_cache Templates.DB
diff --git a/ACE/ACEXML/common/Mem_Map_Stream.cpp b/ACE/ACEXML/common/Mem_Map_Stream.cpp
new file mode 100644
index 00000000000..306641cb177
--- /dev/null
+++ b/ACE/ACEXML/common/Mem_Map_Stream.cpp
@@ -0,0 +1,264 @@
+// $Id$
+
+#include "ace/FILE_Addr.h"
+#include "ace/OS_NS_unistd.h"
+#include "ACEXML/common/Mem_Map_Stream.h"
+
+ACE_RCSID(common, Mem_Map_Stream, "$Id$")
+
+ACEXML_Mem_Map_Stream::ACEXML_Mem_Map_Stream (void)
+ : svc_handler_ (0)
+{
+
+}
+
+ACE_SOCK_Stream &
+ACEXML_Mem_Map_Stream::stream (void)
+{
+ return svc_handler_->peer ();
+}
+
+ssize_t
+ACEXML_Mem_Map_Stream::send_n (const void *buf, size_t size,
+ ACE_Time_Value *tv)
+{
+ return svc_handler_->peer ().send_n (buf, size, 0, tv);
+}
+
+int
+ACEXML_Mem_Map_Stream::eof (void) const
+{
+ return this->get_pos_ >= this->end_of_mapping_plus1_;
+}
+
+int
+ACEXML_Mem_Map_Stream::get_char (void)
+{
+ if (this->eof () && this->grow_file_and_remap () == -1)
+ return EOF;
+ return *this->get_pos_++;
+}
+
+void
+ACEXML_Mem_Map_Stream::rewind (void)
+{
+ this->recv_pos_ = reinterpret_cast<char *> (this->mem_map_.addr ());
+ this->get_pos_ = this->recv_pos_;
+ this->end_of_mapping_plus1_ = this->recv_pos_ + this->mem_map_.size ();
+}
+
+int
+ACEXML_Mem_Map_Stream::peek_char (size_t offset)
+{
+ // We may need to iterate if the size of <n> is large.
+ while (this->get_pos_ + offset >= this->end_of_mapping_plus1_)
+ if (this->grow_file_and_remap () == -1)
+ return EOF;
+
+ return this->get_pos_[offset];
+}
+
+const char *
+ACEXML_Mem_Map_Stream::recv (void) const
+{
+ return this->recv_pos_;
+}
+
+const char *
+ACEXML_Mem_Map_Stream::recv (size_t &len)
+{
+ if (this->eof () && this->grow_file_and_remap () == -1)
+ {
+ len = 0;
+ return 0;
+ }
+ const char *s = this->recv_pos_;
+ this->seek (static_cast<off_t> (len), SEEK_CUR);
+ len = this->get_pos_ - s;
+ return s;
+}
+
+size_t
+ACEXML_Mem_Map_Stream::recv_len (void) const
+{
+ return this->get_pos_ - this->recv_pos_;
+}
+
+const char *
+ACEXML_Mem_Map_Stream::peek_str (size_t offset,
+ size_t size)
+{
+ // We will iterate if the size of <offset> is large.
+ while (this->get_pos_ + (offset + size) > this->end_of_mapping_plus1_)
+ if (this->grow_file_and_remap () == -1)
+ return 0;
+
+ return &this->get_pos_[offset];
+}
+
+off_t
+ACEXML_Mem_Map_Stream::seek (off_t offset, int whence)
+{
+ switch (whence)
+ {
+ case SEEK_SET:
+ this->get_pos_ =
+ reinterpret_cast<char *> (this->mem_map_.addr ())
+ + offset;
+ break;
+
+ case SEEK_CUR:
+ this->get_pos_ += offset;
+ break;
+
+ case SEEK_END:
+ this->get_pos_ =
+ this->end_of_mapping_plus1_ + offset;
+ // @@ Not sure how to implement this (yet).
+ ACE_NOTSUP_RETURN (-1);
+ break;
+ }
+
+ // Make sure that the backing store will cover this.
+ while (this->get_pos_ > this->end_of_mapping_plus1_)
+ if (this->grow_file_and_remap () == -1)
+ this->get_pos_ = this->end_of_mapping_plus1_;
+
+ this->recv_pos_ = this->get_pos_;
+ return this->recv_pos_ - reinterpret_cast<char *> (this->mem_map_.addr ());
+}
+
+Svc_Handler *
+ACEXML_Mem_Map_Stream::svc_handler (void)
+{
+ return this->svc_handler_;
+}
+
+size_t
+ACEXML_Mem_Map_Stream::available (void) const
+{
+ return this->end_of_mapping_plus1_ - this->get_pos_;
+}
+
+int
+ACEXML_Mem_Map_Stream::open (Connector *connector,
+ const ACE_INET_Addr &addr)
+{
+ svc_handler_ = 0;
+
+ // Connect to the server at <addr>. If the handler has to be
+ // connected to the server again, the Caching strategy takes care
+ // and uses the same connection.
+ if (connector->connect (svc_handler_,
+ addr) == -1)
+ {
+
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p %s %d\n",
+ "Connect failed",
+ addr.get_host_name (),
+ addr.get_port_number ()),
+ -1);
+ }
+ // Create a temporary filename.
+ ACE_FILE_Addr file (ACE_sap_any_cast (ACE_FILE_Addr &));
+
+ // Create the temporary file via the <ACE_Mem_Map> class API.
+ if (this->mem_map_.open (file.get_path_name (),
+ O_RDWR | O_CREAT | O_APPEND,
+ ACE_DEFAULT_FILE_PERMS) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "open"),
+ -1);
+ // Make sure to unlink this right away so that if this process
+ // crashes these files will be removed automatically.
+ else if (ACE_OS::unlink (file.get_path_name ()) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "unlink"),
+ -1);
+ else
+ // Initialize all the position pointers to 0.
+ this->rewind ();
+
+ return 0;
+}
+
+int
+ACEXML_Mem_Map_Stream::grow_file_and_remap (void)
+{
+ char buf[8192];
+
+ // Copy the next chunk of bytes from the socket into the temporary
+ // file.
+ ACE_Time_Value tv (ACE_DEFAULT_TIMEOUT);
+ ssize_t bytes = 0;
+ ssize_t n = 0;
+ while (1)
+ {
+ n = this->svc_handler_->peer ().recv (buf, sizeof buf, 0, &tv);
+ if (n == -1)
+ {
+ if (errno != EWOULDBLOCK)
+ {
+ ACE_ERROR ((LM_ERROR, "%p\n", "recv"));
+ return -1;
+ }
+ }
+ bytes += n;
+ if (n == 0 && !bytes)
+ return -1;
+ else if (n == 0)
+ break;
+ else if (ACE::write_n (this->mem_map_.handle (), buf, n) != n)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "write_n"),
+ -1);
+ }
+
+// ssize_t n = this->svc_handler_->peer ().recv (buf, sizeof buf, 0, &tv);
+// if (n == -1)
+// {
+// ACE_ERROR ((LM_ERROR, "%p\n", "recv"));
+// return -1;
+// }
+// else if (n == 0)
+// return -1;
+// else if (ACE::write_n (this->mem_map_.handle (), buf, n) != n)
+// ACE_ERROR_RETURN ((LM_ERROR,
+// "%p\n",
+// "write_n"),
+// -1);
+
+ // Grow the memory-mapping to encompass the entire temporary file.
+ if (this->mem_map_.map (-1,
+ PROT_RDWR,
+ ACE_MAP_PRIVATE,
+ (void*)0) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "map"),
+ -1);
+ // MAP_FAILED is used as a "first time in" flag.
+ if (this->recv_pos_ == MAP_FAILED)
+ {
+ this->recv_pos_ = reinterpret_cast<char *> (this->mem_map_.addr ());
+ this->get_pos_ = this->recv_pos_;
+ }
+
+ this->end_of_mapping_plus1_ =
+ reinterpret_cast<char *> (this->mem_map_.addr ())
+ + this->mem_map_.size ();
+
+ return 0;
+}
+
+ACEXML_Mem_Map_Stream::~ACEXML_Mem_Map_Stream (void)
+{
+ // Remove the mapping and the file.
+ this->mem_map_.remove ();
+ delete this->svc_handler_;
+}
+
diff --git a/ACE/ACEXML/common/Mem_Map_Stream.h b/ACE/ACEXML/common/Mem_Map_Stream.h
new file mode 100644
index 00000000000..2c193aed80a
--- /dev/null
+++ b/ACE/ACEXML/common/Mem_Map_Stream.h
@@ -0,0 +1,191 @@
+/* -*- C++ -*- */
+
+/** @file Mem_Map_Stream.h
+ *
+ * $Id$
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ *
+ */
+
+#ifndef _ACEXML_MEM_MAP_STREAM_H
+#define _ACEXML_MEM_MAP_STREAM_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/SOCK_Stream.h"
+#include "ace/Mem_Map.h"
+#include "ace/SOCK_Connector.h"
+#include "ace/Connector.h"
+#include "ace/Svc_Handler.h"
+#include "ACEXML/common/XML_Types.h"
+
+typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> Svc_Handler;
+typedef ACE_Connector<Svc_Handler, ACE_SOCK_CONNECTOR> Connector;
+
+/**
+ * @class ACEXML_Mem_Map_Stream Mem_Map_Stream.h "ACEXML/common/Mem_Map_Stream.h"
+ *
+ * @brief Provides a memory-mapped stream abstraction to simplify parsing
+ * of tokens.
+ *
+ * This class makes it possible to treat an connection as a stream of
+ * bytes, similar to the C library stdio streams. The contents of the
+ * connection are buffered incrementally in a memory-mapped file. This
+ * class maintains pointers to two positions in the stream:
+ *
+ * 1. The <recv> position, which keeps track of the beginning of a
+ * token that is in the stream.
+ *
+ * 2. The <get> position, which moves along character-by-character
+ * until the end of the token is reached.
+ *
+ * Once a token has been located, it can be extracted from the stream by
+ * calling the <recv>. The length of the token, i.e., the <recv_len>, is
+ * the length in bytes between the <get> position and the <recv> position.
+ * Once the token has been extracted, the <recv> and <get> positions can be
+ * updated by the <seek> method.
+ */
+class ACEXML_Export ACEXML_Mem_Map_Stream
+{
+public:
+ /// Default constructor
+ ACEXML_Mem_Map_Stream (void);
+
+ /// Initialize this object.
+ virtual int open (Connector *connector,
+ const ACE_INET_Addr &);
+
+ /// Destructor.
+ virtual ~ACEXML_Mem_Map_Stream (void);
+
+ /// Returns the underlying <ACE_SOCK_Stream>.
+ ACE_SOCK_Stream &stream (void);
+
+ /**
+ * Send <size> bytes in <buf> to the connected peer. This is a
+ * completely unbuffered call.
+ */
+ virtual ssize_t send_n (const void *buf,
+ size_t size,
+ ACE_Time_Value *tv = 0);
+
+ /**
+ * Return the next character in the stream and advance the <get>
+ * position. Returns EOF when the <get> position reaches the end of the
+ * HTTP stream.
+ */
+ virtual int get_char (void);
+
+ /**
+ * Returns a pointer to array of at most <len> characters starting at
+ * the <recv> position. If the <recv> position + <len> extends past the
+ * EOF then <len> is set to the number of characters between the <recv>
+ * position and the EOF and both the <get> and <recv> positions are
+ * advanced by <len>. Returns 0 if the <recv> position is at the EOF.
+ */
+ virtual const char *recv (size_t &len);
+
+ /**
+ * Returns a pointer to array of characters starting at the <recv>
+ * position.
+ */
+ virtual const char *recv (void) const;
+
+ /**
+ * Returns the length in bytes between the <get> position and the <recv>
+ * position.
+ */
+ virtual size_t recv_len (void) const;
+
+ /**
+ * Returns the no. of bytes available in the stream.
+ */
+ virtual size_t available (void) const;
+
+ /**
+ * Resets the <get> and <recv> positions to the beginning of the stream.
+ * This works since all the data has been cached in the memory-mapped
+ * backing store.
+ */
+ virtual void rewind (void);
+
+ /**
+ * Returns the nth character <offset> from the <get> position in the
+ * stream without advancing the <get> position. Automatically extends
+ * the backing store if necessary. Returns EOF if <offset> is past the
+ * end of the stream.
+ */
+ virtual int peek_char (size_t offset);
+
+ /**
+ * Return a pointer to an array of <size> characters starting at
+ * <offset> characters from the <get> position in the stream without
+ * advancing the <get> position. Automatically extends the backing store
+ * if necessary. Returns 0 if <offset> or <offset + size> is past the
+ * end of the stream.
+ */
+ virtual const char *peek_str (size_t offset, size_t size);
+
+ /**
+ * Sets the <get> and <recv> positions as follows:
+ * o If <whence> is <SEEK_SET>, the positions are set to <offset>
+ * bytes from the start of the stream.
+ * o If <whence> is <SEEK_CUR>, the positions are set to the
+ * current <get> position plus <offset>.
+ * o If <whence> is <SEEK_END>, the positions are set to the size
+ * of the stream plus <offset>.
+ *
+ * If offset is greater than EOF, both <get> and <recv> are set to EOF.
+ * Note special return value is returned to indicate this condition.
+ */
+ virtual off_t seek (off_t offset, int whence = SEEK_CUR);
+
+ /// Returns 1 if we're at the end of the HTTP stream, else 0.
+ virtual int eof (void) const;
+
+ /// Returns the underlying service handler.
+ Svc_Handler *svc_handler (void);
+
+private:
+ /**
+ * Grow the file by reading another chunk from the HTTP socket and
+ * extend the mapping to cover this chunk. Returns -1 on failure or
+ * EOF, else 0.
+ */
+ int grow_file_and_remap (void);
+
+ /**
+ * Connection to peer. The granularity is at the Svc_Handler level.
+ * The Svc_Handler has an SOCK_Stream.
+ */
+ Svc_Handler *svc_handler_;
+
+ /// Memory-mapped file that we're iterating over.
+ ACE_Mem_Map mem_map_;
+
+ /// Pointer to the address where the next <recv> method will start.
+ char *recv_pos_;
+
+ /**
+ * Pointer to the address where the next <get_char> method will
+ * start.
+ */
+ char *get_pos_;
+
+ /// Address at the end of the file mapping.
+ char *end_of_mapping_plus1_;
+
+};
+
+
+#include /**/ "ace/post.h"
+
+
+#endif /* _ACEXML_MEM_MAP_STREAM_H */
diff --git a/ACE/ACEXML/common/NamespaceSupport.cpp b/ACE/ACEXML/common/NamespaceSupport.cpp
new file mode 100644
index 00000000000..5f337eca2ba
--- /dev/null
+++ b/ACE/ACEXML/common/NamespaceSupport.cpp
@@ -0,0 +1,247 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/NamespaceSupport.h"
+#include "ace/OS_NS_string.h"
+
+static const ACEXML_Char ACEXML_XMLNS_PREFIX_name[] = ACE_TEXT ("xmlns");
+
+const ACEXML_Char *ACEXML_NamespaceSupport::XMLNS_PREFIX = ACEXML_XMLNS_PREFIX_name;
+
+static const ACEXML_Char ACEXML_DEFAULT_NS_PREFIX[] = {0};
+
+static const ACEXML_Char ACEXML_TABOO_NS_PREFIX[] = ACE_TEXT ("xml");
+
+static const ACEXML_Char ACEXML_XMLNS_URI_name[] = ACE_TEXT ("http://www.w3.org/XML/1998/namespace");
+const ACEXML_Char *ACEXML_NamespaceSupport::XMLNS = ACEXML_XMLNS_URI_name;
+
+ACEXML_Namespace_Context_Stack::ACEXML_Namespace_Context_Stack (void)
+{
+}
+
+ACEXML_Namespace_Context_Stack::~ACEXML_Namespace_Context_Stack (void)
+{
+ // Clean up stuff.
+}
+
+int
+ACEXML_Namespace_Context_Stack::push (ACEXML_NS_CONTEXT *nsc)
+{
+ return (this->stack_.push (nsc) < 0);
+}
+
+ACEXML_NS_CONTEXT *
+ACEXML_Namespace_Context_Stack::pop (void)
+{
+ if (this->stack_.size() <= 0)
+ return 0;
+
+ ACEXML_NS_CONTEXT* temp = 0;
+ int retval = this->stack_.pop (temp);
+ if (retval != 0)
+ {
+ ACE_ERROR ((LM_ERROR, "Unable to pop Namespace context from stack\n"));
+ return 0;
+ }
+ return temp;
+}
+
+int
+ACEXML_NamespaceSupport::popContext (void)
+{
+ delete this->effective_context_;
+
+ if ((this->effective_context_ = this->ns_stack_.pop ()) == 0)
+ return -1;
+ return 0;
+}
+
+int
+ACEXML_NamespaceSupport::pushContext (void)
+{
+ ACEXML_NS_CONTEXT *temp = this->effective_context_;
+ ACE_NEW_RETURN (this->effective_context_,
+ ACEXML_NS_CONTEXT (),
+ -1);
+
+ // @@ Copy everything from the old context to the new one.
+ ACEXML_NS_CONTEXT_ENTRY *entry = 0;
+
+ for (ACEXML_NS_CONTEXT_ITER iter (*temp);
+ iter.next (entry) != 0;
+ iter.advance ())
+ this->effective_context_->bind (entry->ext_id_,
+ entry->int_id_);
+ this->ns_stack_.push (temp);
+ return 0;
+}
+
+ACEXML_NamespaceSupport::ACEXML_NamespaceSupport (void)
+ : ns_stack_ (),
+ effective_context_ (0)
+{}
+
+int
+ACEXML_NamespaceSupport::init (void)
+{
+ // @@ No way to tell if the new fails.
+ ACE_NEW_RETURN (effective_context_, ACEXML_NS_CONTEXT(), -1);
+
+ ACEXML_String prefix (ACEXML_TABOO_NS_PREFIX, 0, 0);
+ ACEXML_String uri (ACEXML_XMLNS_URI_name, 0, 0);
+ return this->effective_context_->bind (prefix, uri);
+}
+
+ACEXML_NamespaceSupport::~ACEXML_NamespaceSupport (void)
+{
+ while (this->popContext () == 0)
+ ;
+}
+
+int
+ACEXML_NamespaceSupport::declarePrefix (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri)
+{
+ if (!prefix || !uri)
+ return -1;
+
+ // Unless predefined by w3.org(?) NS prefix can never start with
+ // "xml".
+ if (ACE_OS::strcmp (ACEXML_TABOO_NS_PREFIX, prefix) == 0)
+ return -1;
+
+ ACEXML_String ns_prefix (prefix, 0, 0);
+ ACEXML_String ns_uri (uri, 0, 0);
+
+ return this->effective_context_->rebind (ns_prefix, ns_uri);
+}
+
+int
+ACEXML_NamespaceSupport::getDeclaredPrefixes (ACEXML_STR_LIST &prefixes) const
+{
+ ACEXML_NS_CONTEXT_ENTRY *entry = 0;
+
+ // The prefix for default namespace (empty string) is included in
+ // the return list.
+ for (ACEXML_NS_CONTEXT_ITER iter (*this->effective_context_);
+ iter.next (entry) != 0;
+ iter.advance ())
+ prefixes.enqueue_tail (entry->ext_id_.c_str ());
+
+ return 0;
+}
+
+const ACEXML_Char *
+ACEXML_NamespaceSupport::getPrefix (const ACEXML_Char *uri) const
+{
+ if (!uri || *uri == 0)
+ return 0;
+
+ ACEXML_NS_CONTEXT_ENTRY *entry = 0;
+
+ for (ACEXML_NS_CONTEXT_ITER iter (*this->effective_context_);
+ iter.next (entry) != 0;
+ iter.advance ())
+ if (entry->int_id_ == ACEXML_String (uri, 0, 0))
+ return entry->ext_id_.c_str ();
+
+ return 0; // Nothing found.
+}
+
+int
+ACEXML_NamespaceSupport::getPrefixes (ACEXML_STR_LIST &prefixes) const
+{
+ ACEXML_NS_CONTEXT_ENTRY *entry = 0;
+
+ // The prefix for default namespace (empty string) is not included
+ // in the return list.
+ for (ACEXML_NS_CONTEXT_ITER iter (*this->effective_context_);
+ iter.next (entry) != 0;
+ iter.advance ())
+ prefixes.enqueue_tail (entry->ext_id_.c_str ());
+ return 0;
+}
+
+int
+ACEXML_NamespaceSupport::getPrefixes (const ACEXML_Char *uri,
+ ACEXML_STR_LIST &prefixes) const
+{
+ if (!uri)
+ return -1;
+
+ ACEXML_NS_CONTEXT_ENTRY *entry = 0;
+
+ for (ACEXML_NS_CONTEXT_ITER iter (*this->effective_context_);
+ iter.next (entry) != 0;
+ iter.advance ())
+ if (entry->int_id_ == ACEXML_String (uri, 0, 0) &&
+ entry->ext_id_ != ACEXML_String (ACEXML_DEFAULT_NS_PREFIX, 0, 0))
+ prefixes.enqueue_tail (entry->ext_id_.c_str ());
+ else
+ continue;
+
+ return 0; // Nothing found.
+}
+
+const ACEXML_Char *
+ACEXML_NamespaceSupport::getURI (const ACEXML_Char *prefix) const
+{
+ if (!prefix)
+ return 0;
+
+ ACEXML_NS_CONTEXT_ENTRY *entry = 0;
+
+ if (this->effective_context_->find (ACEXML_String (prefix, 0, 0),
+ entry) == 0)
+ return entry->int_id_.c_str ();
+ return 0;
+}
+
+int
+ACEXML_NamespaceSupport::processName (const ACEXML_Char *qName,
+ const ACEXML_Char *&uri,
+ const ACEXML_Char *&name,
+ int is_attribute) const
+{
+ int qlen = static_cast<int> (ACE_OS::strlen (qName));
+ int len = -1;
+ for (int i = 0; i < qlen; ++i)
+ if (qName [i] == ':')
+ {
+ len = i;
+ break;
+ }
+
+ ACEXML_String prefix (ACE_TEXT(""),0,0);
+ if (len == -1)
+ name = qName;
+ else
+ {
+ prefix.set (qName, len, 1);
+ name = qName + len + 1;
+ }
+
+ if (is_attribute && len == -1) {
+ uri = ACEXML_DEFAULT_NS_PREFIX;
+ return 0;
+ }
+
+ ACEXML_NS_CONTEXT_ENTRY *entry;
+
+ if (this->effective_context_->find (prefix, entry) == 0)
+ uri = entry->int_id_.c_str ();
+ else
+ {
+ uri = ACEXML_DEFAULT_NS_PREFIX;
+ return -1;
+ }
+ return 0;
+}
+
+int
+ACEXML_NamespaceSupport::reset (void)
+{
+ while (this->popContext() != -1)
+ ;
+ return 0;
+}
+
diff --git a/ACE/ACEXML/common/NamespaceSupport.h b/ACE/ACEXML/common/NamespaceSupport.h
new file mode 100644
index 00000000000..d81f9303d70
--- /dev/null
+++ b/ACE/ACEXML/common/NamespaceSupport.h
@@ -0,0 +1,235 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file NamespaceSupport.h
+ *
+ * $Id$
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef ACEXML_NAMESPACESUPPORT_H
+#define ACEXML_NAMESPACESUPPORT_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+#include "ace/Functor.h"
+#include "ace/Hash_Map_Manager.h"
+#include "ace/Containers_T.h"
+#include "ace/Null_Mutex.h"
+
+
+typedef ACE_Hash_Map_Entry<ACEXML_String,
+ ACEXML_String> ACEXML_NS_CONTEXT_ENTRY;
+
+typedef ACE_Hash_Map_Manager_Ex<ACEXML_String,
+ ACEXML_String,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_NS_CONTEXT;
+
+typedef ACE_Hash_Map_Iterator_Ex<ACEXML_String,
+ ACEXML_String,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_NS_CONTEXT_ITER;
+
+typedef ACE_Hash_Map_Reverse_Iterator_Ex<ACEXML_String,
+ ACEXML_String,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_NS_CONTEXT_REVERSE_ITER;
+
+typedef ACE_Unbounded_Queue<const ACEXML_Char *> ACEXML_STR_LIST;
+
+/**
+ * @class ACEXML_Namespace_Context_Stack NamespaceSupport.h "ACEXML/common/NamespaceSupport.h"
+ *
+ * @brief ACEXML_Namespace_Context_Stack implements a simple stack
+ * that ACEXML_NamespaceSupport uses to keep track of namespace scopes.
+ *
+ * @sa ACEXML_NamespaceSupport
+ */
+class ACEXML_Export ACEXML_Namespace_Context_Stack
+{
+public:
+ /// Default constructor.
+ ACEXML_Namespace_Context_Stack (void);
+
+ /// Destructor.
+ ~ACEXML_Namespace_Context_Stack (void);
+
+ /// Push the old namespace before entering into a new namespace scope.
+ int push (ACEXML_NS_CONTEXT * old);
+
+ /// Pop the old namespace when exiting a namespace scope.
+ ACEXML_NS_CONTEXT *pop (void);
+
+private:
+ /// Internal stack structure to hold namespace context.
+ ACE_Unbounded_Stack<ACEXML_NS_CONTEXT*> stack_;
+};
+
+/**
+ * @class ACEXML_NamespaceSupport NamespaceSupport.h "ACEXML/common/NamespaceSupport.h"
+ *
+ * @brief ACEXML_NamespaceSupport provides namespace management
+ * operation for an XML parser.
+ *
+ * This class encapsulates the logic of Namespace processing: it
+ * tracks the declarations currently in force for each context and
+ * automatically processes qualified XML 1.0 names into their
+ * Namespace parts; it can also be used in reverse for generating XML
+ * 1.0 from Namespaces.
+ *
+ * Namespace support objects are reusable, but the reset method must
+ * be invoked between each session.
+ *
+ * Here is a simple session (in Java :-p):
+ * @code
+ * String parts[] = new String[3];
+ * NamespaceSupport support = new NamespaceSupport();
+ *
+ * support.pushContext();
+ * support.declarePrefix("", "http://www.w3.org/1999/xhtml");
+ * support.declarePrefix("dc", "http://www.purl.org/dc#");
+ *
+ * String parts[] = support.processName("p", parts, false);
+ * System.out.println("Namespace URI: " + parts[0]);
+ * System.out.println("Local name: " + parts[1]);
+ * System.out.println("Raw name: " + parts[2]);
+ *
+ * String parts[] = support.processName("dc:title", parts, false);
+ * System.out.println("Namespace URI: " + parts[0]);
+ * System.out.println("Local name: " + parts[1]);
+ * System.out.println("Raw name: " + parts[2]);
+ *
+ * support.popContext();
+ * @endcode
+ *
+ * Note that this class is optimized for the use case where most
+ * elements do not contain Namespace declarations: if the same
+ * prefix/URI mapping is repeated for each context (for example), this
+ * class will be somewhat less efficient.
+ *
+ * @sa ACEXML_Exception
+ */
+class ACEXML_Export ACEXML_NamespaceSupport
+{
+public:
+ /**
+ * Default constructor.
+ */
+ ACEXML_NamespaceSupport (void);
+
+ /**
+ * Default destructor.
+ */
+ ~ACEXML_NamespaceSupport (void);
+
+ /**
+ * Initialize the namespace support object
+ */
+ int init(void);
+
+ /**
+ * XMLNS default prefix and URI strings.
+ */
+ static const ACEXML_Char *XMLNS_PREFIX;
+ static const ACEXML_Char *XMLNS;
+
+ /**
+ * Declare a Namespace prefix. Return -1 if the prefix was illegal
+ * or an internal error occured. Return 0 if the prefix gets declared
+ * successfully, 1 if the prefix replaces an existing prefix definition.
+ */
+ int declarePrefix (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri);
+
+ /**
+ * Return all prefixes declared in current context in
+ * the user-supplied list @a prefixes. It is user's reponsibility
+ * to ensure the list was empty originally.
+ */
+ int getDeclaredPrefixes (ACEXML_STR_LIST &prefixes) const;
+
+ /**
+ * Return one of the prefixes mapped to a Namespace URI.
+ */
+ const ACEXML_Char *getPrefix (const ACEXML_Char *uri) const;
+
+ /**
+ * Return all prefixes currently declared in the user-supplied list.
+ * @@ Known bug: This function should only return user-defined prefixes.
+ */
+ int getPrefixes (ACEXML_STR_LIST &prefixes) const;
+
+ /**
+ * Return all prefixes currently declared for a URI in the
+ * user-supplied list.
+ */
+ int getPrefixes (const ACEXML_Char *uri,
+ ACEXML_STR_LIST &prefixes) const;
+
+ /**
+ * Look up a prefix and get the currently-mapped Namespace URI.
+ */
+ const ACEXML_Char *getURI (const ACEXML_Char *prefix) const;
+
+ /**
+ * Revert to the previous namespace context.
+ */
+ int popContext (void);
+
+ /**
+ * Process a raw XML 1.0 name.
+ * @a qName is the raw XML name we want to parse,
+ * @a uri contains the URI string of the raw name. It points to a null
+ * string if the namespace is not valid or there's no namespace defined.
+ * @a name contains the original name without the prefix.
+ * @a is_attribute specifies whether the name is an attribute or not.
+ * Attributes have different scoping rules from elements.
+ */
+ int processName (const ACEXML_Char *qName,
+ const ACEXML_Char *&uri,
+ const ACEXML_Char *&name,
+ int is_attribute) const;
+
+ /**
+ * Start a new Namespace context. Prefixes defined in previous
+ * context are copied over to the new context.
+ */
+ int pushContext (void);
+
+ /**
+ * Reset this Namespace support object for reuse.
+ *
+ */
+ int reset (void);
+
+private:
+ /**
+ * Namespace Context stack. When we entering a new namespace
+ * context, the old context is duplicated and pushed into
+ * this stack.
+ */
+ ACEXML_Namespace_Context_Stack ns_stack_;
+
+ /**
+ * The effective namespace context.
+ */
+ ACEXML_NS_CONTEXT *effective_context_;
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* ACEXML_NAMESPACESUPPORT_H */
diff --git a/ACE/ACEXML/common/SAXExceptions.cpp b/ACE/ACEXML/common/SAXExceptions.cpp
new file mode 100644
index 00000000000..0e1cbd2a827
--- /dev/null
+++ b/ACE/ACEXML/common/SAXExceptions.cpp
@@ -0,0 +1,261 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/SAXExceptions.h"
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+
+const ACEXML_Char *ACEXML_SAXException::exception_name_ = ACE_TEXT ("ACEXML_SAXException");
+
+const ACEXML_Char *ACEXML_SAXNotSupportedException::exception_name_ = ACE_TEXT ("ACEXML_SAXNotSupportedException");
+
+const ACEXML_Char *ACEXML_SAXNotRecognizedException::exception_name_ = ACE_TEXT ("ACEXML_SAXNotRecognizedException");
+
+const ACEXML_Char *ACEXML_SAXParseException::exception_name_ = ACE_TEXT ("ACEXML_SAXParseException");
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/common/SAXExceptions.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_SAXException::ACEXML_SAXException (void)
+ : message_ (0)
+{
+}
+
+ACEXML_SAXException::ACEXML_SAXException (const ACEXML_Char *msg)
+ : message_ (ACE::strnew (msg))
+{
+}
+
+ACEXML_SAXException::ACEXML_SAXException (const ACEXML_SAXException &ex)
+ : ACEXML_Exception (ex),
+ message_ (ACE::strnew (ex.message_))
+
+{
+}
+
+ACEXML_SAXException&
+ACEXML_SAXException::operator= (const ACEXML_SAXException& src)
+{
+ ACEXML_SAXException temp (src);
+ ACEXML_Char* message = this->message_;
+ this->exception_name_ = temp.exception_name_;
+ this->message_ = temp.message_;
+ temp.message_ = message;
+ return *this;
+}
+
+
+ACEXML_SAXException*
+ACEXML_SAXException::_downcast (ACEXML_Exception* ex)
+{
+ if (ex->is_a (ACE_TEXT ("ACEXML_SAXException")))
+ return dynamic_cast<ACEXML_SAXException*> (ex);
+ return 0;
+}
+
+ACEXML_SAXException::~ACEXML_SAXException (void)
+{
+ delete[] this->message_;
+}
+
+
+
+ACEXML_Exception *
+ACEXML_SAXException::duplicate (void) const
+{
+ ACEXML_Exception *tmp;
+ ACE_NEW_RETURN (tmp, ACEXML_SAXException (*this), 0);
+ return tmp;
+}
+
+int
+ACEXML_SAXException::is_a (const ACEXML_Char *name)
+{
+ return ACE_OS::strcmp (ACEXML_SAXException::exception_name_, name) == 0
+ || this->ACEXML_Exception::is_a (name);
+}
+
+void
+ACEXML_SAXException::print (void)
+{
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACEXML: (%P|%t) %s: %s\n"),
+ this->exception_name_, this->message()));
+}
+
+ACEXML_SAXNotSupportedException::ACEXML_SAXNotSupportedException (void)
+{
+}
+
+ACEXML_SAXNotSupportedException::ACEXML_SAXNotSupportedException (const ACEXML_SAXNotSupportedException &ex)
+ : ACEXML_SAXException (ex)
+{
+}
+
+ACEXML_SAXNotSupportedException&
+ACEXML_SAXNotSupportedException::operator= (const
+ ACEXML_SAXNotSupportedException &ex)
+{
+ this->ACEXML_SAXException::operator= (ex);
+ return *this;
+}
+
+ACEXML_SAXNotSupportedException*
+ACEXML_SAXNotSupportedException::_downcast (ACEXML_Exception* ex)
+{
+ if (ex->is_a (ACE_TEXT ("ACEXML_SAXNotSupportedException")))
+ return dynamic_cast<ACEXML_SAXNotSupportedException*> (ex);
+ return 0;
+}
+
+ACEXML_SAXNotSupportedException::ACEXML_SAXNotSupportedException (const ACEXML_Char* msg)
+ : ACEXML_SAXException (msg)
+{
+}
+
+ACEXML_SAXNotSupportedException::~ACEXML_SAXNotSupportedException (void)
+{
+ delete[] this->message_;
+}
+
+
+ACEXML_Exception *
+ACEXML_SAXNotSupportedException::duplicate (void) const
+{
+ ACEXML_Exception *tmp;
+ ACE_NEW_RETURN (tmp, ACEXML_SAXNotSupportedException (*this), 0);
+ return tmp;
+}
+
+int
+ACEXML_SAXNotSupportedException::is_a (const ACEXML_Char *name)
+{
+ return ACE_OS::strcmp (ACEXML_SAXNotSupportedException::exception_name_,
+ name) == 0
+ || this->ACEXML_SAXException::is_a (name);
+}
+
+void
+ACEXML_SAXNotSupportedException::print (void)
+{
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("ACEXML: (%P|%t) %s: %s\n"),
+ this->exception_name_, this->message()));
+}
+
+ACEXML_SAXNotRecognizedException::ACEXML_SAXNotRecognizedException (void)
+{
+}
+
+ACEXML_SAXNotRecognizedException::ACEXML_SAXNotRecognizedException (const ACEXML_Char *msg)
+ : ACEXML_SAXException (msg)
+{
+}
+
+ACEXML_SAXNotRecognizedException::ACEXML_SAXNotRecognizedException (const ACEXML_SAXNotRecognizedException &ex)
+ : ACEXML_SAXException (ex)
+{
+}
+
+ACEXML_SAXNotRecognizedException&
+ACEXML_SAXNotRecognizedException::operator= (const ACEXML_SAXNotRecognizedException &ex)
+{
+ this->ACEXML_SAXException::operator= (ex);
+ return *this;
+}
+
+ACEXML_SAXNotRecognizedException*
+ACEXML_SAXNotRecognizedException::_downcast (ACEXML_Exception* ex)
+{
+ if (ex->is_a (ACE_TEXT ("ACEXML_SAXNotRecognizedException")))
+ return dynamic_cast<ACEXML_SAXNotRecognizedException*> (ex);
+ return 0;
+}
+
+ACEXML_SAXNotRecognizedException::~ACEXML_SAXNotRecognizedException (void)
+{
+ delete[] this->message_;
+}
+
+ACEXML_Exception *
+ACEXML_SAXNotRecognizedException::duplicate (void) const
+{
+ ACEXML_Exception *tmp;
+ ACE_NEW_RETURN (tmp, ACEXML_SAXNotRecognizedException (*this), 0);
+ return tmp;
+}
+
+int
+ACEXML_SAXNotRecognizedException::is_a (const ACEXML_Char *name)
+{
+ return ACE_OS::strcmp (ACEXML_SAXNotRecognizedException::exception_name_,
+ name) == 0
+ || this->ACEXML_SAXException::is_a (name);
+}
+
+void
+ACEXML_SAXNotRecognizedException::print (void)
+{
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("ACEXML: (%P|%t) %s: %s\n"),
+ this->exception_name_, this->message()));
+}
+
+ACEXML_SAXParseException::ACEXML_SAXParseException (void)
+{
+}
+
+ACEXML_SAXParseException::ACEXML_SAXParseException (const ACEXML_Char *msg)
+ : ACEXML_SAXException (msg)
+{
+}
+
+ACEXML_SAXParseException::ACEXML_SAXParseException (const ACEXML_SAXParseException &ex)
+ : ACEXML_SAXException (ex)
+{
+}
+
+ACEXML_SAXParseException&
+ACEXML_SAXParseException::operator= (const ACEXML_SAXParseException &ex)
+{
+ this->ACEXML_SAXException::operator= (ex);
+ return *this;
+}
+
+ACEXML_SAXParseException*
+ACEXML_SAXParseException::_downcast (ACEXML_Exception* ex)
+{
+ if (ex->is_a (ACE_TEXT ("ACEXML_SAXParseException")))
+ return dynamic_cast<ACEXML_SAXParseException*> (ex);
+ return 0;
+}
+
+ACEXML_SAXParseException::~ACEXML_SAXParseException (void)
+{
+}
+
+ACEXML_Exception *
+ACEXML_SAXParseException::duplicate (void) const
+{
+ ACEXML_Exception *tmp;
+ ACE_NEW_RETURN (tmp, ACEXML_SAXParseException (*this), 0);
+ return tmp;
+}
+
+int
+ACEXML_SAXParseException::is_a (const ACEXML_Char *name)
+{
+ return ACE_OS::strcmp (ACEXML_SAXParseException::exception_name_,
+ name) == 0
+ || this->ACEXML_SAXException::is_a (name);
+}
+
+void
+ACEXML_SAXParseException::print (void)
+{
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACEXML: (%P|%t) %s: %s\n"),
+ this->exception_name_, this->message()));
+}
diff --git a/ACE/ACEXML/common/SAXExceptions.h b/ACE/ACEXML/common/SAXExceptions.h
new file mode 100644
index 00000000000..d4965c93ee6
--- /dev/null
+++ b/ACE/ACEXML/common/SAXExceptions.h
@@ -0,0 +1,208 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file SAXExceptions.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_SAXEXCEPTIONS_H_
+#define _ACEXML_SAXEXCEPTIONS_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Exception.h"
+
+/**
+ * @class ACEXML_SAXException SAXExceptions.h "ACEXML/common/SAXExceptions.h"
+ *
+ * @brief ACEXML_SAXException
+ *
+ * ACEXML_SAXException is the mother of all SAX related exceptions.
+ */
+class ACEXML_Export ACEXML_SAXException : public ACEXML_Exception
+{
+public:
+ /// Default constructor.
+ ACEXML_SAXException (void);
+
+ /// Constructor initializing the exception message.
+ ACEXML_SAXException (const ACEXML_Char *msg);
+
+ /// Assignment operator
+ ACEXML_SAXException& operator= (const ACEXML_SAXException& src);
+
+ /// Copy constructor.
+ ACEXML_SAXException (const ACEXML_SAXException &ex);
+
+ /// Destructor.
+ virtual ~ACEXML_SAXException (void);
+
+ /// Throw the exception.
+ virtual void _raise (void);
+
+ /// Static narrow operation.
+ static ACEXML_SAXException* _downcast (ACEXML_Exception* ex);
+
+ /// Return the name of the exception.
+ virtual const ACEXML_Char *id (void) const;
+
+ /// Return the extra message accompanying the exception.
+ const ACEXML_Char *message (void);
+
+ virtual ACEXML_Exception *duplicate (void) const;
+
+ virtual int is_a (const ACEXML_Char *name);
+
+ virtual void print (void);
+
+protected:
+ static const ACEXML_Char *exception_name_;
+
+ /// A message providing more information about the exception being thrown.
+ ACEXML_Char *message_;
+};
+
+/**
+ * @class ACEXML_SAXNotSupportedException SAXExceptions.h "ACEXML/common/SAXExceptions.h"
+ *
+ * @brief ACEXML_SAXNotSupportedException
+ */
+class ACEXML_Export ACEXML_SAXNotSupportedException
+ : public ACEXML_SAXException
+{
+public:
+ /// Default constructor.
+ ACEXML_SAXNotSupportedException (void);
+
+ /// Copy constructor.
+ ACEXML_SAXNotSupportedException (const ACEXML_SAXNotSupportedException &ex);
+
+ /// Assignment operator
+ ACEXML_SAXNotSupportedException& operator= (const ACEXML_SAXNotSupportedException &ex);
+
+ /// Constructor which accepts an informational message
+ ACEXML_SAXNotSupportedException (const ACEXML_Char* msg);
+
+ /// Destructor.
+ virtual ~ACEXML_SAXNotSupportedException (void);
+
+ /// Throw the exception.
+ virtual void _raise (void);
+
+ /// Static narrow operation.
+ static ACEXML_SAXNotSupportedException* _downcast (ACEXML_Exception* ex);
+
+ virtual const ACEXML_Char *id (void) const;
+
+ virtual ACEXML_Exception *duplicate (void) const;
+
+ virtual int is_a (const ACEXML_Char *name);
+
+ virtual void print (void);
+
+protected:
+ static const ACEXML_Char *exception_name_;
+};
+
+/**
+ * @class ACEXML_SAXNotRecognizedException SAXExceptions.h "ACEXML/common/SAXExceptions.h"
+ *
+ * @brief ACEXML_SAXNotRecognizedException
+ */
+class ACEXML_Export ACEXML_SAXNotRecognizedException
+ : public ACEXML_SAXException
+{
+public:
+ /// Default constructor.
+ ACEXML_SAXNotRecognizedException (void);
+
+ /// Constructor with an initializing exception message.
+ ACEXML_SAXNotRecognizedException (const ACEXML_Char *msg);
+
+ /// Copy constructor.
+ ACEXML_SAXNotRecognizedException (const ACEXML_SAXNotRecognizedException &ex);
+
+ /// Assignment operator.
+ ACEXML_SAXNotRecognizedException& operator= (const ACEXML_SAXNotRecognizedException &ex);
+
+ /// Destructor.
+ virtual ~ACEXML_SAXNotRecognizedException (void);
+
+ /// Throw the exception.
+ virtual void _raise (void);
+
+ /// Static narrow operation.
+ static ACEXML_SAXNotRecognizedException* _downcast (ACEXML_Exception* ex);
+
+ virtual const ACEXML_Char *id (void) const;
+
+ virtual ACEXML_Exception *duplicate (void) const;
+
+ virtual int is_a (const ACEXML_Char *name);
+
+ virtual void print (void);
+
+protected:
+ static const ACEXML_Char *exception_name_;
+};
+
+/**
+ * @class ACEXML_SAXParseException SAXExceptions.h "ACEXML/common/SAXExceptions.h"
+ *
+ * @brief ACEXML_SAXParseException
+ *
+ */
+class ACEXML_Export ACEXML_SAXParseException
+ : public ACEXML_SAXException
+{
+public:
+ /// Default constructor.
+ ACEXML_SAXParseException (void);
+
+ /// Constructor with an initializing exception message.
+ ACEXML_SAXParseException (const ACEXML_Char *msg);
+
+ /// Copy constructor.
+ ACEXML_SAXParseException (const ACEXML_SAXParseException &ex);
+
+ /// Assignment operator.
+ ACEXML_SAXParseException& operator= (const ACEXML_SAXParseException &ex);
+
+ /// Destructor.
+ virtual ~ACEXML_SAXParseException (void);
+
+ /// Throw the exception.
+ virtual void _raise (void);
+
+ /// Static narrow operation.
+ static ACEXML_SAXParseException* _downcast (ACEXML_Exception* ex);
+
+ virtual const ACEXML_Char *id (void) const;
+
+ virtual ACEXML_Exception *duplicate (void) const;
+
+ virtual int is_a (const ACEXML_Char *name);
+
+ virtual void print (void);
+
+protected:
+ static const ACEXML_Char *exception_name_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/SAXExceptions.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_SAXEXCEPTIONS_H_ */
diff --git a/ACE/ACEXML/common/SAXExceptions.i b/ACE/ACEXML/common/SAXExceptions.i
new file mode 100644
index 00000000000..3aee40632b5
--- /dev/null
+++ b/ACE/ACEXML/common/SAXExceptions.i
@@ -0,0 +1,57 @@
+// -*- C++ -*- $Id$
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_SAXException::message (void)
+{
+ return (this->message_ == 0 ?
+ ACEXML_Exception::null_ :
+ this->message_);
+}
+
+ACEXML_INLINE void
+ACEXML_SAXException::_raise (void)
+{
+ ACEXML_RAISE (*this);
+}
+
+ACEXML_INLINE void
+ACEXML_SAXNotSupportedException::_raise (void)
+{
+ ACEXML_RAISE (*this);
+}
+
+ACEXML_INLINE void
+ACEXML_SAXNotRecognizedException::_raise (void)
+{
+ ACEXML_RAISE (*this);
+}
+
+ACEXML_INLINE void
+ACEXML_SAXParseException::_raise (void)
+{
+ ACEXML_RAISE (*this);
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_SAXException::id (void) const
+{
+ return ACEXML_SAXException::exception_name_;
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_SAXNotSupportedException::id (void) const
+{
+ return ACEXML_SAXNotSupportedException::exception_name_;
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_SAXNotRecognizedException::id (void) const
+{
+ return ACEXML_SAXNotRecognizedException::exception_name_;
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_SAXParseException::id (void) const
+{
+ return ACEXML_SAXParseException::exception_name_;
+}
diff --git a/ACE/ACEXML/common/StrCharStream.cpp b/ACE/ACEXML/common/StrCharStream.cpp
new file mode 100644
index 00000000000..aec2f83d945
--- /dev/null
+++ b/ACE/ACEXML/common/StrCharStream.cpp
@@ -0,0 +1,129 @@
+// $Id$
+
+#include "ACEXML/common/StrCharStream.h"
+#include "ACEXML/common/Encoding.h"
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+
+ACEXML_StrCharStream::ACEXML_StrCharStream (void)
+ : start_ (0), ptr_ (0), end_ (0), encoding_ (0), name_ (0)
+{
+}
+
+
+ACEXML_StrCharStream::~ACEXML_StrCharStream (void)
+{
+ this->close();
+}
+
+int
+ACEXML_StrCharStream::open (const ACEXML_Char *str, const ACEXML_Char* name)
+{
+
+ if (str != 0 && name != 0
+ && (this->start_ = ACE::strnew (str)) != 0
+ && (this->name_ = ACE::strnew (name)) != 0)
+ {
+ this->ptr_ = this->start_;
+ this->end_ = this->start_ + ACE_OS::strlen (this->start_);
+ return this->determine_encoding();
+ }
+ return -1; // Invalid string passed.
+}
+
+int
+ACEXML_StrCharStream::available (void)
+{
+ if (this->start_ != 0)
+ return (this->end_ - this->start_); // @@ Will this work on all platforms?
+ return -1;
+}
+
+int
+ACEXML_StrCharStream::close (void)
+{
+ delete[] this->start_;
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+ delete[] this->name_;
+ this->name_ = 0;
+ this->start_ = this->ptr_ = this->end_ = 0;
+ return 0;
+}
+
+int
+ACEXML_StrCharStream::determine_encoding (void)
+{
+ if (this->start_ == 0)
+ return -1;
+ char input[4] = {0,0,0,0};
+ char* sptr = (char*)this->start_;
+ int i = 0;
+ for ( ; i < 4 && sptr != (char*)this->end_; ++sptr, ++i)
+ input[i] = *sptr;
+ const ACEXML_Char* temp = ACEXML_Encoding::get_encoding (input);
+ if (!temp)
+ return -1;
+ else
+ {
+ if (this->encoding_)
+ delete [] this->encoding_;
+ this->encoding_ = ACE::strnew (temp);
+ // ACE_DEBUG ((LM_DEBUG, "String's encoding is %s\n", this->encoding_));
+ }
+ return 0;
+}
+
+void
+ACEXML_StrCharStream::rewind (void)
+{
+ this->ptr_ = this->start_;
+ this->determine_encoding();
+}
+
+int
+ACEXML_StrCharStream::get (ACEXML_Char& ch)
+{
+ if (this->start_ != 0 && this->ptr_ != this->end_)
+ {
+ ch = *this->ptr_++;
+ return 0;
+ }
+ return -1;
+}
+
+int
+ACEXML_StrCharStream::read (ACEXML_Char *str, size_t len)
+{
+ if (this->start_ != 0 &&
+ this->ptr_ != this->end_)
+ {
+ if (len * sizeof (ACEXML_Char) > (size_t) (this->end_ - this->ptr_))
+ len = this->end_ - this->ptr_;
+ ACE_OS::strncpy (str, this->ptr_, len);
+ this->ptr_ += len;
+ return static_cast<int> (len);
+ }
+ return 0;
+}
+
+int
+ACEXML_StrCharStream::peek (void)
+{
+ if (this->start_ != 0 && this->ptr_ != this->end_)
+ return *this->ptr_;
+ return -1;
+}
+
+const ACEXML_Char*
+ACEXML_StrCharStream::getEncoding (void)
+{
+ return this->encoding_;
+}
+
+const ACEXML_Char*
+ACEXML_StrCharStream::getSystemId(void)
+{
+ return this->name_;
+}
diff --git a/ACE/ACEXML/common/StrCharStream.h b/ACE/ACEXML/common/StrCharStream.h
new file mode 100644
index 00000000000..21de6ecaea4
--- /dev/null
+++ b/ACE/ACEXML/common/StrCharStream.h
@@ -0,0 +1,102 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file StrCharStream.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_STRCHARSTREAM_H_
+#define _ACEXML_STRCHARSTREAM_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/CharStream.h"
+
+/**
+ * @class ACEXML_StrCharStream StrCharStream.h "common/StrCharStream.h"
+ *
+ * An implementation of ACEXML_CharStream for reading
+ * input from a null-terminated ACEXML_Char string.
+ */
+class ACEXML_Export ACEXML_StrCharStream : public ACEXML_CharStream
+{
+public:
+ /// Default constructor.
+ ACEXML_StrCharStream (void);
+
+ /// Destructor
+ virtual ~ACEXML_StrCharStream (void);
+
+ /// Initializing StrCharStream with @a str and @a name
+ int open (const ACEXML_Char *str, const ACEXML_Char* name);
+
+ /**
+ * Returns the available ACEXML_Char in the buffer. -1
+ * if the object is not initialized properly.
+ */
+ virtual int available (void);
+
+ /**
+ * Close this stream and release all resources used by it.
+ */
+ virtual int close (void);
+
+ /**
+ * Determine the encoding of the file.
+ */
+ virtual int determine_encoding (void);
+
+ /**
+ * Read the next ACEXML_Char. Return -1 if we are not able to
+ * return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed.
+ */
+ virtual int get (ACEXML_Char& ch);
+
+ /**
+ * Read the next batch of ACEXML_Char strings
+ */
+ virtual int read (ACEXML_Char *str, size_t len);
+
+ /**
+ * Peek the next ACEXML_Char in the CharStream. Return the
+ * character if succeess, -1 if EOS is reached.
+ */
+ virtual int peek (void);
+
+ /*
+ * Get the character encoding for a byte stream or URI.
+ */
+ virtual const ACEXML_Char *getEncoding (void);
+
+ /*
+ * Get the systemId for the underlying CharStream
+ */
+ virtual const ACEXML_Char* getSystemId (void);
+
+ /**
+ * Resets the pointer to the beginning of the stream.
+ */
+ virtual void rewind (void);
+
+private:
+ ACEXML_Char *start_;
+ ACEXML_Char *ptr_;
+ ACEXML_Char *end_;
+ ACEXML_Char* encoding_;
+ ACEXML_Char* name_;
+
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_STRCHARSTREAM_H_ */
diff --git a/ACE/ACEXML/common/StreamFactory.cpp b/ACE/ACEXML/common/StreamFactory.cpp
new file mode 100644
index 00000000000..7cee4c1a65f
--- /dev/null
+++ b/ACE/ACEXML/common/StreamFactory.cpp
@@ -0,0 +1,56 @@
+// $Id$
+
+#include "ace/OS_NS_string.h"
+
+#include "ACEXML/common/StreamFactory.h"
+#include "ACEXML/common/FileCharStream.h"
+#include "ACEXML/common/HttpCharStream.h"
+
+#ifdef USE_ZZIP
+#include "ACEXML/common/ZipCharStream.h"
+#endif /* USE_ZZIP */
+
+ACE_RCSID (common, StreamFactory, "$Id$")
+
+ACEXML_CharStream*
+ACEXML_StreamFactory::create_stream (const ACEXML_Char* uri)
+{
+ if (uri == 0)
+ return 0;
+ ACEXML_FileCharStream* fstream = 0;
+ ACEXML_HttpCharStream* hstream = 0;
+
+ if (ACE_OS::strstr (uri, ACE_TEXT("ftp://")) != 0)
+ {
+ return 0;
+ }
+ else if (ACE_OS::strstr (uri, ACE_TEXT ("http://")) != 0)
+ {
+ ACE_NEW_RETURN (hstream, ACEXML_HttpCharStream, 0);
+ if (hstream->open (uri) != -1)
+ return hstream;
+ }
+ else
+ {
+ if (ACE_OS::strstr (uri, ACE_TEXT ("file://")) != 0)
+ uri += 7; // Skip over file://
+ ACE_NEW_RETURN (fstream, ACEXML_FileCharStream, 0);
+ if (fstream->open (uri) != -1)
+ return fstream;
+#ifdef USE_ZZIP
+ else
+ {
+ ACEXML_ZipCharStream* zstream = 0;
+ ACE_NEW_RETURN (zstream, ACEXML_ZipCharStream, 0);
+ if (zstream->open (uri) != -1)
+ return zstream;
+ }
+#endif /* USE_ZZIP */
+ }
+ return 0;
+}
+
+ACEXML_StreamFactory::~ACEXML_StreamFactory ()
+{
+ // No op
+}
diff --git a/ACE/ACEXML/common/StreamFactory.h b/ACE/ACEXML/common/StreamFactory.h
new file mode 100644
index 00000000000..9391eb6a299
--- /dev/null
+++ b/ACE/ACEXML/common/StreamFactory.h
@@ -0,0 +1,58 @@
+/**
+ * @file StreamFactory.h
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+
+#ifndef _ACEXML_STREAM_FACTORY_H
+#define _ACEXML_STREAM_FACTORY_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+
+// Forward declarations
+
+class ACEXML_CharStream;
+
+/**
+ * @class ACEXML_StreamFactory StreamFactory.h "ACEXML/common/ACEXML_StreamFactory.h"
+ *
+ * @brief A generic factory used to create an appropriate @sa
+ * ACEXML_CharStream from a SYSTEM id. This class creates a @sa
+ * ACEXML_FileCharStream or a @sa ACEXML_HttpCharStream depending on the
+ * URI supplied.
+ *
+ * @todo Write a stream abstraction for handling ftp:// type URIs and add
+ * a function to create and return such streams. That is the only chunk
+ * missing in the armour.
+ */
+
+class ACEXML_Export ACEXML_StreamFactory
+{
+public:
+
+ // Destructor
+ virtual ~ACEXML_StreamFactory (void);
+
+ /**
+ * Create the appropriate stream from the @a uri passed and return the
+ * stream. The caller is responsible for deallocating the returned
+ * stream.
+ *
+ * @param uri SYSTEM id or a stream of characters (in the case of a
+ * StrCharStream).
+ */
+ virtual ACEXML_CharStream* create_stream (const ACEXML_Char* uri);
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_STREAM_FACTORY_H */
diff --git a/ACE/ACEXML/common/Transcode.cpp b/ACE/ACEXML/common/Transcode.cpp
new file mode 100644
index 00000000000..f94d93bba32
--- /dev/null
+++ b/ACE/ACEXML/common/Transcode.cpp
@@ -0,0 +1,311 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/Transcode.h"
+#include "ace/OS_NS_string.h"
+
+int
+ACEXML_Transcoder::utf162utf8 (ACEXML_UTF16 src,
+ ACEXML_UTF8 *dst,
+ size_t len)
+{
+ // Check for valid argument first...
+
+ if (dst == 0)
+ return ACEXML_INVALID_ARGS;
+
+ if (src < 0x80)
+ {
+ if (len < 1)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ *dst = static_cast<ACEXML_UTF8> (src);
+ return 1;
+ }
+ else if (src < 0x800)
+ {
+ if (len < 2)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ *dst = 0xc0 | (static_cast<ACEXML_UTF8> (src) / 0x40);
+ *(dst+1) = 0x80 | (static_cast<ACEXML_UTF8> (src) % 0x40);
+ return 2;
+ }
+ else
+ {
+ if (len < 3)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ // Surrogates (0xD800 - 0xDFFF) are not valid unicode values
+ if (src >= 0xD800 && src < 0xE000)
+ return ACEXML_IS_SURROGATE;
+
+ *dst = 0xe0 | (static_cast<ACEXML_UTF8> (src) / 0x1000);
+ *(dst+1) = 0x80 | ((static_cast<ACEXML_UTF8> (src) % 0x1000) / 0x40);
+ *(dst+2) = 0x80 | (static_cast<ACEXML_UTF8> (src) % 0x40);
+ return 3;
+ }
+}
+
+int
+ACEXML_Transcoder::ucs42utf8 (ACEXML_UCS4 src,
+ ACEXML_UTF8 *dst,
+ size_t len)
+{
+ if (src < 0x10000)
+ {
+ int retv = ACEXML_Transcoder::utf162utf8
+ (static_cast<ACEXML_UTF16> (src),
+ dst, len);
+ return (retv == ACEXML_IS_SURROGATE ? ACEXML_NON_UNICODE : retv);
+ }
+ else if (src >= 0x100000 && src < 0x110000)
+ {
+ if (len < 4)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ if (dst == 0)
+ return ACEXML_INVALID_ARGS;
+
+ *dst = 0xf0 | (static_cast<ACEXML_UTF8> (src / 0x40000));
+ *(dst+1) = 0x80 | ((static_cast<ACEXML_UTF8> (src % 0x40000)) / 0x1000);
+ *(dst+2) = 0x80 | ((static_cast<ACEXML_UTF8> (src % 0x1000)) / 0x40);
+ *(dst+3) = 0x80 | (static_cast<ACEXML_UTF8> (src % 0x40));
+ return 4;
+ }
+ return ACEXML_NON_UNICODE;
+}
+
+
+int
+ACEXML_Transcoder::ucs42utf16 (ACEXML_UCS4 src,
+ ACEXML_UTF16 *dst,
+ size_t len)
+{
+ if (dst == 0)
+ return ACEXML_INVALID_ARGS;
+
+ if (src < 0x10000)
+ {
+ if (len < 1)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ if (src >= 0xD800 && src < 0xE000)
+ return ACEXML_NON_UNICODE; // Surrogates are not valid unicode value
+
+ *dst = static_cast<ACEXML_UTF16> (src);
+ return 1;
+ }
+ else if (src >= 0x100000 && src < 0x110000)
+ // Scalar values are encoded into surrogates
+ {
+ if (len < 2)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ *dst = 0xD800 | (static_cast<ACEXML_UTF16> (src) / 0x400);
+ *(dst+1) = 0xDC00 | (static_cast<ACEXML_UTF16> (src) % 0x400);
+ return 2;
+ }
+
+ return ACEXML_NON_UNICODE;
+}
+
+int
+ACEXML_Transcoder::surrogate2utf8 (ACEXML_UTF16 high,
+ ACEXML_UTF16 low,
+ ACEXML_UTF8 *dst,
+ size_t len)
+{
+ if (len < 3)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ if (dst == 0 ||
+ (high >= 0xD800 && high < 0xDC00) ||
+ (low >= 0xDC00 && low < 0xE000))
+ return ACEXML_INVALID_ARGS;
+
+ ACEXML_UCS4 src = (high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000;
+ *dst = static_cast<ACEXML_UTF8> (0xD800 | (src / 0x400));
+ *(dst+1) = static_cast<ACEXML_UTF8> (0xDC00 | (src % 0x400));
+ return 2;
+}
+
+int
+ACEXML_Transcoder::surrogate2ucs4 (ACEXML_UTF16 high,
+ ACEXML_UTF16 low,
+ ACEXML_UCS4 &dst)
+{
+ if ((high >= 0xD800 && high < 0xDC00) ||
+ (low >= 0xDC00 && low < 0xE000))
+ return ACEXML_INVALID_ARGS;
+
+ dst = (high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000;
+ return ACEXML_SUCCESS;
+}
+
+int
+ACEXML_Transcoder::utf82ucs4 (const ACEXML_UTF8 *the_src,
+ size_t len,
+ ACEXML_UCS4 &dst)
+{
+ if (the_src == 0)
+ return ACEXML_INVALID_ARGS;
+
+ const unsigned char *src = reinterpret_cast<const unsigned char *> (the_src);
+
+ size_t forward = 1;
+
+ if (forward > len)
+ return ACEXML_END_OF_SOURCE;
+
+ if (static_cast<unsigned char> (*src) < 0x80)
+ dst = *src;
+ else if ((*src & 0xE0) == 0xC0)
+ {
+ dst = (*(src++) & 0x1f) * 0x40;
+ if (++forward > len)
+ return ACEXML_END_OF_SOURCE;
+ if ((*src & 0xC0) != 0x80)
+ return ACEXML_NON_UNICODE; // Error transcoding unicode scalar
+ dst += *src & 0x3f;
+ }
+ else if ((*src & 0xF0) == 0xE0)
+ {
+ dst = (*src++ & 0x0f) * 0x40;
+ if (++forward > len)
+ return ACEXML_END_OF_SOURCE;
+ if ((*src & 0xC0) != 0x80)
+ return ACEXML_NON_UNICODE;
+ dst = (dst + (*src++ & 0x3f)) * 0x40;
+ if (++forward > len)
+ return ACEXML_END_OF_SOURCE;
+ if ((*src & 0xC0) != 0x80)
+ return ACEXML_NON_UNICODE;
+ dst += *src & 0x3f;
+ }
+ else if ((*src & 0xF8) == 0xF0)
+ {
+ dst = (*src++ & 0x0f) * 0x40;
+ if (++forward > len)
+ return ACEXML_END_OF_SOURCE;
+ if ((*src & 0xC0) != 0x80)
+ return ACEXML_NON_UNICODE;
+ dst = (dst + (*src++ & 0x3f)) * 0x40;
+ if (++forward > len)
+ return ACEXML_END_OF_SOURCE;
+ if ((*src & 0xC0) != 0x80)
+ return ACEXML_NON_UNICODE;
+ dst = (dst + (*src++ & 0x3f)) * 0x40;
+ if (++forward > len)
+ return ACEXML_END_OF_SOURCE;
+ if ((*src & 0xC0) != 0x80)
+ return ACEXML_NON_UNICODE;
+ dst += *src & 0x3f;
+ }
+ else
+ return ACEXML_NON_UNICODE;
+
+ return forward;
+}
+
+int
+ACEXML_Transcoder::utf162ucs4 (const ACEXML_UTF16 *src,
+ size_t len,
+ ACEXML_UCS4 &dst)
+{
+ if (src == 0)
+ return ACEXML_INVALID_ARGS;
+
+ size_t forward = 1;
+ if (*src >= 0xDC00 && *src < 0xE000)
+ {
+ if (len < 2)
+ return ACEXML_END_OF_SOURCE;
+ return ACEXML_Transcoder::surrogate2ucs4 (*src,
+ *(src+1),
+ dst);
+ }
+ else
+ {
+ if (len < 1)
+ return ACEXML_END_OF_SOURCE;
+ dst = *src;
+ }
+
+ return forward;
+}
+
+int
+ACEXML_Transcoder::utf8s2utf16s (const ACEXML_UTF8 *src,
+ ACEXML_UTF16 *dst,
+ size_t len)
+{
+ if (src == 0 || dst == 0)
+ return ACEXML_INVALID_ARGS;
+
+ size_t src_len = ACE_OS::strlen (src) + 1;
+
+ size_t total_len = 0;
+ int forward;
+ ACEXML_UCS4 temp;
+
+ while (src_len > 0)
+ {
+ if ((forward = ACEXML_Transcoder::utf82ucs4 (src,
+ src_len,
+ temp)) <= 0)
+ return forward;
+
+ src += forward;
+ src_len -= forward;
+
+ if ((forward = ACEXML_Transcoder::ucs42utf16 (temp,
+ dst,
+ len)) <= 0)
+ return forward;
+
+ total_len += forward;
+ dst += forward;
+ len -= forward;
+ }
+
+ return static_cast<int> (total_len);
+}
+
+int
+ACEXML_Transcoder::utf16s2utf8s (const ACEXML_UTF16 *src,
+ ACEXML_UTF8 *dst,
+ size_t len)
+{
+ if (src == 0 || dst == 0)
+ return ACEXML_INVALID_ARGS;
+
+ size_t src_len = 1;
+ for (const ACEXML_UTF16 *p = src; *p++ != 0; ++src_len)
+ ;
+
+ size_t total_len = 0;
+ int forward;
+ ACEXML_UCS4 temp;
+
+ while (src_len > 0)
+ {
+ if ((forward = ACEXML_Transcoder::utf162ucs4 (src,
+ src_len,
+ temp)) <= 0)
+ return forward;
+
+ src += forward;
+ src_len -= forward;
+
+ if ((forward = ACEXML_Transcoder::ucs42utf8 (temp,
+ dst,
+ len)) <= 0)
+ return forward;
+
+ total_len += forward;
+ dst += forward;
+ len -= forward;
+ }
+
+ return static_cast<int> (total_len);
+}
diff --git a/ACE/ACEXML/common/Transcode.h b/ACE/ACEXML/common/Transcode.h
new file mode 100644
index 00000000000..1acf294c7aa
--- /dev/null
+++ b/ACE/ACEXML/common/Transcode.h
@@ -0,0 +1,172 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Transcode.h
+ *
+ * This file declares functions to convert char string among different
+ * unicode encoding (utf8, utf16, utf32)
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_TRANSCODE_H_
+#define _ACEXML_TRANSCODE_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+
+/**
+ * @class ACEXML_Transcoder Transcode.h "ACEXML/common/Transcode.h"
+ *
+ * @brief ACEXML_Transcoder
+ *
+ * Wrapper class for performing transcoding among different UNICODE
+ * encoding.
+ */
+class ACEXML_Export ACEXML_Transcoder
+{
+public:
+ /*
+ * Status of the conversion function.
+ */
+ enum
+ {
+ ACEXML_SUCCESS = 0,
+ ACEXML_DESTINATION_TOO_SHORT = -1,
+ ACEXML_END_OF_SOURCE = -2,
+ ACEXML_INVALID_ARGS = -3,
+ ACEXML_IS_SURROGATE = -4,
+ ACEXML_NON_UNICODE = -5
+ } ACEXML_STATUS;
+
+
+ // The following functions translate a unicode characters
+ // into different encoding. Return number of characters put into
+ // destination or consumed from src if success without
+ // error, otherwise, return corresponding error code.
+ /*
+ * 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 it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int utf162utf8 (ACEXML_UTF16 src,
+ ACEXML_UTF8 *dst,
+ size_t len);
+
+ /*
+ * 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 it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int ucs42utf8 (ACEXML_UCS4 src,
+ ACEXML_UTF8 *dst,
+ size_t len);
+
+ /*
+ * 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 it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int ucs42utf16 (ACEXML_UCS4 src,
+ ACEXML_UTF16 *dst,
+ size_t len);
+
+ /*
+ * 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 it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int surrogate2utf8 (ACEXML_UTF16 high,
+ ACEXML_UTF16 low,
+ ACEXML_UTF8 *dst,
+ size_t len);
+
+ /*
+ * Convert a UTF-16 surrogate character pair into a UCS-4 character.
+ *
+ * @return SUCCESS if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int surrogate2ucs4 (ACEXML_UTF16 high,
+ ACEXML_UTF16 low,
+ ACEXML_UCS4 &dst);
+
+ /*
+ * Convert the first UNICODE character in a UTF-8 character string
+ * into a UCS-4 character.
+ *
+ * @return number of characters the function consumed from the
+ * UTF-8 string if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int utf82ucs4 (const ACEXML_UTF8 *src,
+ size_t len,
+ ACEXML_UCS4 &dst);
+
+ /*
+ * Convert the first UNICODE character in a UTF-16 character string
+ * into a UCS-4 character.
+ *
+ * @return number of characters the function consumed from the
+ * UTF-16 string if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int utf162ucs4 (const ACEXML_UTF16 *src,
+ size_t len,
+ ACEXML_UCS4 &dst);
+
+// static int utf82utf16 (const ACEXML_UTF8 *src,
+// size_t len,
+// ACEXML_UTF16 &dst);
+ // This function does not handle surrogates.
+
+ // = The following functions are non-inlined:
+
+ /*
+ * Convert a UTF-8 string into a UTF-16 string.
+ *
+ * @param len The length of @a dst string.
+ *
+ * @return number of characters the function consumed from the
+ * UTF-8 string if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int utf8s2utf16s (const ACEXML_UTF8 *src,
+ ACEXML_UTF16 *dst,
+ size_t len);
+
+ /*
+ * Convert a UTF-16 string into a UTF-8 string.
+ *
+ * @param len The length of @a dst string.
+ *
+ * @return number of characters the function uses in
+ * UTF-8 string if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int utf16s2utf8s (const ACEXML_UTF16 *src,
+ ACEXML_UTF8 *dst,
+ size_t len);
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_TRANSCODE_H_ */
diff --git a/ACE/ACEXML/common/URL_Addr.cpp b/ACE/ACEXML/common/URL_Addr.cpp
new file mode 100644
index 00000000000..b58c916c73f
--- /dev/null
+++ b/ACE/ACEXML/common/URL_Addr.cpp
@@ -0,0 +1,177 @@
+// $Id$
+
+#include "ACEXML/common/URL_Addr.h"
+
+ACE_RCSID(common, ACEXML_URL_Addr, "$Id$")
+
+#if !defined (__ACEXML_INLINE__)
+#include "ACEXML/common/URL_Addr.inl"
+#endif /* __ACEXML_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_stdlib.h"
+#include "ace/OS_NS_string.h"
+
+ACEXML_URL_Addr::ACEXML_URL_Addr (void)
+ : path_name_ (0),
+ addr_string_ (0),
+ addr_string_len_ (0)
+{
+}
+
+int
+ACEXML_URL_Addr::addr_to_string (ACEXML_Char *s,
+ size_t size,
+ int ipaddr_format) const
+{
+ size_t total_len = this->calculate_length (ipaddr_format);
+ if (size < total_len)
+ return -1;
+ else
+ {
+ ACE_OS::sprintf (s, ACE_TEXT ("%s:%d/%s"),
+ ACE_TEXT_CHAR_TO_TCHAR (ipaddr_format == 0
+ ? this->get_host_name ()
+ : this->get_host_addr ()),
+ this->get_port_number (),
+ this->get_path_name ());
+ return 0;
+ }
+}
+
+const ACEXML_Char *
+ACEXML_URL_Addr::addr_to_string (int ipaddr_format)
+{
+ size_t size = this->calculate_length (ipaddr_format);
+ if (size > this->addr_string_len_)
+ {
+ ACE_ALLOCATOR_RETURN (this->addr_string_,
+ (ACEXML_Char *) ACE_OS::realloc(this->addr_string_,
+ size), 0);
+ this->addr_string_len_ = size;
+ }
+ ACE_OS::sprintf (this->addr_string_,
+ ACE_TEXT ("%s:%d/%s"),
+ ACE_TEXT_CHAR_TO_TCHAR (ipaddr_format == 0
+ ? this->get_host_name ()
+ : this->get_host_addr ()),
+ this->get_port_number (),
+ this->get_path_name ());
+ return this->addr_string_;
+}
+
+#if defined (ACE_USES_WCHAR)
+int
+ACEXML_URL_Addr::string_to_addr (const char* s)
+{
+ return this->string_to_addr (ACE_TEXT_CHAR_TO_TCHAR (s));
+}
+#endif /* ACE_USES_WCHAR */
+
+int
+ACEXML_URL_Addr::string_to_addr (const ACEXML_Char* s)
+{
+ if (s == 0)
+ return -1;
+
+ const ACEXML_Char* http = ACE_TEXT ("http://");
+ size_t http_len = ACE_OS::strlen (http);
+
+ // Check validity of URL
+ if (ACE_OS::strncmp (http, s, http_len) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Invalid URL %s\n"), s), -1);
+
+ const ACEXML_Char* url = 0;
+ // Get the host name
+ for (url = s + http_len; *url != '\0' && *url != ':' && *url != '/'; ++url)
+ ;
+
+ size_t host_len = url - s;
+ host_len -= http_len;
+
+ ACEXML_Char* host_name = 0;
+ ACE_NEW_RETURN (host_name, ACEXML_Char[host_len + 1], -1);
+ ACE_OS::strncpy (host_name, s + http_len, host_len);
+ host_name[host_len] = '\0';
+ ACE_Auto_Basic_Array_Ptr<ACEXML_Char> cleanup_host_name (host_name);
+
+ // Get the port number (if any)
+ unsigned short port = ACE_DEFAULT_HTTP_PORT;
+ if (*url == ':')
+ {
+ port = (unsigned short) ACE_OS::strtol (++url, 0, 10); // Skip over ':'
+ while ( *url != '\0' && *url != '/' )
+ ++url;
+ }
+
+ // Set the addr
+ int result = this->ACE_INET_Addr::set (port, host_name);
+
+ if (result == -1)
+ return -1;
+
+ // Get the path name
+ const ACEXML_Char* path_name = 0;
+ if (*url == '\0')
+ path_name = ACE_TEXT ("/");
+ else
+ path_name = url;
+
+ ACE_ALLOCATOR_RETURN (this->path_name_, ACE_OS::strdup (path_name), -1);
+ return result;
+}
+
+ACEXML_URL_Addr::ACEXML_URL_Addr (const ACEXML_URL_Addr &addr)
+ : ACE_INET_Addr (),
+ path_name_ (0),
+ addr_string_ (0),
+ addr_string_len_ (0)
+{
+ if (this->set (addr) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACEXML_URL_Addr::ACEXML_URL_Addr")));
+}
+
+int
+ACEXML_URL_Addr::set (const ACEXML_URL_Addr &addr)
+{
+ ACE_OS::free (this->path_name_);
+ ACE_OS::free (this->addr_string_);
+ if (this->ACE_INET_Addr::set (addr) == -1)
+ return -1;
+ else
+ {
+ if (addr.path_name_)
+ ACE_ALLOCATOR_RETURN (this->path_name_,
+ ACE_OS::strdup (addr.path_name_),
+ -1);
+ if (addr.addr_string_)
+ ACE_ALLOCATOR_RETURN (this->addr_string_,
+ ACE_OS::strdup (addr.addr_string_),
+ -1);
+ this->addr_string_len_ = addr.addr_string_len_;
+ return 0;
+ }
+}
+
+ACEXML_URL_Addr::ACEXML_URL_Addr (const ACEXML_Char *host_name,
+ const ACEXML_Char *path_name,
+ unsigned short port)
+ : ACE_INET_Addr (port, host_name),
+ path_name_ (ACE_OS::strdup (path_name)),
+ addr_string_ (0),
+ addr_string_len_ (0)
+{
+}
+
+ACEXML_URL_Addr::~ACEXML_URL_Addr (void)
+{
+ ACE_OS::free (this->path_name_);
+ ACE_OS::free (this->addr_string_);
+ this->path_name_ = 0;
+}
+
diff --git a/ACE/ACEXML/common/URL_Addr.h b/ACE/ACEXML/common/URL_Addr.h
new file mode 100644
index 00000000000..d7f7b4b6702
--- /dev/null
+++ b/ACE/ACEXML/common/URL_Addr.h
@@ -0,0 +1,135 @@
+/* -*- C++ -*- */
+
+/** @file URL_Addr.h
+ *
+ * $Id$
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ *
+ */
+
+#ifndef _ACEXML_URL_ADDR_H
+#define _ACEXML_URL_ADDR_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Default_Constants.h"
+#include "ace/INET_Addr.h"
+#include "ACEXML/common/XML_Types.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+/**
+ * @class ACEXML_URL_Addr URL_Addr.h "ACEXML/common/URL_Addr.h"
+ *
+ * Defines a URL address family address format.
+ */
+class ACEXML_Export ACEXML_URL_Addr : public ACE_INET_Addr
+{
+public:
+ /// Initialization and termination methods.
+ ACEXML_URL_Addr (void);
+
+ /// Constructor.
+ ACEXML_URL_Addr (const ACEXML_Char *host_name,
+ const ACEXML_Char *path_name,
+ unsigned short port = ACE_DEFAULT_HTTP_PORT);
+
+ /// Copy constructor.
+ ACEXML_URL_Addr (const ACEXML_URL_Addr &addr);
+
+ /// Essentially the copy constructor.
+ int set (const ACEXML_URL_Addr &addr);
+
+ /**
+ * Initializes an <ACEXML_URL_Addr> from the <address>, which can be
+ * "ip-number:port-number/path-name" (e.g.,
+ * "www.cs.wustl.edu:1234/~schmidt/" "ip-number:port-number/path-name"
+ * (e.g., "128.252.166.57:1234/~schmidt"). If there is no ':' in the
+ * <address> it is assumed to be an ip-number or ip-address number, with
+ * the port number <ACE_DEFAULT_HTTP_PORT>.
+ */
+ virtual int string_to_addr (const ACEXML_Char* address);
+
+ // Function to shut up Borland C++
+#if defined (ACE_USES_WCHAR)
+ virtual int string_to_addr (const char* address);
+#endif
+
+ /**
+ * Transform the current <ACE_INET_Addr> address into string format. If
+ * <ipaddr_format> is non-0 this produces
+ * "ip-number:port-number/path-name" (e.g.,
+ * "128.252.166.57:80/~schmidt/"), whereas if <ipaddr_format> is 0 this
+ * produces "ip-name:port-number" (e.g.,
+ * "www.cs.wustl.edu:80/~schmidt/"). Returns -1 if the <size> of the
+ * <buffer> is too small, else 0.
+ */
+ virtual int addr_to_string (ACEXML_Char *s,
+ size_t size,
+ int ipaddr_format = 1) const;
+
+ /**
+ * Transform the current <ACE_INET_Addr> address into string format. If
+ * <ipaddr_format> is non-0 this produces
+ * "ip-number:port-number/path-name" (e.g.,
+ * "128.252.166.57:80/~schmidt/"), whereas if <ipaddr_format> is 0 this
+ * produces "ip-name:port-number" (e.g.,
+ * "www.cs.wustl.edu:80/~schmidt/"). Uses dynamic memory, which is
+ * allocated on demand and deallocated when the object is destroyed.
+ * Returns -1 if dynamic memory fails, else 0.
+ */
+ virtual const ACEXML_Char *addr_to_string (int ipaddr_format = 1);
+
+ /// Assignment operator.
+ void operator= (const ACEXML_URL_Addr &addr);
+
+ /// Destructor.
+ ~ACEXML_URL_Addr (void);
+
+ /**
+ * Compare two addresses for equality. The addresses are considered
+ * equal if they contain the same IP address, port number, and path name.
+ */
+ bool operator == (const ACEXML_URL_Addr &SAP) const;
+
+ /// Compare two addresses for inequality.
+ bool operator != (const ACEXML_URL_Addr &SAP) const;
+
+ /// Computes and returns hash value.
+ virtual u_long hash (void) const;
+
+ /// Return the path name.
+ const ACEXML_Char *get_path_name (void) const;
+
+ /// Commit suicide.
+ int destroy (void);
+
+private:
+
+ /// Calculate the maximum length of the address string
+ size_t calculate_length (int ipaddr_format) const;
+
+ /// Our path name.
+ ACEXML_Char *path_name_;
+
+ /// The dynamically created address string that's used for the
+ /// <addr_to_string> method.
+ ACEXML_Char *addr_string_;
+
+ /// Current length of the <addr_string_>
+ size_t addr_string_len_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/URL_Addr.inl"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_URL_ADDR_H */
diff --git a/ACE/ACEXML/common/URL_Addr.inl b/ACE/ACEXML/common/URL_Addr.inl
new file mode 100644
index 00000000000..b1ac1db8322
--- /dev/null
+++ b/ACE/ACEXML/common/URL_Addr.inl
@@ -0,0 +1,65 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#include "ace/ACE.h"
+#include "ace/INET_Addr.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+
+ACE_INLINE size_t
+ACEXML_URL_Addr::calculate_length (int ipaddr_format) const
+{
+ return ACE_OS::strlen (ipaddr_format == 0 ?
+ this->get_host_name () : this->get_host_addr ())
+ + ACE_OS::strlen ("65536") // Assume the max port number.
+ + ACE_OS::strlen (this->get_path_name ())
+ + sizeof (':')
+ + sizeof ('/')
+ + sizeof ('\0'); // For trailing '\0'.
+}
+
+ACE_INLINE void
+ACEXML_URL_Addr::operator= (const ACEXML_URL_Addr &addr)
+{
+ if (this->set (addr) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACEXML_URL_Addr::ACEXML_URL_Addr")));
+}
+
+ACE_INLINE u_long
+ACEXML_URL_Addr::hash (void) const
+{
+ u_long result = this->ACE_INET_Addr::hash ()
+ + ACE::hash_pjw (this->get_path_name ());
+ return result;
+}
+
+ACE_INLINE bool
+ACEXML_URL_Addr::operator== (const ACEXML_URL_Addr &addr) const
+{
+ return ACE_OS::strcmp (addr.get_path_name (), this->get_path_name ()) == 0
+ && addr.get_port_number () == this->get_port_number ()
+ && addr.get_ip_address () == this->get_ip_address ();
+}
+
+ACE_INLINE bool
+ACEXML_URL_Addr::operator!= (const ACEXML_URL_Addr &addr) const
+{
+ return !(*this == addr);
+}
+
+ACE_INLINE const ACEXML_Char *
+ACEXML_URL_Addr::get_path_name (void) const
+{
+ return this->path_name_;
+}
+
+ACE_INLINE int
+ACEXML_URL_Addr::destroy (void)
+{
+ // Commit suicide.
+ delete this;
+ return 0;
+}
diff --git a/ACE/ACEXML/common/Validator.cpp b/ACE/ACEXML/common/Validator.cpp
new file mode 100644
index 00000000000..cf3ce502200
--- /dev/null
+++ b/ACE/ACEXML/common/Validator.cpp
@@ -0,0 +1,8 @@
+// $Id$
+
+#include "ACEXML/common/Validator.h"
+
+ACEXML_Validator::~ACEXML_Validator ()
+{
+
+}
diff --git a/ACE/ACEXML/common/Validator.h b/ACE/ACEXML/common/Validator.h
new file mode 100644
index 00000000000..0d006396498
--- /dev/null
+++ b/ACE/ACEXML/common/Validator.h
@@ -0,0 +1,64 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Validator.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_VALIDATOR_H_
+#define _ACEXML_VALIDATOR_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Attributes.h"
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/SAXExceptions.h"
+
+/**
+ * @class ACEXML_Validator Validator.h "common/Validator.h"
+ *
+ * @brief An abstract virtual class defining validator interface.
+ *
+ * An validator provides validation service for one XML element.
+ * ACEXML_Validators are stateful object. Implementations should
+ * remember the current element encountered and determine if
+ * it's a valid sequence of child elements. A parser fishes
+ * out a validator of certain
+ */
+class ACEXML_Export ACEXML_Validator
+{
+public:
+ virtual ~ACEXML_Validator () = 0;
+
+ /**
+ * Validate attributes of an element.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int startElement (ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Validate the next child element.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int nextElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_VALIDATOR_H_ */
diff --git a/ACE/ACEXML/common/XMLFilter.h b/ACE/ACEXML/common/XMLFilter.h
new file mode 100644
index 00000000000..c012ee706e2
--- /dev/null
+++ b/ACE/ACEXML/common/XMLFilter.h
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file XMLFilter.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_XMLFILTER_H_
+#define _ACEXML_XMLFILTER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XMLReader.h"
+
+/**
+ * @class ACEXML_XMLFilter XMLFilter.h "ACEXML/common/XMLFilter.h"
+ *
+ * @brief ACEXML_XMLFilter
+ *
+ * An XML filter is like an XML reader, except that it obtains its events
+ * from another XML reader rather than a primary source like an XML
+ * document or database. Filters can modify a stream of events as they pass
+ * on to the final application.
+ *
+ * The XMLFilterImpl helper class provides a convenient base for creating
+ * SAX2 filters, by passing on all ACEXML_EntityResolver,
+ * ACEXML_DTDHandler, ACEXML_ContentHandler and ACEXML_ErrorHandler events
+ * automatically.
+ */
+class ACEXML_Export ACEXML_XMLFilter : public ACEXML_XMLReader
+{
+public:
+ /**
+ * Get the parent reader.
+ */
+ virtual ACEXML_XMLReader *getParent (void) const = 0;
+
+ /**
+ * Set the parent reader.
+ */
+ virtual void setParent (ACEXML_XMLReader *parent) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_XMLFILTER_H_ */
diff --git a/ACE/ACEXML/common/XMLFilterImpl.cpp b/ACE/ACEXML/common/XMLFilterImpl.cpp
new file mode 100644
index 00000000000..300c6b7ea4b
--- /dev/null
+++ b/ACE/ACEXML/common/XMLFilterImpl.cpp
@@ -0,0 +1,339 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/XMLFilterImpl.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/common/XMLFilterImpl.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_XMLFilterImpl::ACEXML_XMLFilterImpl (void)
+ : parent_ (0),
+ locator_ (0),
+ entityResolver_ (0),
+ dtdHandler_ (0),
+ contentHandler_ (0),
+ errorHandler_ (0)
+{
+}
+
+ACEXML_XMLFilterImpl::ACEXML_XMLFilterImpl (ACEXML_XMLReader *parent)
+ : parent_ (parent),
+ locator_ (0),
+ entityResolver_ (0),
+ dtdHandler_ (0),
+ contentHandler_ (0),
+ errorHandler_ (0)
+{
+}
+
+ACEXML_XMLFilterImpl::~ACEXML_XMLFilterImpl (void)
+{
+ // @@ How are all the object lifecycles managed?
+}
+
+void
+ACEXML_XMLFilterImpl::parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->setupParser () < 0)
+ {
+ ACEXML_THROW (ACEXML_SAXException (ACE_TEXT ("No Parent available")));
+ }
+ this->parent_->parse (input ACEXML_ENV_ARG_PARAMETER);
+ return;
+}
+
+void
+ACEXML_XMLFilterImpl::parse (const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->setupParser () < 0)
+ {
+ ACEXML_THROW (ACEXML_SAXException (ACE_TEXT ("No Parent available")));
+ }
+
+ this->parent_->parse (new ACEXML_InputSource (systemId) ACEXML_ENV_ARG_PARAMETER);
+ return;
+}
+
+int
+ACEXML_XMLFilterImpl::getFeature (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException))
+{
+ if (this->parent_ != 0)
+ return this->parent_->getFeature (name ACEXML_ENV_ARG_PARAMETER);
+
+ ACEXML_THROW_RETURN (ACEXML_SAXNotRecognizedException (name), 0);
+}
+
+void *
+ACEXML_XMLFilterImpl::getProperty (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException))
+{
+ if (this->parent_ != 0)
+ return this->parent_->getProperty (name ACEXML_ENV_ARG_PARAMETER);
+
+ ACEXML_THROW_RETURN (ACEXML_SAXNotRecognizedException (name), 0);
+}
+
+void
+ACEXML_XMLFilterImpl::setFeature (const ACEXML_Char *name,
+ int boolean_value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException))
+{
+ if (this->parent_ != 0)
+ {
+ this->parent_->setFeature (name,
+ boolean_value ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+
+ ACEXML_THROW (ACEXML_SAXNotRecognizedException (name));
+}
+
+void
+ACEXML_XMLFilterImpl::setProperty (const ACEXML_Char *name,
+ void *value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException))
+{
+ if (this->parent_ != 0)
+ {
+ this->parent_->setProperty (name,
+ value ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+
+ ACEXML_THROW (ACEXML_SAXNotRecognizedException (name));
+}
+
+ACEXML_XMLReader *
+ACEXML_XMLFilterImpl::getParent (void) const
+{
+ return this->parent_;
+}
+
+void
+ACEXML_XMLFilterImpl::setParent (ACEXML_XMLReader *parent)
+{
+ this->parent_ = parent;
+}
+
+void
+ACEXML_XMLFilterImpl::characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->characters (ch, start, length ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::endDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->endDocument (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->endElement (namespaceURI,
+ localName,
+ qName ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->endPrefixMapping (prefix ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->ignorableWhitespace (ch,
+ start,
+ length ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->processingInstruction (target,
+ data ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::setDocumentLocator (ACEXML_Locator *locator)
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->setDocumentLocator (locator);
+}
+
+void
+ACEXML_XMLFilterImpl::skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->skippedEntity (name ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::startDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->startDocument (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->startElement (namespaceURI,
+ localName,
+ qName,
+ atts ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->startPrefixMapping (prefix,
+ uri ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->dtdHandler_ != 0)
+ this->dtdHandler_->notationDecl (name,
+ publicId,
+ systemId ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->dtdHandler_ != 0)
+ this->dtdHandler_->unparsedEntityDecl (name,
+ publicId,
+ systemId,
+ notationName ACEXML_ENV_ARG_PARAMETER);
+}
+
+ACEXML_InputSource *
+ACEXML_XMLFilterImpl::resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->entityResolver_ != 0)
+ return this->entityResolver_->resolveEntity (publicId,
+ systemId ACEXML_ENV_ARG_PARAMETER);
+ return 0;
+}
+
+void
+ACEXML_XMLFilterImpl::error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->errorHandler_ != 0)
+ this->errorHandler_->error (exception ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->errorHandler_ != 0)
+ this->errorHandler_->fatalError (exception ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->errorHandler_ != 0)
+ this->errorHandler_->warning (exception ACEXML_ENV_ARG_PARAMETER);
+}
+
+ACEXML_DTDHandler *
+ACEXML_XMLFilterImpl::getDTDHandler (void) const
+{
+ return this->dtdHandler_;
+}
+
+ACEXML_ContentHandler *
+ACEXML_XMLFilterImpl::getContentHandler (void) const
+{
+ return this->contentHandler_;
+}
+
+ACEXML_EntityResolver *
+ACEXML_XMLFilterImpl::getEntityResolver (void) const
+{
+ return this->entityResolver_;
+}
+
+ACEXML_ErrorHandler *
+ACEXML_XMLFilterImpl::getErrorHandler (void) const
+{
+ return this->errorHandler_;
+}
+
+void
+ACEXML_XMLFilterImpl::setDTDHandler (ACEXML_DTDHandler *handler)
+{
+ this->dtdHandler_ = handler;
+}
+
+void
+ACEXML_XMLFilterImpl::setContentHandler (ACEXML_ContentHandler *handler)
+{
+ this->contentHandler_ = handler;
+}
+
+void
+ACEXML_XMLFilterImpl::setEntityResolver (ACEXML_EntityResolver *handler)
+{
+ this->entityResolver_ = handler;
+}
+
+void
+ACEXML_XMLFilterImpl::setErrorHandler (ACEXML_ErrorHandler *handler)
+{
+ this->errorHandler_ = handler;
+}
diff --git a/ACE/ACEXML/common/XMLFilterImpl.h b/ACE/ACEXML/common/XMLFilterImpl.h
new file mode 100644
index 00000000000..52963580636
--- /dev/null
+++ b/ACE/ACEXML/common/XMLFilterImpl.h
@@ -0,0 +1,294 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file XMLFilterImpl.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef ACEXML_XMLFILTERIMPL_H
+#define ACEXML_XMLFILTERIMPL_H
+#include /**/ "ace/pre.h"
+
+#include "ACEXML/common/XMLFilter.h"
+#include "ACEXML/common/XMLReader.h"
+#include "ACEXML/common/Locator.h"
+#include "ACEXML/common/ContentHandler.h"
+#include "ACEXML/common/DTDHandler.h"
+#include "ACEXML/common/EntityResolver.h"
+#include "ACEXML/common/ErrorHandler.h"
+
+/**
+ * @class ACEXML_XMLFilterImpl XMLFilterImpl.h "ACEXML/common/XMLFilterImpl.h"
+ *
+ * @brief ACEXML_XMLFilterImpl
+ *
+ * This class is designed to sit between an XMLReader and the client
+ * application's event handlers. By default, it does nothing but pass
+ * requests up to the reader and events on to the handlers unmodified, but
+ * subclasses can override specific methods to modify the event stream or
+ * the configuration requests as they pass through.
+ */
+class ACEXML_Export ACEXML_XMLFilterImpl
+ : public ACEXML_XMLFilter,
+ public ACEXML_ContentHandler,
+ public ACEXML_DTDHandler,
+ public ACEXML_EntityResolver,
+ public ACEXML_ErrorHandler
+{
+public:
+ /**
+ * Default constructor. Create with no parent.
+ */
+ ACEXML_XMLFilterImpl (void);
+
+ /**
+ * Construct an XML filter with the specified parent.
+ */
+ ACEXML_XMLFilterImpl (ACEXML_XMLReader *parent);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ACEXML_XMLFilterImpl (void);
+
+ /*
+ * Look up the value of a feature.
+ */
+ virtual int getFeature (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) ;
+
+ /*
+ * Look up the value of a property.
+ */
+ virtual void * getProperty (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) ;
+
+ /*
+ * Parse an XML document.
+ */
+ virtual void parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Parse an XML document from a system identifier (URI).
+ */
+ virtual void parse (const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ // @@ throw IOException???
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Set the state of a feature.
+ */
+ virtual void setFeature (const ACEXML_Char *name,
+ int boolean_value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) ;
+
+ /*
+ * Set the value of a property.
+ */
+ virtual void setProperty (const ACEXML_Char *name,
+ void *value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) ;
+
+ /*
+ * Get the parent reader.
+ */
+ virtual ACEXML_XMLReader *getParent (void) const;
+
+ /*
+ * Set the parent reader.
+ */
+ virtual void setParent (ACEXML_XMLReader *parent);
+
+ /*
+ * Get the current DTD event handler.
+ */
+ virtual ACEXML_DTDHandler *getDTDHandler (void) const;
+
+ /*
+ * Get the current content event handler.
+ */
+ virtual ACEXML_ContentHandler *getContentHandler (void) const;
+
+ /*
+ * Get the current entity resolver.
+ */
+ virtual ACEXML_EntityResolver *getEntityResolver (void) const;
+
+ /*
+ * Get the current error event handler.
+ */
+ virtual ACEXML_ErrorHandler *getErrorHandler (void) const;
+
+ /*
+ * Set the DTD event handler.
+ */
+ virtual void setDTDHandler (ACEXML_DTDHandler *handler);
+
+ /*
+ * Set the content event handler.
+ */
+ virtual void setContentHandler (ACEXML_ContentHandler *handler);
+
+ /*
+ * Set the entity resolver.
+ */
+ virtual void setEntityResolver (ACEXML_EntityResolver *handler);
+
+ /*
+ * Set the error event handler.
+ */
+ virtual void setErrorHandler (ACEXML_ErrorHandler *handler);
+
+ /*
+ * Receive notification of character data.
+ */
+ virtual void characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the end of a document.
+ */
+ virtual void endDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the end of an element.
+ */
+ virtual void endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * End the scope of a prefix-URI mapping.
+ */
+ virtual void endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of ignorable whitespace in element content.
+ */
+ virtual void ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of a processing instruction.
+ */
+ virtual void processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive an object for locating the origin of SAX document events.
+ */
+ virtual void setDocumentLocator (ACEXML_Locator *locator) ;
+
+ /*
+ * Receive notification of a skipped entity.
+ */
+ virtual void skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the beginning of a document.
+ */
+ virtual void startDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the beginning of an element.
+ */
+ virtual void startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Begin the scope of a prefix-URI Namespace mapping.
+ */
+ virtual void startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ // *** Methods inherit from ACEXML_DTDHandler.
+
+ /*
+ * Receive notification of a notation declaration event.
+ */
+ virtual void notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of an unparsed entity declaration event.
+ */
+ virtual void unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ // Methods inherit from ACEXML_EnitityResolver.
+
+ /*
+ * Allow the application to resolve external entities.
+ */
+ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ // Methods inherit from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+ virtual void error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /*
+ * Receive notification of a non-recoverable error.
+ */
+ virtual void fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /*
+ * Receive notification of a warning.
+ */
+ virtual void warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+protected:
+ int setupParser (void);
+ // Set up the event handlers of parent parser to this.
+ // Returns -1 if no valid parent is set.
+
+private:
+ ACEXML_XMLReader *parent_;
+ ACEXML_Locator *locator_;
+ ACEXML_EntityResolver *entityResolver_;
+ ACEXML_DTDHandler *dtdHandler_;
+ ACEXML_ContentHandler *contentHandler_;
+ ACEXML_ErrorHandler *errorHandler_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/XMLFilterImpl.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* ACEXML_XMLFILTERIMPL_H */
diff --git a/ACE/ACEXML/common/XMLFilterImpl.i b/ACE/ACEXML/common/XMLFilterImpl.i
new file mode 100644
index 00000000000..4be2ceeceea
--- /dev/null
+++ b/ACE/ACEXML/common/XMLFilterImpl.i
@@ -0,0 +1,14 @@
+// -*- C++ -*- $Id$
+
+ACEXML_INLINE int
+ACEXML_XMLFilterImpl::setupParser (void)
+{
+ if (this->parent_ == 0)
+ return -1;
+
+ this->parent_->setEntityResolver (this);
+ this->parent_->setDTDHandler (this);
+ this->parent_->setContentHandler (this);
+ this->parent_->setErrorHandler (this);
+ return 0;
+}
diff --git a/ACE/ACEXML/common/XMLReader.cpp b/ACE/ACEXML/common/XMLReader.cpp
new file mode 100644
index 00000000000..d762c79a3a2
--- /dev/null
+++ b/ACE/ACEXML/common/XMLReader.cpp
@@ -0,0 +1,11 @@
+#include "XMLReader.h"
+
+
+ACE_RCSID (common,
+ XMLReader,
+ "$Id$")
+
+
+ACEXML_XMLReader::~ACEXML_XMLReader (void)
+{
+}
diff --git a/ACE/ACEXML/common/XMLReader.h b/ACE/ACEXML/common/XMLReader.h
new file mode 100644
index 00000000000..c95024d3dd4
--- /dev/null
+++ b/ACE/ACEXML/common/XMLReader.h
@@ -0,0 +1,136 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file XMLReader.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_XMLREADER_H_
+#define _ACEXML_XMLREADER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/ContentHandler.h"
+#include "ACEXML/common/DTDHandler.h"
+#include "ACEXML/common/EntityResolver.h"
+#include "ACEXML/common/ErrorHandler.h"
+
+/**
+ * @class ACEXML_XMLReader XMLReader.h "ACEXML/common/XMLReader.h"
+ *
+ * @brief ACEXML_XMLReader
+ *
+ * XMLReader is the interface that an XML parser's SAX2 driver must
+ * implement. This interface allows an application to set and query
+ * features and properties in the parser, to register event handlers
+ * for document processing, and to initiate a document parse.
+ *
+ * All SAX interfaces are assumed to be synchronous: the parse methods
+ * must not return until parsing is complete, and readers must wait
+ * for an event-handler callback to return before reporting the next
+ * event.
+ */
+class ACEXML_Export ACEXML_XMLReader
+{
+public:
+
+ virtual ~ACEXML_XMLReader (void);
+
+ /**
+ * Return the current content handler.
+ */
+ virtual ACEXML_ContentHandler *getContentHandler (void) const = 0;
+
+ /**
+ * Return the current DTD handler.
+ */
+ virtual ACEXML_DTDHandler *getDTDHandler (void) const = 0;
+
+ /**
+ * Return the current entity resolver.
+ */
+ virtual ACEXML_EntityResolver *getEntityResolver (void) const = 0;
+
+ /**
+ * Return the current error handler.
+ */
+ virtual ACEXML_ErrorHandler *getErrorHandler (void) const = 0;
+
+ /**
+ * Look up the value of a feature. This method allows
+ * programmers to check whether a specific feature has been
+ * activated in the parser.
+ */
+ virtual int getFeature (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) = 0;
+
+ /**
+ * Look up the value of a property.
+ */
+ virtual void * getProperty (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) = 0;
+
+ /**
+ * Parse an XML document.
+ */
+ virtual void parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Parse an XML document from a system identifier (URI).
+ */
+ virtual void parse (const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Allow an application to register a content event handler.
+ */
+ virtual void setContentHandler (ACEXML_ContentHandler *handler) = 0;
+
+ /**
+ * Allow an application to register a DTD event handler.
+ */
+ virtual void setDTDHandler (ACEXML_DTDHandler *handler) = 0;
+
+ /**
+ * Allow an application to register an entity resolver.
+ */
+ virtual void setEntityResolver (ACEXML_EntityResolver *resolver) = 0;
+
+ /**
+ * Allow an application to register an error event handler.
+ */
+ virtual void setErrorHandler (ACEXML_ErrorHandler *handler) = 0;
+
+ /**
+ * Activating or deactivating a feature.
+ */
+ virtual void setFeature (const ACEXML_Char *name,
+ int boolean_value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) = 0;
+
+ /**
+ * Set the value of a property.
+ */
+ virtual void setProperty (const ACEXML_Char *name,
+ void *value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_XMLREADER_H_ */
diff --git a/ACE/ACEXML/common/XML_Codecs.cpp b/ACE/ACEXML/common/XML_Codecs.cpp
new file mode 100644
index 00000000000..9566158ddfd
--- /dev/null
+++ b/ACE/ACEXML/common/XML_Codecs.cpp
@@ -0,0 +1,94 @@
+// -*- C++ -*- $Id$
+
+#include "ace/Auto_Ptr.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+#include "ACEXML/common/XML_Codecs.h"
+
+ACE_RCSID (common, XML_Codecs, "$Id$")
+
+ACEXML_Char*
+ACEXML_Base64::encode (const ACEXML_Char* input,
+ size_t* output_len)
+{
+ if (!input)
+ return 0;
+ size_t len = ACE_OS::strlen (input);
+
+ ACE_Byte* buf = 0;
+ ACE_NEW_RETURN (buf,
+ ACE_Byte[len],
+ 0);
+ ACE_Auto_Basic_Array_Ptr<ACE_Byte> cleanup_buf (buf);
+
+ for (size_t i = 0; i < len; ++i)
+ buf[i] = (ACE_Byte)input[i];
+ buf[len] = 0;
+
+ size_t encode_len = 0;
+ ACE_Byte* encodedBuf = ACE_Base64::encode (buf, len, &encode_len);
+
+ if (!encodedBuf)
+ return 0;
+
+ ACEXML_Char* result = 0;
+ ACE_NEW_RETURN (result,
+ ACEXML_Char[encode_len+1],
+ 0);
+
+ for (size_t j = 0; j < encode_len; ++j)
+ result[j] = (ACEXML_Char)encodedBuf[j];
+ result[encode_len] = 0;
+
+ *output_len = encode_len;
+ delete[] encodedBuf;
+ return result;
+}
+
+
+ACEXML_Char*
+ACEXML_Base64::decode (const ACEXML_Char* input,
+ size_t* output_len)
+{
+ if (!input)
+ return 0;
+
+ size_t len = ACE_OS::strlen (input);
+
+ ACE_Byte* buf = 0;
+
+ ACE_NEW_RETURN (buf,
+ ACE_Byte[len],
+ 0);
+
+ ACE_Auto_Basic_Array_Ptr<ACE_Byte> cleanup (buf);
+
+ for (size_t i = 0; i < len; ++i)
+ buf[i] = (ACE_Byte)input[i];
+
+ buf[len] = 0;
+
+ size_t decode_len = 0;
+
+ ACE_Byte* decodedBuf = ACE_Base64::decode (buf, &decode_len);
+
+ if (!decodedBuf)
+ return 0;
+
+ ACEXML_Char* result = 0;
+
+ ACE_NEW_RETURN (result,
+ ACEXML_Char[decode_len+1],
+ 0);
+
+ for (size_t j = 0; j < decode_len; ++j)
+ result[j] = (ACEXML_Char)decodedBuf[j];
+
+ result[decode_len] = 0;
+
+ *output_len = decode_len;
+ delete[] decodedBuf;
+
+ return result;
+}
+
diff --git a/ACE/ACEXML/common/XML_Codecs.h b/ACE/ACEXML/common/XML_Codecs.h
new file mode 100644
index 00000000000..10101d4e5b4
--- /dev/null
+++ b/ACE/ACEXML/common/XML_Codecs.h
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+
+/**
+ * @file XML_Codecs.h
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ *
+ * XML_Codecs is a generic wrapper for various encoding and decoding
+ * mechanisms used in ACEXML. Currently it includes support for handling
+ * Base64 content transfer-encoding of ACEXML_Chars.
+ *
+ */
+
+#ifndef _ACEXML_XML_CODECS_H
+#define _ACEXML_XML_CODECS_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+#include "ace/Codecs.h"
+
+/**
+ * @class ACEXML_Base64
+ *
+ * @brief Encode/Decode a stream of ACEXML_Chars according to Base64 encoding.
+ *
+ * This class provides methods to encode or decode a stream of ACEXML_Chars
+ * to/from Base64 encoding. It doesn't convert the input stream to a
+ * canonical form before encoding.
+ *
+ */
+class ACEXML_Export ACEXML_Base64 : public ACE_Base64
+{
+public:
+
+ //@{
+
+ /**
+ * Encodes a stream of octets to Base64 data
+ *
+ * @param input Binary data in ACEXML_Char stream.
+ * @param output_len Length of the encoded Base64 ACEXML_Char stream.
+ * @return Encoded Base64 data in ACEXML_Char stream or NULL if input data
+ * cannot be encoded.
+ */
+
+ static ACEXML_Char* encode (const ACEXML_Char* input,
+ size_t* output_len);
+ /**
+ * Decodes a stream of Base64 to octets data
+ *
+ * @param input Encoded Base64 data in ACEXML_Char stream.
+ * @param output_len Length of the binary ACEXML_Char stream.
+ * @return Binary data in ACEXML_Char stream or NULL if input data cannot
+ * be encoded.
+ */
+ static ACEXML_Char* decode (const ACEXML_Char* input,
+ size_t* output_len);
+
+ //@}
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_XML_CODECS_H */
diff --git a/ACE/ACEXML/common/XML_Macros.h b/ACE/ACEXML/common/XML_Macros.h
new file mode 100644
index 00000000000..50ec6857b3a
--- /dev/null
+++ b/ACE/ACEXML/common/XML_Macros.h
@@ -0,0 +1,443 @@
+// -*- C++ -*-
+
+// ============================================================================
+/**
+ * @file XML_Macros.h
+ *
+ * $Id$
+ *
+ * Writing code that is portable between platforms with or without
+ * native C++ exceptions is hard. The following macros offer some
+ * help on this task.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ * @author Aniruddha Gokhale <gokhale@sahyadri.research.bell-labs.com>
+ * @author Carlos O'Ryan <coryan@uci.edu>
+ * @author Krishnakumar B <kitty@cs.wustl.edu>, et al.
+ */
+// ============================================================================
+
+// Macros for handling exceptions.
+
+#ifndef _ACEXML_MACROS_H
+#define _ACEXML_MACROS_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/config-all.h"
+
+# if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+# endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Exception_Macros.h"
+
+// The following macros assume that an environment variable is passed
+// in/out of each function that can throw an exception. The type of the
+// environment variable is defined by ACEXML_ENV_TYPE.
+
+#if !defined (ACEXML_ENV_TYPE)
+# define ACEXML_ENV_TYPE ACEXML_Env
+#endif /* ACEXML_ENV_TYPE */
+
+// The name of the variable defined by ACEXML_TRY_ENV. Below is the name
+// that we use by default. If you wish to change it you can redefine
+// ACEXML_TRY_ENV to change the default name. Also ACEXML_ADOPT_ENV allows the
+// use of non-standard name within a scope.
+
+#if !defined (ACEXML_TRY_ENV)
+# define ACEXML_TRY_ENV _ACEXML_Env_variable
+#endif /* ACEXML_TRY_ENV */
+
+// The base type of Exception from which all the other exception types are
+// derived. By default, it is set to ACEXML_Exception.
+
+#if !defined (ACEXML_EXCEPTION_TYPE)
+# define ACEXML_EXCEPTION_TYPE ACEXML_Exception
+#endif /* ACEXML_EXCEPTION_TYPE */
+
+// This is the exception caught by ACEXML_CATCHANY.
+#if !defined (ACEXML_ANY_EXCEPTION)
+# define ACEXML_ANY_EXCEPTION ex
+#endif /* ACEXML_ANY_EXCEPTION */
+
+// Declare a new environment variable on the stack. The type of the
+// environment variable is determined by ACEXML_ENV_TYPE.
+#define ACEXML_DECLARE_NEW_ENV \
+ ACEXML_ENV_TYPE ACEXML_TRY_ENV
+
+#if defined (ACE_USES_NATIVE_EXCEPTIONS)
+// -----------------------------------------------------------------
+
+#define ACEXML_ADOPT_ENV (ENV)
+
+// No need to check. Native exceptions handle the control flow
+// automatically when an exception occurs.
+# define ACEXML_CHECK
+
+// Used when the function requires a return value.
+# define ACEXML_CHECK_RETURN(RETV)
+
+// ACEXML_THROW_R_INT should not be used by the user.
+# define ACEXML_THROW_R_INT(EXCEPTION) \
+ throw EXCEPTION
+
+// Throwing an exception is easy. These two macros should _NOT_ be
+// used within try blocks.
+# define ACEXML_THROW(EXCEPTION) \
+ throw EXCEPTION
+
+// Throwing an exception when the function reqires a return value.
+# if defined (__HP_aCC)
+# define ACEXML_THROW_RETURN(EXCEPTION, RETV) \
+ do \
+ { \
+ throw EXCEPTION; \
+ return RETV; \
+ } while (0)
+# else /* WIN32 */
+# define ACEXML_THROW_RETURN(EXCEPTION,RETV) \
+ throw EXCEPTION
+# endif /* WIN32 */
+
+// For compilers with native exceptions, we can simply use try to try. ;-)
+// do {} while (0) is required to avoid compilation warnings.
+# define ACEXML_TRY \
+ do \
+ { \
+ try \
+ {
+# define ACEXML_TRY_NEW_ENV \
+ do \
+ { \
+ ACEXML_ENV_TYPE ACEXML_TRY_ENV; \
+ try \
+ {
+# define ACEXML_TRY_EX(LABEL) \
+ do \
+ { \
+ try \
+ {
+
+// No need to check for exceptions within try block for compilers with
+// native exceptions.
+# define ACEXML_TRY_CHECK
+# define ACEXML_TRY_CHECK_EX(LABEL)
+
+// Likewise, throwing exceptions within try blocks is easy.
+# define ACEXML_TRY_THROW(EXCEPTION) throw EXCEPTION
+# define ACEXML_TRY_THROW_EX(EXCEPTION,LABEL) throw EXCEPTION
+
+// Same thing for catch.
+# define ACEXML_CATCH(EXCEPTION,VAR) \
+ } \
+ catch (EXCEPTION & VAR) \
+ { \
+ ACE_UNUSED_ARG (VAR);
+
+# define ACEXML_CATCHANY \
+ ACEXML_CATCH(ACEXML_EXCEPTION_TYPE, ACEXML_ANY_EXCEPTION)
+
+# define ACEXML_CATCHALL \
+ } \
+ catch (...) \
+ {
+
+// Rethrowing the exception from catch blocks.
+# define ACEXML_RE_THROW throw
+# define ACEXML_RE_THROW_EX(LABEL) throw
+
+// Close the catch block.
+# define ACEXML_ENDTRY \
+ } \
+ } while (0)
+
+#else /* ! ACEXML_USES_NATIVE_EXCEPTIONS */
+// -----------------------------------------------------------------
+
+// When handling compilers without native exceptions, things get a bit
+// hairy. Exceptions are simulated using ACEXML_ENV_TYPE. The trick here is to
+// make sure the flow-of-control can simulate the case when native
+// exceptions occur...
+
+# define ACEXML_ADOPT_ENV(ENV) ACEXML_ENV_TYPE &ACEXML_TRY_ENV = ENV
+
+// Follow every statement that could throw exceptions with ACEXML_CHECK or
+// ACEXML_CHECK_RETURN. These two macros should _NOT_ be used within try
+// blocks. Use ACEXML_TRY_CHECK or ACEXML_TRY_CHECK_EX instead.
+# define ACEXML_CHECK \
+ if (ACEXML_TRY_ENV . exception () != 0) \
+ return
+// When function requires a return value
+# define ACEXML_CHECK_RETURN(RETV) \
+ if (ACEXML_TRY_ENV . exception () != 0) \
+ return RETV
+
+// ACEXML_THROW_R_INT should not be used by the user.
+# define ACEXML_THROW_R_INT(EXCEPTION) ACEXML_TRY_ENV.exception (new EXCEPTION)
+
+// Throwing exceptions will inevitably cause a return from the current
+// function. These two macros should _NOT_ be used within try blocks. Use
+// ACEXML_TRY_THROW or ACEXML_TRY_THROW_EX instead.
+# define ACEXML_THROW(EXCEPTION) \
+ do \
+ { \
+ ACEXML_TRY_ENV.exception (new EXCEPTION); \
+ return; \
+ } while (0)
+
+# define ACEXML_THROW_RETURN(EXCEPTION,RETV) \
+ do \
+ { \
+ ACEXML_TRY_ENV.exception (new EXCEPTION); \
+ return RETV; \
+ } while (0)
+
+// ACEXML_TRY sets up flags to control program flow. ACEXML_TRY_FLAG acts
+// like a one-shot flip-flop. When an exception occurs (detected using
+// ACEXML_TRY_CHECK,) ACEXML_TRY_FLAG will be reset and the control goes
+// back into ACEXML_TRY_LABEL. Since ACEXML_TRY_FLAG is reset, the try
+// block won't get executed again and the control proceeds to the following
+// catch blocks. ACEXML_EXCEPTION_NOT_CAUGHT flag is used to prevent
+// catching an exception twice. This macro assumes there's already an
+// ACEXML_ENV_TYPE variable ACEXML_TRY_ENV defined (which should be the
+// case normally)
+# define ACEXML_TRY \
+ do { \
+ int ACEXML_TRY_FLAG = 1; \
+ int ACEXML_EXCEPTION_NOT_CAUGHT = 1; \
+ ACEXML_TRY_LABEL: \
+ if (ACEXML_TRY_FLAG) \
+ do {
+
+// ACEXML_TRY_NEW_ENV functions like the macro ACEXML_TRY but defines a new
+// ACEXML_ENV_TYPE variable ACEXML_TRY_ENV. It is most often used in the outer
+// most function where no ACEXML_TRY_ENV is available.
+# define ACEXML_TRY_NEW_ENV \
+ do { \
+ ACEXML_ENV_TYPE ACEXML_TRY_ENV;\
+ int ACEXML_TRY_FLAG = 1; \
+ int ACEXML_EXCEPTION_NOT_CAUGHT = 1; \
+ ACEXML_TRY_LABEL: \
+ if (ACEXML_TRY_FLAG) \
+ do {
+
+// ACEXML_TRY_EX works exactly like ACEXML_TRY macro except the label used
+// in the try block is customizable to avoid name clashing. It should be
+// used when nested try blocks or multiple try blocks are required, in the
+// same function.
+# define ACEXML_TRY_EX(LABEL) \
+ do { \
+ int ACEXML_TRY_FLAG = 1; \
+ int ACEXML_EXCEPTION_NOT_CAUGHT = 1; \
+ ACEXML_TRY_LABEL ## LABEL: \
+ if (ACEXML_TRY_FLAG) \
+ do {
+
+// Check for exceptions within try blocks.
+# define ACEXML_TRY_CHECK \
+ { \
+ if (ACEXML_TRY_ENV.exception () != 0) \
+ { \
+ ACEXML_TRY_FLAG = 0; \
+ goto ACEXML_TRY_LABEL; \
+ } \
+ }
+
+// Checking exception within EX try blocks.
+# define ACEXML_TRY_CHECK_EX(LABEL) \
+ { \
+ if (ACEXML_TRY_ENV.exception () != 0) \
+ { \
+ ACEXML_TRY_FLAG = 0; \
+ goto ACEXML_TRY_LABEL ## LABEL; \
+ } \
+ }
+
+// Throwing exception within TRY blocks.
+# define ACEXML_TRY_THROW(EXCEPTION) \
+ { \
+ ACEXML_TRY_ENV.exception (new EXCEPTION); \
+ ACEXML_TRY_FLAG = 0; \
+ goto ACEXML_TRY_LABEL; \
+ }
+
+# define ACEXML_TRY_THROW_EX(EXCEPTION,LABEL) \
+ { \
+ ACEXML_TRY_ENV.exception (new EXCEPTION); \
+ ACEXML_TRY_FLAG = 0; \
+ goto ACEXML_TRY_LABEL ## LABEL; \
+ }
+
+// When exceptions occur or try block finishes execution without exception,
+// control will continue in the catch block. This macro first checks if
+// there's any uncaught exception left. If all the conditions are met, we
+// have caught an exception. It then resets ACEXML_EXCEPTION_NOT_CAUGHT to
+// prevent subsequent catch blocks from catching the same exception again,
+// and extracts out the underlying exception in ACEXML_TRY_ENV. We also make a
+// copy of ACEXML_TRY_ENV in ACEXML_CAUGHT_ENV, in case we want to rethrow the
+// exception. ACEXML_TRY_ENV is cleared out after the exception is caught so
+// you should not use ACEXML_TRY_ENV within the catch block(You should use the
+// exception directly).
+# define ACEXML_CATCH(TYPE,VAR) \
+ } while (0); \
+ do \
+ if (ACEXML_TRY_ENV.exception () != 0 && ACEXML_EXCEPTION_NOT_CAUGHT && \
+ TYPE::_downcast(ACEXML_TRY_ENV.exception ()) != 0) \
+ { \
+ ACEXML_ENV_TYPE ACEXML_CAUGHT_ENV = ACEXML_TRY_ENV;\
+ ACEXML_EXCEPTION_NOT_CAUGHT = 0; \
+ TYPE &VAR = *TYPE::_downcast (ACEXML_CAUGHT_ENV.exception ()); \
+ ACE_UNUSED_ARG (VAR); \
+ ACEXML_TRY_ENV.clear ();
+
+// ACEXML_CATCHANY uses ACEXML_CATCH to catch all exceptions derived from
+// ACEXML_EXCEPTION_TYPE
+# define ACEXML_CATCHANY ACEXML_CATCH (ACEXML_EXCEPTION_TYPE, ACEXML_ANY_EXCEPTION)
+
+// Since there's no other exception for compilers without exception
+// support, we simply catch all ACEXML_EXCEPTION_TYPE exceptions for
+// ACEXML_CATCHALL.
+# define ACEXML_CATCHALL ACEXML_CATCHANY
+
+// Rethrowing exception within catch blocks. Notice that we depend on the
+// ACEXML_CHECK/ACEXML_CHECK_RETURN following the ACEXML_ENDTRY, or
+// ACEXML_TRY_CHECK/ ACEXML_TRY_CHECK_EX following the ACEXML_ENDTRY when
+// the catch block is within another try block, to do the "Right
+// Thing[TM]."
+# define ACEXML_RE_THROW \
+ do {\
+ ACEXML_TRY_ENV = ACEXML_CAUGHT_ENV; \
+ goto ACEXML_TRY_LABEL; \
+ } while (0)
+# define ACEXML_RE_THROW_EX(LABEL) \
+ do {\
+ ACEXML_TRY_ENV = ACEXML_CAUGHT_ENV; \
+ goto ACEXML_TRY_LABEL ## LABEL; \
+ } while (0)
+
+// Close the try block. Since exceptions may not get caught, and exceptions
+// can also be rethrown from the catch block, it's always a good idea to
+// follow ACEXML_ENDTRY with ACEXML_CHECK or ACEXML_TRY_CHECK (depending on
+// the context.)
+# define ACEXML_ENDTRY \
+ } while (0); \
+ } while (0)
+
+#endif /* ! ACE_USES_NATIVE_EXCEPTIONS */
+
+// ACE_HAS_EXCEPTIONS is not the same as ACE_NEW_THROWS_EXCEPTIONS.
+#if defined(ACE_NEW_THROWS_EXCEPTIONS)
+
+# define ACEXML_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \
+ do { try { POINTER = new CONSTRUCTOR; } \
+ catch (ACE_bad_alloc) { errno = ENOMEM; ACEXML_THROW_R_INT (EXCEPTION); } \
+ } while (0)
+
+#else /* ! ACE_NEW_THROWS_EXCEPTIONS */
+
+# define ACEXML_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \
+ do { POINTER = new CONSTRUCTOR; \
+ if (POINTER == 0) { errno = ENOMEM; ACEXML_THROW_R_INT (EXCEPTION); } \
+ } while (0)
+
+#endif /* ACE_NEW_THROWS_EXCEPTIONS */
+
+# define ACEXML_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \
+ ACE_Guard< MUTEX > OBJ (LOCK); \
+ if (OBJ.locked () == 0) ACEXML_THROW_R_INT (EXCEPTION);
+
+# define ACEXML_READ_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \
+ ACE_Read_Guard< MUTEX > OBJ (LOCK); \
+ if (OBJ.locked () == 0) ACEXML_THROW_R_INT (EXCEPTION);
+
+# define ACEXML_WRITE_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \
+ ACE_Write_Guard< MUTEX > OBJ (LOCK); \
+ if (OBJ.locked () == 0) ACEXML_THROW_R_INT (EXCEPTION);
+
+//@{
+/**
+ * @name Native C++ exceptions portability macros.
+ *
+ * The following macros are used to write code portable between platforms
+ * with and without native C++ exception support. Their main goal is to
+ * hide the presence of the ACEXML_ENV_TYPE argument, but they collaborate
+ * with the ACEXML_TRY_* macros to emulate the try/catch blocks.
+ */
+
+/// Define a macro to emit code only when ACEXML_ENV_TYPE is used
+#if !defined (ACE_USES_NATIVE_EXCEPTIONS) || defined (ACEXML_ENV_BKWD_COMPAT)
+# define ACEXML_ENV_EMIT_CODE(X) X
+#else
+# define ACEXML_ENV_EMIT_CODE(X)
+#endif /* ACE_USES_NATIVE_EXCEPTIONS && ! ACEXML_ENV_BKWD_COMPAT */
+
+/// Another macro to emit code only when ACEXML_ENV_TYPE is used
+#if !defined (ACE_USES_NATIVE_EXCEPTIONS) || defined (ACEXML_ENV_BKWD_COMPAT)
+# define ACEXML_ENV_EMIT_CODE2(X,Y) X,Y
+#else
+# define ACEXML_ENV_EMIT_CODE2(X,Y)
+#endif /* ACE_USES_NATIVE_EXCEPTIONS && ! ACEXML_ENV_BKWD_COMPAT */
+
+/// Helper macro
+#define ACEXML_ENV_EMIT_DUMMY
+
+/// Declare a ACEXML_ENV_TYPE argument as the last argument of a
+/// function
+/**
+ * Normally this macro is used as follows:
+ *
+ * <CODE>void my_funct (int x, int y ACEXML_ENV_ARG_DECL);</CODE>
+ *
+ * Its purpose is to provide developers (and users) with a mechanism to
+ * write code that is portable to platforms with and without native C++
+ * exceptions.
+ */
+#define ACEXML_ENV_ARG_DECL \
+ ACEXML_ENV_EMIT_CODE2(ACEXML_ENV_EMIT_DUMMY, \
+ ACEXML_ENV_TYPE &ACEXML_TRY_ENV)
+
+/// Declare a ACEXML_ENV_TYPE argument that is not used by the
+/// function definition.
+/**
+ * Similar to ACEXML_ENV_ARG_DECL, but the formal parameter name is dropped to
+ * avoid warnings about unused parameters
+ */
+#define ACEXML_ENV_ARG_DECL_NOT_USED \
+ ACEXML_ENV_EMIT_CODE2(ACEXML_ENV_EMIT_DUMMY, \
+ ACEXML_ENV_TYPE &)
+
+/// Declare a ACEXML_ENV_TYPE argument for methods that do not take any other
+/// parameters
+#define ACEXML_ENV_SINGLE_ARG_DECL \
+ ACEXML_ENV_EMIT_CODE(ACEXML_ENV_TYPE &ACEXML_TRY_ENV)
+
+/// Declare a ACEXML_ENV_TYPE argument for methods which don't use it.
+#define ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED \
+ ACEXML_ENV_EMIT_CODE(ACEXML_ENV_TYPE &)
+
+/// Use the ACEXML_ENV_TYPE argument in a nested call
+#define ACEXML_ENV_ARG_PARAMETER \
+ ACEXML_ENV_EMIT_CODE2(ACEXML_ENV_EMIT_DUMMY, \
+ ACEXML_TRY_ENV)
+
+/// Use the ACEXML_ENV_TYPE argument in a nested call, assuming that the
+/// called function takes only the ACEXML_TRY_ENV argument.
+#define ACEXML_ENV_SINGLE_ARG_PARAMETER \
+ ACEXML_ENV_EMIT_CODE(ACEXML_TRY_ENV)
+
+/// Eliminate unused argument warnings about ACEXML_TRY_ENV
+#define ACEXML_ENV_ARG_NOT_USED \
+ ACEXML_ENV_EMIT_CODE(ACE_UNUSED_ARG(ACEXML_TRY_ENV))
+//@}
+
+#if !defined (ACE_USES_NATIVE_EXCEPTIONS)
+// This thing can be moved above when we drop ACEXML_ENV_BKWD_COMPAT.
+# define ACEXML_ENV_RAISE(ex) ACEXML_TRY_ENV.exception (ex)
+#else
+# define ACEXML_ENV_RAISE(ex) (ex)->_raise ()
+#endif /* ACEXML_CORBA_HAS_EXCEPTIONS */
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_MACROS_H */
diff --git a/ACE/ACEXML/common/XML_Types.h b/ACE/ACEXML/common/XML_Types.h
new file mode 100644
index 00000000000..5a55d6b7754
--- /dev/null
+++ b/ACE/ACEXML/common/XML_Types.h
@@ -0,0 +1,83 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file XML_Types.h
+ *
+ * This file collects the type definitions for data types
+ * used in ACE XML parser.
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_XML_TYPES_H_
+#define _ACEXML_XML_TYPES_H_
+
+#include /**/ "ace/pre.h"
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Basic_Types.h"
+#include "ace/SString.h"
+#include "ace/Functor_String.h"
+
+# if defined (ACE_HAS_WCHAR) && (ACE_SIZEOF_WCHAR == 2)
+typedef wchar_t ACEXML_UTF16;
+# else
+typedef ACE_USHORT16 ACEXML_UTF16;
+# endif /* ACE_HAS_WCHAR && ACE_SIZEOF_WCHAR == 2 */
+
+# if defined (ACE_HAS_WCHAR) && (ACE_SIZEOF_WCHAR == 4)
+typedef wchar_t ACEXML_UCS4;
+# else
+typedef ACE_UINT32 ACEXML_UCS4;
+# endif /* ACE_HAS_WCHAR && ACE_SIZEOF_WCHAR == 4 */
+
+typedef char ACEXML_UTF8;
+
+/**
+ * @typedef ACEXML_Char
+ * ACEXML_Char only maps to ACEXML_UTF16 when ACE_USES_WCHAR is defined.
+ * Here we assume sizeof (wchar_t) is always 2 bytes.
+ *
+ * Default XML strings will use UTF-8 encoding. We would like to use
+ * the string classes in standard C++ Library here. But they are not
+ * very portable yet (as far as I know,) and I'll just use ACE_CString
+ * for now, unless UNICODE support is turned on. Notice that you
+ * should never convert strings between ACE_CString and ACE_WString
+ * using the built-in conversion functions as they only perform simple
+ * copy without any encoding conversion.
+ */
+typedef ACE_TCHAR ACEXML_Char;
+# if defined (ACE_USES_WCHAR)
+//typedef ACEXML_UTF16 ACEXML_Char;
+typedef ACE_WString ACEXML_String;
+# else
+//typedef ACEXML_UTF8 ACEXML_Char;
+typedef ACE_CString ACEXML_String;
+# endif /* ACE_USES_WCHAR */
+
+# if (!defined (ACEXML_HAS_INLINE) && defined (__ACE_INLINE__)) || (ACEXML_HAS_INLINE == 1)
+# define __ACEXML_INLINE__ inline
+# else
+# if defined (__ACEXML_INLINE__)
+# undef __ACEXML_INLINE__
+# endif /* __ACEXML_INLINE__ */
+# endif /* (!ACEXML_HAS_INLINE) && (__ACE_INLINE__) || (ACEXML_HAS_INLINE == 1) */
+
+# if defined (__ACEXML_INLINE__)
+# define ACEXML_INLINE inline
+# else
+# define ACEXML_INLINE
+# endif /* __ACEXML_INLINE */
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_XML_TYPE_H_ */
diff --git a/ACE/ACEXML/common/XML_Util.cpp b/ACE/ACEXML/common/XML_Util.cpp
new file mode 100644
index 00000000000..7b9b9fb00fe
--- /dev/null
+++ b/ACE/ACEXML/common/XML_Util.cpp
@@ -0,0 +1,46 @@
+// $Id$
+
+#include "ACEXML/common/XML_Util.h"
+
+static const ACEXML_Char ESCAPED_AMP[] = ACE_TEXT("&amp;");
+static const ACEXML_Char ESCAPED_LESS[] = ACE_TEXT("&lt;");
+static const ACEXML_Char ESCAPED_GREATER[] = ACE_TEXT("&gt;");
+static const ACEXML_Char ESCAPED_APOS[] = ACE_TEXT("&apos;");
+static const ACEXML_Char ESCAPED_QUOTE[] = ACE_TEXT("&quot;");
+
+#define CSTRLEN(x) ((sizeof(x) / sizeof(ACEXML_Char)) - 1)
+
+ACEXML_String ACEXML_escape_string(const ACEXML_String& str)
+{
+ ACEXML_String ret(str.length ());
+ ACEXML_escape_string(str, ret);
+ return ret;
+}
+
+void ACEXML_escape_string(const ACEXML_String& in, ACEXML_String& out)
+{
+ size_t len = in.length ();
+ out.clear();
+ for (size_t stridx = 0; stridx < len; ++stridx)
+ {
+ switch (in[stridx]) {
+ case '&':
+ out.append(ESCAPED_AMP, CSTRLEN(ESCAPED_AMP));
+ break;
+ case '<':
+ out.append(ESCAPED_LESS, CSTRLEN(ESCAPED_LESS));
+ break;
+ case '>':
+ out.append(ESCAPED_GREATER, CSTRLEN(ESCAPED_GREATER));
+ break;
+ case '\'':
+ out.append(ESCAPED_APOS, CSTRLEN(ESCAPED_APOS));
+ break;
+ case '\"':
+ out.append(ESCAPED_QUOTE, CSTRLEN(ESCAPED_QUOTE));
+ break;
+ default:
+ out += in[stridx];
+ }
+ }
+}
diff --git a/ACE/ACEXML/common/XML_Util.h b/ACE/ACEXML/common/XML_Util.h
new file mode 100644
index 00000000000..2844c33f397
--- /dev/null
+++ b/ACE/ACEXML/common/XML_Util.h
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file XML_Util.h
+ *
+ * Initially contains a function to escape strings for use in XML files.
+ *
+ * $Id$
+ *
+ * @author Justin Michel <michel_j@ociweb.com>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_XML_UTIL_H_
+#define _ACEXML_XML_UTIL_H_
+
+#include /**/ "ace/pre.h"
+
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+
+ACEXML_Export ACEXML_String ACEXML_escape_string(const ACEXML_String& str);
+ACEXML_Export void ACEXML_escape_string(const ACEXML_String& in, ACEXML_String& out);
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_XML_UTIL_H_ */
diff --git a/ACE/ACEXML/common/ZipCharStream.cpp b/ACE/ACEXML/common/ZipCharStream.cpp
new file mode 100644
index 00000000000..bea182781ad
--- /dev/null
+++ b/ACE/ACEXML/common/ZipCharStream.cpp
@@ -0,0 +1,255 @@
+// $Id$
+
+#ifdef USE_ZZIP
+
+#include "ACEXML/common/ZipCharStream.h"
+#include "ace/ACE.h"
+
+
+ACEXML_ZipCharStream::ACEXML_ZipCharStream (void)
+ : filename_ (0), encoding_ (0), size_ (0), infile_ (0), pos_ (0),
+ limit_ (0)
+{
+}
+
+ACEXML_ZipCharStream::~ACEXML_ZipCharStream (void)
+{
+ this->close();
+}
+
+int
+ACEXML_ZipCharStream::open (const ACEXML_Char *name)
+{
+ delete[] this->filename_;
+ this->filename_ = 0;
+
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+
+ this->infile_ = zzip_fopen (name, ACE_TEXT ("r"));
+ if (this->infile_ == 0)
+ return -1;
+
+ this->filename_ = ACE::strnew (ACE::basename (name));
+ return this->determine_encoding();
+}
+
+int
+ACEXML_ZipCharStream::determine_encoding (void)
+{
+ if (this->infile_ == 0)
+ return -1;
+ char input[4];
+ int i = 0;
+ for (; i < 4 && (input[i] = this->peekchar_i(i)) > 0; ++i)
+ ;
+ if (i < 4)
+ return -1;
+ const ACEXML_Char* temp = ACEXML_Encoding::get_encoding (input);
+ if (!temp)
+ return -1;
+ else
+ {
+ if (this->encoding_)
+ delete [] this->encoding_;
+ this->encoding_ = ACE::strnew (temp);
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("File's encoding is %s\n"),
+// this->encoding_));
+ }
+ // Move over the byte-order-mark if present.
+ char ch;
+ for (int j = 0; j < 3; ++j)
+ {
+ if ((ch = this->peekchar_i()) < 0)
+ return -1;
+ if (ch == '\xFF' || ch == '\xFE' || ch == '\xEF' || ch == '\xBB' ||
+ ch == '\xBF')
+ this->get(ch);
+ else
+ break;
+ }
+ return 0;
+}
+
+void
+ACEXML_ZipCharStream::rewind()
+{
+ if (this->infile_ == 0)
+ return;
+ zzip_rewind (this->infile_);
+ this->determine_encoding();
+}
+
+int
+ACEXML_ZipCharStream::available (void)
+{
+ if (this->infile_ == 0)
+ return -1;
+ long curr;
+ if ((curr = zzip_tell (this->infile_)) < 0)
+ return -1;
+ return (this->size_ - curr);
+}
+
+int
+ACEXML_ZipCharStream::close (void)
+{
+ if (this->infile_ != 0)
+ {
+ zzip_close (this->infile_);
+ this->infile_ = 0;
+ }
+ delete[] this->filename_;
+ this->filename_ = 0;
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+ this->size_ = 0;
+ this->pos_ = 0;
+ this->limit_ = 0;
+ return 0;
+}
+
+
+int
+ACEXML_ZipCharStream::getchar_i (char& ch)
+{
+ if (this->infile_ == 0)
+ return -1;
+
+ if (this->pos_ < this->limit_)
+ {
+ ch = this->buf_[this->pos_++];
+ return 0;
+ }
+ this->limit_ = zzip_read (this->infile_, this->buf_, sizeof (this->buf_));
+ if (this->limit_ == 0)
+ return -1;
+ this->pos_ = 0;
+ ch = this->buf_[this->pos_++];
+ return 0;
+}
+
+int
+ACEXML_ZipCharStream::peekchar_i (off_t offset)
+{
+ if (this->infile_ == 0)
+ return -1;
+
+ if (offset > (off_t) sizeof (this->buf_))
+ return -1;
+ if (this->pos_ + offset < this->limit_)
+ return this->buf_[this->pos_ + offset];
+ int i = 0;
+ for (; this->pos_ < this->limit_; ++this->pos_, ++i)
+ this->buf_[i] = this->buf_[this->pos_];
+ this->limit_ = zzip_read (this->infile_, this->buf_ + i,
+ sizeof (this->buf_) - i);
+ this->limit_ += i;
+ if (this->limit_ == 0)
+ return -1;
+ this->pos_ = 0;
+ return this->buf_[this->pos_ + offset];
+}
+
+int
+ACEXML_ZipCharStream::read (ACEXML_Char *str, size_t len)
+{
+ if (this->infile_ == 0)
+ return -1;
+
+ size_t i = 0;
+ for (; i < len && this->pos_ < this->limit_; ++i)
+ str[i] = this->buf_[this->pos_++];
+ if (i == len)
+ return len;
+ len = len - i;
+ this->pos_ = 0;
+ this->limit_ = 0;
+ int bytes = zzip_fread (str + i, sizeof (ACEXML_Char), len, this->infile_);
+ return (bytes + i);
+}
+
+int
+ACEXML_ZipCharStream::get (ACEXML_Char& ch)
+{
+#if defined (ACE_USES_WCHAR)
+ return this->get_i (ch);
+#else
+ return this->getchar_i (ch);
+#endif /* ACE_USES_WCHAR */
+}
+
+
+int
+ACEXML_ZipCharStream::peek (void)
+{
+#if defined (ACE_USES_WCHAR)
+ return this->peek_i();
+#else
+ return this->peekchar_i();
+#endif /* ACE_USES_WCHAR */
+}
+
+const ACEXML_Char*
+ACEXML_ZipCharStream::getEncoding (void)
+{
+ return this->encoding_;
+}
+
+const ACEXML_Char*
+ACEXML_ZipCharStream::getSystemId (void)
+{
+ return this->filename_;
+}
+
+#if defined (ACE_USES_WCHAR)
+int
+ACEXML_ZipCharStream::get_i (ACEXML_Char& ch)
+{
+ if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0)
+ return this->getchar_i (ch);
+
+ int BE = (ACE_OS::strcmp (this->encoding_,
+ ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0;
+ ACEXML_Char input[2];
+ int i = 0;
+ for (; i < 2 && (this->getchar_i (input[i]) == 0); ++i)
+ ;
+ if (i < 2)
+ {
+ ch = 0;
+ return -1;
+ }
+ ch = BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0];
+ return 0;
+}
+
+int
+ACEXML_ZipCharStream::peek_i (void)
+{
+
+ // If we are reading a UTF-8 encoded file, just use the plain unget.
+ if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0)
+ return this->peekchar_i();
+
+ // Peek into the stream. This reads two characters off the stream, keeps
+ // it in peek_.
+ int BE = (ACE_OS::strcmp (this->encoding_,
+ ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0;
+
+ ACEXML_Char input[2];
+ int i = 0;
+ for (; i < 2 && (input[i] = this->peekchar_i (i)) > 0; ++i)
+ ;
+ if (i < 2)
+ return -1;
+ return (BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0]);
+}
+#endif /* ACE_USES_WCHAR */
+
+#else
+#if defined (__HP_aCC)
+static int shut_up_aCC = 0;
+#endif /* __HP_aCC */
+
+#endif /* USE_ZZIP */
diff --git a/ACE/ACEXML/common/ZipCharStream.h b/ACE/ACEXML/common/ZipCharStream.h
new file mode 100644
index 00000000000..2c3ee5fb775
--- /dev/null
+++ b/ACE/ACEXML/common/ZipCharStream.h
@@ -0,0 +1,144 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ZipCharStream.h
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_ZIPCHARSTREAM_H_
+#define _ACEXML_ZIPCHARSTREAM_H_
+
+#ifdef USE_ZZIP
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/CharStream.h"
+#include "ACEXML/common/Encoding.h"
+#include "zzip/zzip.h"
+
+// Ugly wart to get aroung a macro version of read defined in zzip.h. Evil...
+#ifdef read
+#undef read
+#endif
+
+/**
+ * @class ACEXML_ZipCharStream
+ *
+ * An implementation of ACEXML_CharStream for reading input from a ZIP archive.
+ */
+class ACEXML_Export ACEXML_ZipCharStream : public ACEXML_CharStream
+{
+public:
+ /// Default constructor.
+ ACEXML_ZipCharStream (void);
+
+ /// Destructor
+ virtual ~ACEXML_ZipCharStream (void);
+
+ /// Open a file.
+ int open (const ACEXML_Char *name);
+
+ /**
+ * Returns the available ACEXML_Char in the buffer. -1
+ * if the object is not initialized properly.
+ */
+ virtual int available (void);
+
+ /**
+ * Close this stream and release all resources used by it.
+ */
+ virtual int close (void);
+
+ /**
+ * Read the next ACEXML_Char. Return -1 if we are not able to
+ * return an ACEXML_Char, 0 if EOF is reached, or 1 if succeed.
+ */
+ virtual int get (ACEXML_Char& ch);
+
+ /**
+ * Read the next batch of ACEXML_Char strings
+ */
+ virtual int read (ACEXML_Char *str, size_t len);
+
+ /**
+ * Determine the encoding of the file.
+ */
+ virtual int determine_encoding (void);
+
+
+ /**
+ * Peek the next ACEXML_Char in the CharStream. Return the
+ * character if success, -1 if EOF is reached.
+ */
+ virtual int peek (void);
+
+ /**
+ * Resets the file pointer to the beginning of the stream.
+ */
+ virtual void rewind (void);
+
+ /*
+ * Get the character encoding for a byte stream or URI.
+ */
+ virtual const ACEXML_Char *getEncoding (void);
+
+ /*
+ * Get the systemId for the underlying CharStream
+ */
+ virtual const ACEXML_Char* getSystemId (void);
+
+protected:
+
+ /** Read the next character as a normal character. Return -1 if EOF is
+ * reached, else return 0.
+ */
+ virtual int getchar_i (char& ch);
+
+ /**
+ * Peek @c offset bytes into the stream and return the character at @c
+ * offset. If EOF is reached, return -1.
+ */
+ virtual int peekchar_i (off_t offset = 0);
+
+private:
+
+#if defined (ACE_USES_WCHAR)
+ /**
+ * Read the next character from the stream taking into account the
+ * encoding of the file.
+ */
+ int get_i (ACEXML_Char& ch);
+
+ /**
+ * Return the next character from the stream taking into account the
+ * encoding of the file. Subsequent call to get() returns this
+ * character.
+ */
+ int peek_i (void);
+
+#endif /* ACE_USES_WCHAR */
+
+ ACEXML_Char* filename_;
+ ACEXML_Char* encoding_;
+ off_t size_;
+ ZZIP_FILE* infile_;
+ char buf_[80];
+ int pos_;
+ int limit_;
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* USE_ZZIP */
+
+#endif /* _ACEXML_ZIPCHARSTREAM_H_ */
diff --git a/ACE/ACEXML/common/codecs.mpb b/ACE/ACEXML/common/codecs.mpb
new file mode 100644
index 00000000000..134e0815539
--- /dev/null
+++ b/ACE/ACEXML/common/codecs.mpb
@@ -0,0 +1,8 @@
+// -*- MPC -*-
+// $Id$
+
+feature(ace_codecs) {
+ Source_Files {
+ XML_Codecs.cpp
+ }
+}
diff --git a/ACE/ACEXML/common/common.mpc b/ACE/ACEXML/common/common.mpc
new file mode 100644
index 00000000000..bd496a82123
--- /dev/null
+++ b/ACE/ACEXML/common/common.mpc
@@ -0,0 +1,33 @@
+// -*- MPC -*-
+// $Id$
+
+project(ACEXML): acelib, codecs, core {
+ avoids += ace_for_tao
+ sharedname = ACEXML
+ dynamicflags += ACEXML_BUILD_DLL
+
+ Source_Files {
+ // This file will only be added if the ace_codecs feature is enabled.
+ // See codecs.mpb for more information.
+ !XML_Codecs.cpp
+ }
+
+ Header_Files {
+ ACEXML_Export.h
+ Attributes.h
+ ContentHandler.h
+ DTDHandler.h
+ EntityResolver.h
+ ErrorHandler.h
+ Locator.h
+ XMLFilter.h
+ XMLReader.h
+ XML_Macros.h
+ XML_Types.h
+ XML_Util.h
+ }
+
+ Pkgconfig_Files {
+ ACEXML.pc.in
+ }
+}
diff --git a/ACE/ACEXML/docs/TODO.txt b/ACE/ACEXML/docs/TODO.txt
new file mode 100644
index 00000000000..e7e48ca67c4
--- /dev/null
+++ b/ACE/ACEXML/docs/TODO.txt
@@ -0,0 +1,17 @@
+/**
+@page acexml_todo ACEXML TO-DO List
+
+<ul>
+
+ <li>Add Schema parsing ability.
+
+ <li>Add support for resolving external entities, such as a
+ schema/namespace definition located on the web.
+
+ <li>Add parameterized entity management class. See above.
+
+ <li>Define validator building/calling interfaces.
+
+</ul>
+
+*/
diff --git a/ACE/ACEXML/docs/bugs.txt b/ACE/ACEXML/docs/bugs.txt
new file mode 100644
index 00000000000..136e0cd7117
--- /dev/null
+++ b/ACE/ACEXML/docs/bugs.txt
@@ -0,0 +1,17 @@
+/**
+@page acexml_bugs ACEXML Known Bugs
+
+<ul>
+ <li>ACEXML currently do not validate an XML files. The validator
+ hooks have not fully integrated into the parser yet.
+
+ <li>Need to verify predefined entities are working correctly. Check
+ out the SAXPrint example.
+
+ <li>Currently, replacement of parameterized reference (PEReference) is
+ not working.
+
+</ul>
+
+
+*/
diff --git a/ACE/ACEXML/docs/guidelines.txt b/ACE/ACEXML/docs/guidelines.txt
new file mode 100644
index 00000000000..9d084924c2c
--- /dev/null
+++ b/ACE/ACEXML/docs/guidelines.txt
@@ -0,0 +1,39 @@
+// -*- HTML-Helper -*- $Id$
+
+/**
+@page acexml_guides ACEXML Programming Guidelines
+
+<ul>
+ <li>A lot of class names under @c $(ACE_ROOT)/ACEXML/common do not
+ follow the naming convention suggested in ACE-guidelines.html.
+ The reason for that is because those classes were derived from
+ the SAX2 API and we would like to keep them as similar as
+ possible.
+ <li>Character encoding: The default character encoding for ACEXML
+ can be set at compile time. ACEXML uses UTF-8 encoding in most
+ platforms where <code>ACEXML_Char</code> maps to
+ <code>char</code> in this case. When ACE is configured to use
+ <CODE>wchar</CODE> and <CODE>UNICODE</CODE>, ACEXML uses UTF-16
+ encoding and <code>ACEXML_Char</code> maps to
+ <code>wchar_t</code>. Notice that ACEXML assume
+ <code>sizeof (wchar_t)</code> is of 2-byte long. For platforms
+ using 4-byte <code>wchar_t</code>, ACEXML will not work
+ correctly, but it should be trivial to fix.<p>
+
+ <li>Currently, there's only an example showing how to use the parser
+ under @c $(ACE_ROOT)/ACEXML/examples/SAXPrint/.
+
+ <li><b>(Not supported yet)</b> To develop a new validator, one must
+ create a DLL implementing
+ @c ACEXML_Attributes_Def_Builder, @c
+ ACEXML_Attribute_Def_Builder, @c ACEXML_Element_Def_Builder,
+ @c ACEXML_Validator, and @c ACEXML_DTD_Manager. The DLL should
+ also export a traditional C function called @c
+ create_dtd_manager. The XML parser itself should also be
+ modified to support and dynamically link with the new validator.
+ See @c $(ACE_ROOT)/ACEXML/parser/debug_validator/ for an example.
+
+</ul>
+
+
+*/
diff --git a/ACE/ACEXML/docs/parser_features.txt b/ACE/ACEXML/docs/parser_features.txt
new file mode 100644
index 00000000000..c65930e32a2
--- /dev/null
+++ b/ACE/ACEXML/docs/parser_features.txt
@@ -0,0 +1,25 @@
+/** -*- HTML-Helper -*- $Id$
+@defgroup acexml_parser_features Configurable Special Features of ACEXML Parser
+@{
+
+There are special features in ACEXML Parser that can be
+activated/deactivated thru @c setFeature. Likewise, whether a feature
+has been activated or not can be queried using @c getFeature.
+
+@sa ACEXML_XMLReader::setFeature
+@sa ACEXML_XMLReader::getFeature
+
+Here is a list of supported features:
+
+<OL>
+ <li> namespaces - When this feature is enabled, ACEXML parser allows
+ access by namespace qualified names.
+
+ <li> namespace_prefixes - Normally the list of attributes returned by the
+ parser will not contain attributes used as namespace declarations
+ (xmlns:foo="bar"). When this feature is enabled, the list of attributes
+ contains the namespace declarations also.
+</OL>
+
+@}
+*/
diff --git a/ACE/ACEXML/docs/readme.txt b/ACE/ACEXML/docs/readme.txt
new file mode 100644
index 00000000000..f0de833b526
--- /dev/null
+++ b/ACE/ACEXML/docs/readme.txt
@@ -0,0 +1,36 @@
+/** -*- HTML-Helper -*- $Id$
+@mainpage ACEXML - A Small and Portable XML Parser
+
+@section acexml_synopsis Synopsis
+ACEXML is a small footprint and portable framework for integrating XML
+parsing ability into user applications. The framework is based on the
+ <a href="http://www.saxproject.org/"> Simple API for XML
+(SAX 2.0) </A> by David Megginson. A simple non-conformant XML parser
+is also included in the framework. Since our original motivation was
+to use the parser for specifying software composition and
+configuration descriptors, at the current stage, the parser does not
+fully support all the features specified in the XML specification.
+
+We do, however, plan to add more features to the parser and will
+either release a more versatile parser or allow the current parser to
+dynamically load in the extra features in the future.
+
+@section acexml_features Features of ACEXML
+<ul>
+ <li> ACEXML only recognize UNICODE documents, although they can be
+ in various different encoding, such as UTF-8, UTF-16, or UCS-4.
+ Therefore, it might be a problem to handle document containing
+ multi-byte charatersets. They can, however, be translated into
+ UNICODE before being parsed by ACEXML parser.
+</ul>
+
+
+@section acexml_others Other Topics
+<ol>
+ <li>@ref acexml_parser_features
+ <li>@ref acexml_guides
+ <li>@ref acexml_bugs
+ <li>@ref acexml_todo
+</ol>
+
+*/
diff --git a/ACE/ACEXML/examples/Makefile.am b/ACE/ACEXML/examples/Makefile.am
new file mode 100644
index 00000000000..8a2494ea586
--- /dev/null
+++ b/ACE/ACEXML/examples/Makefile.am
@@ -0,0 +1,13 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+SUBDIRS = \
+ SAXPrint
+
diff --git a/ACE/ACEXML/examples/SAXPrint/Makefile.am b/ACE/ACEXML/examples/SAXPrint/Makefile.am
new file mode 100644
index 00000000000..075d3b6fca8
--- /dev/null
+++ b/ACE/ACEXML/examples/SAXPrint/Makefile.am
@@ -0,0 +1,48 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+ACE_BUILDDIR = $(top_builddir)
+ACE_ROOT = $(top_srcdir)
+
+
+## Makefile.SAXPrint.am
+
+if BUILD_ACEXML
+if !BUILD_ACE_FOR_TAO
+noinst_PROGRAMS = SAXPrint
+
+SAXPrint_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(ACE_ROOT)/ACEXML/common
+
+SAXPrint_SOURCES = \
+ Print_Handler.cpp \
+ SAXPrint_Handler.cpp \
+ main.cpp \
+ Print_Handler.h \
+ SAXPrint_Handler.h \
+ SAXPrint_Handler.i
+
+SAXPrint_LDADD = \
+ $(ACE_BUILDDIR)/ACEXML/parser/parser/libACEXML_Parser.la \
+ $(ACE_BUILDDIR)/ACEXML/common/libACEXML.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif !BUILD_ACE_FOR_TAO
+endif BUILD_ACEXML
+
+## Clean up template repositories, etc.
+clean-local:
+ -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.*
+ -rm -f gcctemp.c gcctemp so_locations *.ics
+ -rm -rf cxx_repository ptrepository ti_files
+ -rm -rf templateregistry ir.out
+ -rm -rf ptrepository SunWS_cache Templates.DB
diff --git a/ACE/ACEXML/examples/SAXPrint/Print_Handler.cpp b/ACE/ACEXML/examples/SAXPrint/Print_Handler.cpp
new file mode 100644
index 00000000000..34434cafc7a
--- /dev/null
+++ b/ACE/ACEXML/examples/SAXPrint/Print_Handler.cpp
@@ -0,0 +1,254 @@
+// -*- C++ -*- $Id$
+
+#include "Print_Handler.h"
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+
+ACEXML_Print_Handler::ACEXML_Print_Handler (ACEXML_Char* fileName)
+ : fileName_(ACE::strnew (fileName))
+{
+
+}
+
+ACEXML_Print_Handler::~ACEXML_Print_Handler (void)
+{
+ delete[] this->fileName_;
+}
+
+void
+ACEXML_Print_Handler::characters (const ACEXML_Char *cdata,
+ int start,
+ 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, length, cdata));
+}
+
+void
+ACEXML_Print_Handler::endDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("* Event endDocument () ***************\n")));
+}
+
+void
+ACEXML_Print_Handler::endElement (const ACEXML_Char *uri,
+ const ACEXML_Char *name,
+ const ACEXML_Char *qName
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("* Event endElement (%s, %s, %s) ***************\n"),
+ uri, name, qName));
+}
+
+void
+ACEXML_Print_Handler::endPrefixMapping (const ACEXML_Char *prefix
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("* Event endPrefixMapping (%s) ***************\n"),
+ prefix));
+}
+
+void
+ACEXML_Print_Handler::ignorableWhitespace (const ACEXML_Char *,
+ int,
+ int
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // ACE_DEBUG ((LM_DEBUG,
+ // ACE_TEXT ("* Event ignorableWhitespace () ***************\n")));
+}
+
+void
+ACEXML_Print_Handler::processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("* Event processingInstruction (%s, %s) ***************\n"),
+ target, data));
+}
+
+void
+ACEXML_Print_Handler::setDocumentLocator (ACEXML_Locator * locator)
+{
+
+ this->locator_ = locator;
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event setDocumentLocator () ***************\n")));
+}
+
+void
+ACEXML_Print_Handler::skippedEntity (const ACEXML_Char *name
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("* Event skippedEntity (%s) ***************\n"),
+ name));
+}
+
+void
+ACEXML_Print_Handler::startDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("* Event startDocument () ***************\n")));
+}
+
+void
+ACEXML_Print_Handler::startElement (const ACEXML_Char *uri,
+ const ACEXML_Char *name,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *alist
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("* Event startElement (%s, %s, %s) ***************\n"),
+ uri, name, qName));
+
+ if (alist != 0)
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" %s = \"%s\"\n"),
+ alist->getQName (i), alist->getValue (i)));
+ }
+}
+
+void
+ACEXML_Print_Handler::startPrefixMapping (const ACEXML_Char * prefix,
+ const ACEXML_Char * uri ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("* Event startPrefixMapping () ***************\n")));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Prefix = %s, URI = %s\n"), prefix, uri));
+}
+
+// *** Methods inherit from ACEXML_DTDHandler.
+
+void
+ACEXML_Print_Handler::notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicID,
+ const ACEXML_Char *systemID ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("* Event notationDecl: (%s) "),
+ name));
+
+ if (publicID == 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("SYSTEM %s\n"),
+ systemID));
+ else if (systemID == 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("PUBLIC %s\n"),
+ publicID));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("PUBLIC %s %s\n"),
+ publicID, systemID));
+}
+
+void
+ACEXML_Print_Handler::unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicID,
+ const ACEXML_Char *systemID,
+ const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("* Unparsed Entity: %s"),
+ name));
+
+ if (publicID == 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" SYSTEM %s"),
+ systemID));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" PUBLIC %s %s"),
+ publicID, systemID));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" NDATA %s\n"),
+ notationName));
+}
+
+// Methods inherit from ACEXML_EnitityResolver.
+
+ACEXML_InputSource *
+ACEXML_Print_Handler::resolveEntity (const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+ return 0;
+}
+
+// Methods inherit from ACEXML_ErrorHandler.
+
+/*
+ * Receive notification of a recoverable error.
+ */
+void
+ACEXML_Print_Handler::error (ACEXML_SAXParseException & ex ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ",
+ (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()),
+ this->locator_->getLineNumber(),
+ this->locator_->getColumnNumber()));
+ ex.print();
+}
+
+void
+ACEXML_Print_Handler::fatalError (ACEXML_SAXParseException& ex ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ",
+ (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()),
+ this->locator_->getLineNumber(),
+ this->locator_->getColumnNumber()));
+ ex.print();
+
+}
+
+void
+ACEXML_Print_Handler::warning (ACEXML_SAXParseException & ex ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ",
+ (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()),
+ this->locator_->getLineNumber(),
+ this->locator_->getColumnNumber()));
+ ex.print();
+}
diff --git a/ACE/ACEXML/examples/SAXPrint/Print_Handler.h b/ACE/ACEXML/examples/SAXPrint/Print_Handler.h
new file mode 100644
index 00000000000..3f28e6d9165
--- /dev/null
+++ b/ACE/ACEXML/examples/SAXPrint/Print_Handler.h
@@ -0,0 +1,187 @@
+// $Id$
+
+//=============================================================================
+/**
+ * @file Print_Handler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef ACEXML_PRINT_HANDLER_H
+#define ACEXML_PRINT_HANDLER_H
+
+#include "ACEXML/common/DefaultHandler.h"
+
+/**
+ * @class ACEXML_Print_Handler
+ *
+ * @brief ACEXML_Print_Handler is an example SAX event handler.
+ *
+ * This SAX event handler prints out a detailed event report
+ * on every event it receives.
+ */
+class ACEXML_Print_Handler : public ACEXML_DefaultHandler
+{
+public:
+ /*
+ * Default constructor.
+ */
+ ACEXML_Print_Handler (ACEXML_Char* fileName);
+
+ /*
+ * Default destructor.
+ */
+ virtual ~ACEXML_Print_Handler (void);
+
+ // Methods inherited from ACEXML_ContentHandler.
+
+ /*
+ * Receive notification of character data.
+ */
+ virtual void characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the end of a document.
+ */
+ virtual void endDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the end of an element.
+ */
+ virtual void endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * End the scope of a prefix-URI mapping.
+ */
+ virtual void endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of ignorable whitespace in element content.
+ */
+ virtual void ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a processing instruction.
+ */
+ virtual void processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive an object for locating the origin of SAX document events.
+ */
+ virtual void setDocumentLocator (ACEXML_Locator *locator) ;
+
+ /*
+ * Receive notification of a skipped entity.
+ */
+ virtual void skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the beginning of a document.
+ */
+ virtual void startDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the beginning of an element.
+ */
+ virtual void startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Begin the scope of a prefix-URI Namespace mapping.
+ */
+ virtual void startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // *** Methods inherit from ACEXML_DTDHandler.
+
+ /*
+ * Receive notification of a notation declaration event.
+ */
+ virtual void notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of an unparsed entity declaration event.
+ */
+ virtual void unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // Methods inherit from ACEXML_EnitityResolver.
+
+ /*
+ * Allow the application to resolve external entities.
+ */
+ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // Methods inherit from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+ virtual void error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a non-recoverable error.
+ */
+ virtual void fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a warning.
+ */
+ virtual void warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+private:
+
+ ACEXML_Char* fileName_;
+ ACEXML_Locator* locator_;
+
+};
+
+#endif /* ACEXML_PRINT_HANDLER_H */
diff --git a/ACE/ACEXML/examples/SAXPrint/SAXPrint.mpc b/ACE/ACEXML/examples/SAXPrint/SAXPrint.mpc
new file mode 100644
index 00000000000..4fea0873337
--- /dev/null
+++ b/ACE/ACEXML/examples/SAXPrint/SAXPrint.mpc
@@ -0,0 +1,6 @@
+// -*- MPC -*-
+// $Id$
+
+project(SAXPrint): aceexe, acexml {
+ exename = SAXPrint
+}
diff --git a/ACE/ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp b/ACE/ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp
new file mode 100644
index 00000000000..3dfeb5a182a
--- /dev/null
+++ b/ACE/ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp
@@ -0,0 +1,244 @@
+// -*- C++ -*- $Id$
+
+#include "SAXPrint_Handler.h"
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "SAXPrint_Handler.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_SAXPrint_Handler::ACEXML_SAXPrint_Handler (const ACEXML_Char* filename)
+ : indent_ (0), fileName_(ACE::strnew (filename)), locator_ (0)
+{
+ // no-op
+}
+
+ACEXML_SAXPrint_Handler::~ACEXML_SAXPrint_Handler (void)
+{
+ delete [] this->fileName_;
+}
+
+void
+ACEXML_SAXPrint_Handler::characters (const ACEXML_Char *cdata,
+ int start,
+ int length ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+ ACE_UNUSED_ARG (start);
+ ACE_UNUSED_ARG (length);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%s"),
+ cdata));
+}
+
+void
+ACEXML_SAXPrint_Handler::endDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+}
+
+void
+ACEXML_SAXPrint_Handler::endElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *qName
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ this->dec_indent ();
+ this->print_indent ();
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("</%s>"),
+ qName));
+}
+
+void
+ACEXML_SAXPrint_Handler::endPrefixMapping (const ACEXML_Char *
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+// ACE_DEBUG ((LM_DEBUG,
+// ACE_TEXT ("* Event endPrefixMapping (%s) ***************\n"),
+// prefix));
+}
+
+void
+ACEXML_SAXPrint_Handler::ignorableWhitespace (const ACEXML_Char * cdata,
+ int,
+ int ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%s"),
+ cdata));
+// ACE_DEBUG ((LM_DEBUG,
+ // ACE_TEXT ("* Event ignorableWhitespace () ***************\n")));
+}
+
+void
+ACEXML_SAXPrint_Handler::processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ this->print_indent ();
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("<?%s %s>\n"),
+ target, data));
+}
+
+void
+ACEXML_SAXPrint_Handler::setDocumentLocator (ACEXML_Locator * locator)
+{
+
+ this->locator_ = locator;
+ //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event setDocumentLocator () ***************\n")));
+}
+
+void
+ACEXML_SAXPrint_Handler::skippedEntity (const ACEXML_Char *name
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("* Event skippedEntity (%s) ***************\n"),
+ name));
+}
+
+void
+ACEXML_SAXPrint_Handler::startDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("* Event startDocument () ***************\n")));
+}
+
+void
+ACEXML_SAXPrint_Handler::startElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *alist
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+
+
+ this->print_indent ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("<%s"),
+ qName));
+ if (alist != 0)
+ for (size_t i = 0; i < alist->getLength (); ++i)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" %s = \"%s\""),
+ alist->getQName (i), alist->getValue (i)));
+ }
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT (">")));
+ this->inc_indent ();
+}
+
+void
+ACEXML_SAXPrint_Handler::startPrefixMapping (const ACEXML_Char * ,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+// ACE_DEBUG ((LM_DEBUG,
+// ACE_TEXT ("* Event startPrefixMapping () ***************\n")));
+// ACE_DEBUG ((LM_DEBUG,
+// ACE_TEXT ("Prefix = %s, URI = %s\n"), prefix, uri));
+
+}
+
+// *** Methods inherited from ACEXML_DTDHandler.
+
+void
+ACEXML_SAXPrint_Handler::notationDecl (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_SAXPrint_Handler::unparsedEntityDecl (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+// Methods inherited from ACEXML_EnitityResolver.
+
+ACEXML_InputSource *
+ACEXML_SAXPrint_Handler::resolveEntity (const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+ return 0;
+}
+
+// Methods inherited from ACEXML_ErrorHandler.
+
+/*
+ * Receive notification of a recoverable error.
+ */
+void
+ACEXML_SAXPrint_Handler::error (ACEXML_SAXParseException & ex
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ",
+ (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()),
+ this->locator_->getLineNumber(),
+ this->locator_->getColumnNumber()));
+ ex.print();
+}
+
+void
+ACEXML_SAXPrint_Handler::fatalError (ACEXML_SAXParseException & ex
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ",
+ (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()),
+ this->locator_->getLineNumber(),
+ this->locator_->getColumnNumber()));
+ ex.print();
+}
+
+void
+ACEXML_SAXPrint_Handler::warning (ACEXML_SAXParseException & ex
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ",
+ (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()),
+ this->locator_->getLineNumber(),
+ this->locator_->getColumnNumber()));
+ ex.print();
+}
+
+void
+ACEXML_SAXPrint_Handler::print_indent (void)
+{
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
+ for (size_t i = 0; i < this->indent_; ++i)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" ")));
+}
diff --git a/ACE/ACEXML/examples/SAXPrint/SAXPrint_Handler.h b/ACE/ACEXML/examples/SAXPrint/SAXPrint_Handler.h
new file mode 100644
index 00000000000..612dd406c06
--- /dev/null
+++ b/ACE/ACEXML/examples/SAXPrint/SAXPrint_Handler.h
@@ -0,0 +1,195 @@
+// $Id$
+
+//=============================================================================
+/**
+ * @file SAXPrint_Handler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef ACEXML_SAXPRINT_HANDLER_H
+#define ACEXML_SAXPRINT_HANDLER_H
+
+#include "ACEXML/common/DefaultHandler.h"
+
+/**
+ * @class ACEXML_SAXPrint_Handler
+ *
+ * @brief ACEXML_SAXPrint_Handler is an example SAX event handler.
+ *
+ * This SAX event handler try to regenerate the XML document it
+ * reads with correct indentation.
+ */
+class ACEXML_SAXPrint_Handler : public ACEXML_DefaultHandler
+{
+public:
+ /*
+ * Default constructor.
+ */
+ ACEXML_SAXPrint_Handler (const ACEXML_Char* name);
+
+ /*
+ * Default destructor.
+ */
+ virtual ~ACEXML_SAXPrint_Handler (void);
+
+ // Methods inherit from ACEXML_ContentHandler.
+
+ /*
+ * Receive notification of character data.
+ */
+ virtual void characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the end of a document.
+ */
+ virtual void endDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the end of an element.
+ */
+ virtual void endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * End the scope of a prefix-URI mapping.
+ */
+ virtual void endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of ignorable whitespace in element content.
+ */
+ virtual void ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a processing instruction.
+ */
+ virtual void processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive an object for locating the origin of SAX document events.
+ */
+ virtual void setDocumentLocator (ACEXML_Locator *locator) ;
+
+ /*
+ * Receive notification of a skipped entity.
+ */
+ virtual void skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the beginning of a document.
+ */
+ virtual void startDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of the beginning of an element.
+ */
+ virtual void startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Begin the scope of a prefix-URI Namespace mapping.
+ */
+ virtual void startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // *** Methods inherit from ACEXML_DTDHandler.
+
+ /*
+ * Receive notification of a notation declaration event.
+ */
+ virtual void notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of an unparsed entity declaration event.
+ */
+ virtual void unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // Methods inherit from ACEXML_EnitityResolver.
+
+ /*
+ * Allow the application to resolve external entities.
+ */
+ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ // Methods inherit from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+ virtual void error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a non-recoverable error.
+ */
+ virtual void fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Receive notification of a warning.
+ */
+ virtual void warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ void inc_indent ();
+ void dec_indent ();
+ void print_indent ();
+
+private:
+
+ size_t indent_;
+ ACEXML_Char* fileName_;
+ ACEXML_Locator* locator_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "SAXPrint_Handler.i"
+#endif /* __ACEXML_INLINE__ */
+#endif /* ACEXML_SAXPRINT_HANDLER_H */
diff --git a/ACE/ACEXML/examples/SAXPrint/SAXPrint_Handler.i b/ACE/ACEXML/examples/SAXPrint/SAXPrint_Handler.i
new file mode 100644
index 00000000000..2102291ea68
--- /dev/null
+++ b/ACE/ACEXML/examples/SAXPrint/SAXPrint_Handler.i
@@ -0,0 +1,13 @@
+// -*- C++ -*- $Id$
+
+ACEXML_INLINE void
+ACEXML_SAXPrint_Handler::inc_indent (void)
+{
+ this->indent_ += 1;
+}
+
+ACEXML_INLINE void
+ACEXML_SAXPrint_Handler::dec_indent (void)
+{
+ this->indent_ -= 1;
+}
diff --git a/ACE/ACEXML/examples/SAXPrint/broken.xml b/ACE/ACEXML/examples/SAXPrint/broken.xml
new file mode 100644
index 00000000000..8c350cc24fe
--- /dev/null
+++ b/ACE/ACEXML/examples/SAXPrint/broken.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<!-- This is a broken XML file. Most of the stuff here don't make any sense at all -->
+
+<root>
+ <child> kid
diff --git a/ACE/ACEXML/examples/SAXPrint/main.cpp b/ACE/ACEXML/examples/SAXPrint/main.cpp
new file mode 100644
index 00000000000..f6f334cee0e
--- /dev/null
+++ b/ACE/ACEXML/examples/SAXPrint/main.cpp
@@ -0,0 +1,206 @@
+// $Id$
+
+#include "ACEXML/common/FileCharStream.h"
+#include "ACEXML/common/HttpCharStream.h"
+#include "ACEXML/common/StrCharStream.h"
+#include "ACEXML/common/ZipCharStream.h"
+#include "ACEXML/parser/parser/Parser.h"
+#include "Print_Handler.h"
+#include "SAXPrint_Handler.h"
+#include "ace/Get_Opt.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_main.h"
+
+static const ACEXML_Char *test_string =
+ACE_TEXT ("<?xml version='1.0'?> <ACE_Svc_Conf> <static id=\"ACE_Service_Manager\" params='-d -p 4911'/> <dynamic id=\"Test_Task\" type=\"service_object\"> &#65; &quot; <initializer path=\"CCM_App\" init='_make_Test_Task' params='-p 3000'/> </dynamic> </ACE_Svc_Conf>");
+
+static void
+usage (const ACE_TCHAR* program)
+{
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Usage: %s [-sl] [-f <filename> | -u <url> | -z <ZIP Archive>]\n")
+ ACE_TEXT (" -s: Use SAXPrint_Handler (Default is Print_Handler)\n")
+ ACE_TEXT (" -l: Parse the internal strings (test the StrCharStream class)\n")
+ ACE_TEXT (" -f: Specify the filename when -l is not specified\n")
+ ACE_TEXT (" -z: Specify that the file is inside a ZIP archive\n")
+ ACE_TEXT (" -u: URL specifying the path to the file\n"),
+ program));
+}
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ ACEXML_Char* filename = 0;
+ int sax = 0; // Use SAXPrint handler or not.
+ int str = 0;
+ int zip = 0;
+ ACEXML_Char* url = 0;
+
+ ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("sf:lu:z"));
+ int c;
+
+ while ((c = get_opt ()) != EOF)
+ {
+ switch (c)
+ {
+ case 's':
+ sax = 1;
+ break;
+ case 'l':
+ str = 1;
+ break;
+ case 'f':
+ filename = get_opt.opt_arg ();
+ break;
+ case 'u':
+ url = get_opt.opt_arg();
+ break;
+ case 'z':
+ zip = 1;
+#ifndef USE_ZZIP
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("ZZIPLIB support has not been")
+ ACE_TEXT (" compiled in. Refer to ")
+ ACE_TEXT ("$ACE_ROOT/ACEXML/README for more ")
+ ACE_TEXT ("information. \n")));
+ return -1;
+#endif /* USE_ZZIP */
+ break;
+ default:
+ usage(argv[0]);
+ return -1;
+ }
+ }
+
+ if (str == 0 && filename == 0 && url == 0) {
+ usage(argv[0]);
+ return -1;
+ }
+
+ ACEXML_DefaultHandler *handler = 0;
+ ACEXML_CharStream *stm = 0;
+ ACEXML_FileCharStream *fstm = 0;
+ ACEXML_HttpCharStream *ustm = 0;
+ ACEXML_StrCharStream* sstm = 0;
+#ifdef USE_ZZIP
+ ACEXML_ZipCharStream* zstm = 0;
+#endif /* USE_ZZIP */
+ if (filename != 0)
+ {
+#ifdef USE_ZZIP
+ if (zip)
+ {
+ ACE_NEW_RETURN (zstm, ACEXML_ZipCharStream(), -1);
+ if (zstm->open (filename) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Failed to open XML file: %s\n"),
+ filename),
+ -1);
+ stm = zstm;
+ }
+ else
+ {
+#endif /* USE_ZZIP */
+ ACE_NEW_RETURN (fstm, ACEXML_FileCharStream (), -1);
+ if (fstm->open (filename) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Failed to open XML file: %s\n"),
+ filename),
+ -1);
+ stm = fstm;
+#ifdef USE_ZZIP
+ }
+#endif /* USE_ZZIP */
+ }
+ else if (url != 0)
+ {
+
+ ACE_NEW_RETURN (ustm, ACEXML_HttpCharStream (), -1);
+ if (ustm->open (url) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Failed to open URL : %s\n"),
+ url),
+ -1);
+ stm = ustm;
+ }
+ else
+ {
+ ACE_NEW_RETURN (sstm, ACEXML_StrCharStream, -1);
+ if (sstm->open (test_string, ACE_TEXT ("test_string")) < 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Failed to open string : %s\n"),
+ test_string),
+ -1);
+ stm = sstm;
+ }
+
+ ACEXML_Char* name = (filename == 0) ? url : filename;
+ if (sax == 0)
+ ACE_NEW_RETURN (handler,
+ ACEXML_Print_Handler (name),
+ -1);
+ else
+ ACE_NEW_RETURN (handler,
+ ACEXML_SAXPrint_Handler (name),
+ -1);
+ auto_ptr<ACEXML_DefaultHandler> cleanup_handler (handler);
+
+ ACEXML_Parser parser;
+ ACEXML_InputSource input (stm);
+
+ parser.setContentHandler (handler);
+ parser.setDTDHandler (handler);
+ parser.setErrorHandler (handler);
+ parser.setEntityResolver (handler);
+ ACEXML_DECLARE_NEW_ENV;
+
+ ACEXML_TRY_EX (FIRST)
+ {
+ parser.parse (&input ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_TRY_CHECK_EX (FIRST);
+ }
+ ACEXML_CATCH (ACEXML_Exception, ex)
+ {
+ ex.print();
+ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Exception occurred. Exiting...\n")));
+ }
+ ACEXML_ENDTRY;
+ ACEXML_TRY_EX (SECOND)
+ {
+ parser.parse (&input ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_TRY_CHECK_EX (SECOND);
+ }
+ ACEXML_CATCH (ACEXML_SAXException, ex)
+ {
+ ex.print();
+ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Exception occurred. Exiting...\n")));
+ return 1;
+ }
+ ACEXML_ENDTRY;
+// ACEXML_TRY_EX (THIRD)
+// {
+// parser.parse (&input ACEXML_ENV_ARG_PARAMETER);
+// ACEXML_TRY_CHECK_EX (THIRD);
+// }
+// ACEXML_CATCH (ACEXML_SAXException, ex)
+// {
+// ex.print();
+// ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Exception occurred. Exiting...\n")));
+// return 1;
+// }
+// ACEXML_ENDTRY;
+// ACEXML_TRY_EX (FOURTH)
+// {
+// parser.parse (&input ACEXML_ENV_ARG_PARAMETER);
+// ACEXML_TRY_CHECK_EX (FOURTH);
+// }
+// ACEXML_CATCH (ACEXML_SAXException, ex)
+// {
+// ex.print();
+// ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Exception occurred. Exiting...\n")));
+// return 1;
+// }
+// ACEXML_ENDTRY;
+ return 0;
+}
+
diff --git a/ACE/ACEXML/examples/SAXPrint/namespaces.xml b/ACE/ACEXML/examples/SAXPrint/namespaces.xml
new file mode 100644
index 00000000000..f2418848929
--- /dev/null
+++ b/ACE/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/ACE/ACEXML/examples/SAXPrint/ns.svc.conf.xml b/ACE/ACEXML/examples/SAXPrint/ns.svc.conf.xml
new file mode 100644
index 00000000000..980ef21de92
--- /dev/null
+++ b/ACE/ACEXML/examples/SAXPrint/ns.svc.conf.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<ace:ACE_Svc_Conf xmlns="http://ace.doc.wustl.edu/svcconf" xmlns:ace="http://ace.doc.wustl.edu/svcconf">
+<static id="ACE_Service_Manager">
+ <params>-d</params>
+ <params>-p 4911</params>
+</static>
+
+<dynamic id="Test_Task" type="service_object"> &#65; &amp;lt;
+ <initializer path="CCM_App" init="_make_Test_Task">
+ <params>-p 3000</params>
+ </initializer>
+</dynamic>
+
+<ace:streamdef>
+ <dynamic id="CCM_App" type="stream" status="active">
+ <initializer path="CCM_App" init="make_stream"/>
+ </dynamic>
+ <module>
+ <dynamic id="Device_Adapter" type="module">
+ <initializer path="CCM_App" init="make_da"/>
+ </dynamic>
+ <dynamic id="Event_Analyzer" type="module">
+ <initializer path="CCM_App" init="make_ea"/>
+ </dynamic>
+ <dynamic id="Multicast_Router" type="module">
+ <initializer path="CCM_App" init="make_mr">
+ <params>-p</params>
+ <params>3001</params>
+ </initializer>
+ </dynamic>
+ </module>
+</ace:streamdef>
+
+<stream id="CCM_App">
+ <module>
+ <remove id="Device_Adapter"/>
+ <!-- <remove id="Event_Analyzer"/> -->
+ <!-- <remove id="Multicast_Router"/> -->
+ <![CDATA[Only a text string.
+Do you &amp;expect something more?]]>
+ </module>
+</stream>
+
+<!-- remove CCM_App -->
+<remove id="Test_&amp;Task&#x65;bc"/>
+</ace:ACE_Svc_Conf>
diff --git a/ACE/ACEXML/examples/SAXPrint/simple.svcconf.xml b/ACE/ACEXML/examples/SAXPrint/simple.svcconf.xml
new file mode 100644
index 00000000000..32afe359fdb
--- /dev/null
+++ b/ACE/ACEXML/examples/SAXPrint/simple.svcconf.xml
@@ -0,0 +1,38 @@
+<ACE_Svc_Conf>
+<static id="ACE_Service_Manager" params="-d -p 4911"/>
+
+<dynamic id="Test_Task" type="service_object"> &#65; &amp;
+ <initializer path="CCM_App" init="_make_Test_Task" params="-p 3000" />
+</dynamic>
+
+<streamdef>
+ <dynamic id="CCM_App" type="stream" status="active">
+ <initializer path="CCM_App" init="make_stream"/>
+ </dynamic>
+ <module>
+ <dynamic id="Device_Adapter" type="module">
+ <initializer path="CCM_App" init="make_da"/>
+ </dynamic>
+ <dynamic id="Event_Analyzer" type="module">
+ <initializer path="CCM_App" init="make_ea"/>
+ </dynamic>
+ <dynamic id="Multicast_Router" type="module">
+ <initializer path="CCM_App" init="make_mr" params="-p 3001"/>
+ </dynamic>
+ </module>
+</streamdef>
+
+<stream id="&ccm;">
+ <module>
+ <remove id="Device_Adapter"/>
+ <!-- <remove id="Event_Analyzer"/> -->
+ <!-- <remove id="Multicast_Router"/> -->
+ <![CDATA[Only a text string.
+Do you &amp;expect something more? &#65;]]>
+<!-- Noticed that the "&amp;" in the above CDATA section can not be escaped. -->
+ </module>
+</stream>
+
+<!-- remove CCM_App -->
+<remove id="Test_&amp;Task&#x61;bc"/>
+</ACE_Svc_Conf>
diff --git a/ACE/ACEXML/examples/SAXPrint/svc.conf.xml b/ACE/ACEXML/examples/SAXPrint/svc.conf.xml
new file mode 100644
index 00000000000..5296e5cac35
--- /dev/null
+++ b/ACE/ACEXML/examples/SAXPrint/svc.conf.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!-- This is a test XML file. Most of the stuff here don't make any sense at all -->
+<!DOCTYPE ACE_Svc_Conf PUBLIC 'GOODSAM' '../../apps/svcconf/svcconf.dtd'
+ [
+ <!NOTATION goody PUBLIC 'NBC' 'http://hardcoreace.com/'>
+ <!NOTATION frodo PUBLIC 'ABC'>
+ <!NOTATION bilbo SYSTEM "C:/ACE-GUIDELINE">
+ <!ENTITY ccm 'CCM_App'>
+ <!ENTITY pippin PUBLIC 'GOTO' 'http://taozen.com/' NDATA goody>
+ <!ENTITY sam PUBLIC 'SHIRE' 'http://taozen.com/'>
+ <!ENTITY gandolf SYSTEM 'D:/RINGS.DOT'>
+ <!ELEMENT GOOBEGONE EMPTY>
+ <!ELEMENT POOPOO ANY>
+ <!ELEMENT HOHOHO ((BOOBOO, GOOBEGONE)?, (GOOBEGONE|POOPOO)*)+>
+ <!ELEMENT BOOBOO (#PCDATA | BOOBOO)*>
+ <!ATTLIST GOOBEGONE
+ ohmy CDATA #REQUIRED
+ testing IDREF #IMPLIED>
+ ]>
+
+<ACE_Svc_Conf>
+<static id="ACE_Service_Manager" params="-d -p 4911"/>
+
+<dynamic id="Test_Task" type="service_object"> &#65; &amp;
+ <initializer path="CCM_App" init="_make_Test_Task" params="-p 3000" />
+</dynamic>
+
+<streamdef>
+ <dynamic id="CCM_App" type="stream" status="active">
+ <initializer path="CCM_App" init="make_stream"/>
+ </dynamic>
+ <module>
+ <dynamic id="Device_Adapter" type="module">
+ <initializer path="CCM_App" init="make_da"/>
+ </dynamic>
+ <dynamic id="Event_Analyzer" type="module">
+ <initializer path="CCM_App" init="make_ea"/>
+ </dynamic>
+ <dynamic id="Multicast_Router" type="module">
+ <initializer path="CCM_App" init="make_mr" params="-p 3001"/>
+ </dynamic>
+ </module>
+</streamdef>
+
+<stream id="&ccm;">
+ <module>
+ <remove id="Device_Adapter"/>
+ <!-- <remove id="Event_Analyzer"/> -->
+ <!-- <remove id="Multicast_Router"/> -->
+ <![CDATA[Only a text string.
+Do you &amp;expect something more? &#65;]]>
+<!-- Noticed that the "&amp;" in the above CDATA section can not be escaped. -->
+ </module>
+</stream>
+
+<!-- remove CCM_App -->
+<remove id="Test_&amp;Task&#x61;bc"/>
+</ACE_Svc_Conf>
diff --git a/ACE/ACEXML/parser/Makefile.am b/ACE/ACEXML/parser/Makefile.am
new file mode 100644
index 00000000000..de38e543937
--- /dev/null
+++ b/ACE/ACEXML/parser/Makefile.am
@@ -0,0 +1,13 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+SUBDIRS = \
+ parser
+
diff --git a/ACE/ACEXML/parser/debug_validator/Debug_Attributes_Builder.cpp b/ACE/ACEXML/parser/debug_validator/Debug_Attributes_Builder.cpp
new file mode 100644
index 00000000000..65ae6e3776d
--- /dev/null
+++ b/ACE/ACEXML/parser/debug_validator/Debug_Attributes_Builder.cpp
@@ -0,0 +1,215 @@
+// $Id$
+
+#include "ACEXML/common/SAXExceptions.h"
+#include "ACEXML/parser/debug_validator/Debug_Attributes_Builder.h"
+
+ACEXML_Debug_Attribute_Builder::ACEXML_Debug_Attribute_Builder ()
+ : type_ (ERROR_TYPE),
+ default_decl_ (INVALID)
+{
+}
+
+ACEXML_Debug_Attribute_Builder::ACEXML_Debug_Attribute_Builder (const ACEXML_Debug_Attribute_Builder &rhs)
+ : name_ (rhs.name_),
+ type_ (rhs.type_),
+ default_decl_ (rhs.default_decl_),
+ default_value_ (rhs.default_value_),
+ att_value_queue_ (rhs.att_value_queue_)
+{
+}
+
+ACEXML_Debug_Attribute_Builder::~ACEXML_Debug_Attribute_Builder ()
+{
+}
+
+int
+ACEXML_Debug_Attribute_Builder::setName (const ACEXML_Char *n)
+{
+ this->name_.set (n, 0);
+ return 0;
+}
+
+const ACEXML_Char *
+ACEXML_Debug_Attribute_Builder::getName (void)
+{
+ return this->name_.fast_rep ();
+}
+
+int
+ACEXML_Debug_Attribute_Builder::setAttType (const ATT_TYPE type
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->type_ == ERROR_TYPE)
+ {
+ this->type_ = type;
+ return 0;
+ }
+ ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("Attribute type redefinition in Debug Validator")), -1);
+
+}
+
+int
+ACEXML_Debug_Attribute_Builder::insertList (const ACEXML_Char *n
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_String str (n, 0, 0);
+
+ this->att_value_queue_.enqueue_tail (str);
+ return 0;
+}
+
+int
+ACEXML_Debug_Attribute_Builder::setDefault (const DEFAULT_DECL def,
+ const ACEXML_Char *value
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ this->default_decl_ = def;
+ this->default_value_.set (value, 0);
+ return 0;
+}
+
+int
+ACEXML_Debug_Attribute_Builder::validAttr (void)
+{
+ // @@ Not implemented. Always return 1 (true) for now.
+ return 1;
+}
+
+void
+ACEXML_Debug_Attribute_Builder::dump (void)
+{
+ cout << this->name_ << " ";
+
+ switch (this->type_)
+ {
+ case CDATA:
+ cout << "CDATA ";
+ break;
+ case ID:
+ cout << "ID ";
+ break;
+ case IDREF:
+ cout << "IDREF ";
+ break;
+ case IDREFS:
+ cout << "IDREFS ";
+ break;
+ case ENTITY:
+ cout << "ENTITY ";
+ break;
+ case ENTITIES:
+ cout << "ENTITIES ";
+ break;
+ case NMTOKEN:
+ cout << "NMTOKEN ";
+ break;
+ case NMTOKENS:
+ cout << "NMTOKENS ";
+ break;
+ case NOTATION:
+ cout << "NOTATION ";
+ // Fall thru
+ case ENUMERATION:
+ {
+ cout << "(";
+ ACEXML_STRING_QUEUE_ITERATOR iter (this->att_value_queue_);
+ ACEXML_String *n = 0;
+
+ while (iter.advance () != 0)
+ {
+ if (n == 0)
+ cout << " | ";
+ iter.next (n);
+ cout << *n;
+ }
+ cout << ") ";
+ }
+ break;
+ default:
+ cout << "*** UNKNOWN TYPE ***";
+ break;
+ }
+
+ switch (this->default_decl_)
+ {
+ case REQUIRED:
+ cout << "#REQUIRED";
+ break;
+ case IMPLIED:
+ cout << "#IMPLIED";
+ break;
+ case FIXED:
+ cout << "#FIXED " << this->default_value_;
+ break;
+ default:
+ cout << "**** UNDEFINED DEFAULT DECL ****";
+ break;
+ }
+}
+// ========================================
+
+ACEXML_Debug_Attributes_Builder::ACEXML_Debug_Attributes_Builder ()
+{
+}
+
+ACEXML_Debug_Attributes_Builder::~ACEXML_Debug_Attributes_Builder ()
+{
+}
+
+int
+ACEXML_Debug_Attributes_Builder::setElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ this->element_name_.set (qName, 0);
+ return 0;
+}
+
+ACEXML_Attribute_Def_Builder *
+ACEXML_Debug_Attributes_Builder::getAttribute_Def_Builder ()
+{
+ ACEXML_Attribute_Def_Builder *tmp;
+
+ ACE_NEW_RETURN (tmp,
+ ACEXML_Debug_Attribute_Builder (),
+ 0);
+ return tmp;
+}
+
+int
+ACEXML_Debug_Attributes_Builder::insertAttribute (ACEXML_Attribute_Def_Builder *def ACEXML_ENV_ARG_DECL)
+{
+ ACEXML_Attribute_Def_Builder::VAR ptr (def);
+
+ if (def != 0)
+ {
+ ACEXML_String attname (def->getName (), 0, 0);
+ ACEXML_Debug_Attribute_Builder *ptr =
+ dynamic_cast<ACEXML_Debug_Attribute_Builder *> (def);
+ this->attributes_.bind (attname, *ptr);
+ return 0;
+ }
+ ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("ACEXML_Debug_Attributes_Builder internal error")), -1);
+}
+
+void
+ACEXML_Debug_Attributes_Builder::dump (void)
+{
+ // @@ Print print.
+ cout << "<!ATTLIST " << this->element_name_ << endl;
+
+ ACEXML_ATT_MAP_ITER iter (this->attributes_);
+ ACEXML_ATT_MAP_ENTRY *item;
+
+ while (iter.advance () != 0)
+ {
+ iter.next (item);
+ cout << "\n\t";
+ item->int_id_.dump ();
+ }
+ cout << ">" << endl;
+}
diff --git a/ACE/ACEXML/parser/debug_validator/Debug_Attributes_Builder.h b/ACE/ACEXML/parser/debug_validator/Debug_Attributes_Builder.h
new file mode 100644
index 00000000000..42a8273e2fe
--- /dev/null
+++ b/ACE/ACEXML/parser/debug_validator/Debug_Attributes_Builder.h
@@ -0,0 +1,170 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Debug_Attributes_Builder.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_DEBUG_ATTRIBUTES_BUILDER_H_
+#define _ACEXML_DEBUG_ATTRIBUTES_BUILDER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Attributes_Def_Builder.h"
+#include "ace/Hash_Map_Manager.h"
+#include "ace/Unbounded_Queue.h"
+
+typedef ACE_Unbounded_Queue<ACEXML_String> ACEXML_STRING_QUEUE;
+typedef ACE_Unbounded_Queue_Iterator<ACEXML_String> ACEXML_STRING_QUEUE_ITERATOR;
+
+/**
+ * @class ACEXML_Debug_Attribute_Builder Debug_Attributes_Builder.h "parser/debug_validator/Debug_Attributes_Builder.h"
+ *
+ * This class prints out the Attribute definition for debugging purpose.
+ */
+class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Debug_Attribute_Builder
+ : public ACEXML_Attribute_Def_Builder
+{
+public:
+ ACEXML_Debug_Attribute_Builder ();
+
+ ACEXML_Debug_Attribute_Builder (const ACEXML_Debug_Attribute_Builder &rhs);
+
+ virtual ~ACEXML_Debug_Attribute_Builder ();
+
+ /**
+ * Specify the name of the attribute.
+ */
+ virtual int setName (const ACEXML_Char *n);
+ virtual const ACEXML_Char *getName (void);
+
+ /**
+ * Set the attribute type.
+ */
+ virtual int setAttType (const ATT_TYPE type ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /**
+ * Insert an element for NOTATION or ENUMERATION type attribute.
+ */
+ virtual int insertList (const ACEXML_Char *Name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /**
+ * Set default attribute declaration.
+ */
+ virtual int setDefault (const DEFAULT_DECL def,
+ const ACEXML_Char *value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /**
+ * Check validity of the current attribute definition being built.
+ *
+ * @retval 0 if the attribute is not a valid combo.
+ */
+ virtual int validAttr (void);
+
+
+ /**
+ * Dump the content of the attribute definition.
+ */
+ virtual void dump (void);
+private:
+ /// Attribute name.
+ ACEXML_String name_;
+
+ /// Type of attribute.
+ ATT_TYPE type_;
+
+ /// Default value type.
+ DEFAULT_DECL default_decl_;
+
+ /// Default attribute value.
+ ACEXML_String default_value_;
+
+ /// Holds a queue of enumerated attribute values.
+ ACEXML_STRING_QUEUE att_value_queue_;
+};
+
+typedef ACE_Hash_Map_Entry<ACEXML_String,
+ ACEXML_Debug_Attribute_Builder> ACEXML_ATT_MAP_ENTRY;
+
+typedef ACE_Hash_Map_Manager_Ex <ACEXML_String,
+ ACEXML_Debug_Attribute_Builder,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_ATT_MAP;
+
+typedef ACE_Hash_Map_Iterator_Ex<ACEXML_String,
+ ACEXML_Debug_Attribute_Builder,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_ATT_MAP_ITER;
+
+typedef ACE_Hash_Map_Reverse_Iterator_Ex<ACEXML_String,
+ ACEXML_Debug_Attribute_Builder,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_ATT_MAP_REVERSE_ITER;
+
+/**
+ * @class ACEXML_Debug_Attributes_Builder Debug_Attributes_Builder.h "parser/debug_validator/Debug_Attributes_Builder.h"
+ *
+ * This class prints out Attribute definitions for debugging purpose.
+ */
+class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Debug_Attributes_Builder
+ : public ACEXML_Attributes_Def_Builder
+{
+public:
+ ACEXML_Debug_Attributes_Builder ();
+
+ virtual ~ACEXML_Debug_Attributes_Builder ();
+
+ /**
+ * Set the element name that the attribute builder applies.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int setElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /**
+ * Acquire an Attribute_Builder.
+ */
+ virtual ACEXML_Attribute_Def_Builder *getAttribute_Def_Builder ();
+
+ /**
+ * Add a definition for one attribute.
+ */
+ virtual int insertAttribute (ACEXML_Attribute_Def_Builder *def ACEXML_ENV_ARG_DECL);
+
+
+ /**
+ * Dump the content of the attribute definition.
+ */
+ virtual void dump (void);
+protected:
+ /// The name of the element type these attributes applied.
+ ACEXML_String element_name_;
+
+ /// Collection of attributes.
+ ACEXML_ATT_MAP attributes_;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_DEBUG_ATTRIBUTES_BUILDER_H_ */
diff --git a/ACE/ACEXML/parser/debug_validator/Debug_DTD_Manager.cpp b/ACE/ACEXML/parser/debug_validator/Debug_DTD_Manager.cpp
new file mode 100644
index 00000000000..d0745d13bfc
--- /dev/null
+++ b/ACE/ACEXML/parser/debug_validator/Debug_DTD_Manager.cpp
@@ -0,0 +1,71 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/SAXExceptions.h"
+#include "ACEXML/parser/debug_validator/Debug_DTD_Manager.h"
+#include "ACEXML/parser/debug_validator/Debug_Element_Builder.h"
+#include "ACEXML/parser/debug_validator/Debug_Attributes_Builder.h"
+
+ACEXML_Debug_DTD_Manager::ACEXML_Debug_DTD_Manager ()
+{
+
+}
+
+ACEXML_Debug_DTD_Manager::~ACEXML_Debug_DTD_Manager ()
+{
+
+}
+
+ACEXML_Element_Def_Builder *
+ACEXML_Debug_DTD_Manager::getElement_Def_Builder ()
+{
+ return new ACEXML_Debug_Element_Builder ();
+}
+
+int
+ACEXML_Debug_DTD_Manager::insertElement_Definition (ACEXML_Element_Def_Builder *def ACEXML_ENV_ARG_DECL)
+{
+ ACEXML_Element_Def_Builder::VAR ptr (def);
+
+ if (def != 0)
+ {
+ ptr->dump ();
+ return 0;
+ }
+
+ ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("ACEXML_Debug_Attributes_Builder internal error")), -1);
+}
+
+ACEXML_Attributes_Def_Builder *
+ACEXML_Debug_DTD_Manager::getAttribute_Def_Builder ()
+{
+ ACEXML_Attributes_Def_Builder *tmp;
+ ACE_NEW_RETURN (tmp,
+ ACEXML_Debug_Attributes_Builder (),
+ 0);
+ return tmp;
+}
+
+int
+ACEXML_Debug_DTD_Manager::insertAttributes_Definition (ACEXML_Attributes_Def_Builder *def ACEXML_ENV_ARG_DECL)
+{
+ ACEXML_Attributes_Def_Builder::VAR ptr (def);
+ if (def != 0)
+ {
+ ptr->dump ();
+ return 0;
+ }
+
+ ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("ACEXML_Debug_Attributes_Builder internal error")), -1);
+}
+
+ACEXML_Validator *
+ACEXML_Debug_DTD_Manager::getValidator (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+{
+ ACE_UNUSED_ARG (namespaceURI);
+ ACE_UNUSED_ARG (localName);
+ ACE_UNUSED_ARG (qName);
+
+ ACEXML_THROW_RETURN (ACEXML_SAXNotSupportedException (ACE_TEXT ("getValidator()")), 0);
+}
diff --git a/ACE/ACEXML/parser/debug_validator/Debug_DTD_Manager.h b/ACE/ACEXML/parser/debug_validator/Debug_DTD_Manager.h
new file mode 100644
index 00000000000..0849d95ecb2
--- /dev/null
+++ b/ACE/ACEXML/parser/debug_validator/Debug_DTD_Manager.h
@@ -0,0 +1,76 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Debug_DTD_Manager.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_DEBUG_DTD_Manager_H_
+#define _ACEXML_DEBUG_DTD_Manager_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/DTD_Manager.h"
+
+class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Debug_DTD_Manager : public ACEXML_DTD_Manager
+{
+public:
+ ACEXML_Debug_DTD_Manager ();
+
+ virtual ~ACEXML_Debug_DTD_Manager ();
+
+ /**
+ * Acquire a pointer to an element definition builder. The XML parser use
+ * this interface to acquire the definition builder and use the builder
+ * to create the DTD element definition. The resulting builder is then
+ * registered with the DTD Manager or destroyed if error occured when the
+ * builder encountered errors.
+ *
+ * @retval 0 if error occurs creating the builder.
+ */
+ virtual ACEXML_Element_Def_Builder *getElement_Def_Builder ();
+
+ /**
+ * Insert a new element definition into the DTD Manager.
+ *
+ * @retval 0 if success, -1 if error.
+ */
+ virtual int insertElement_Definition (ACEXML_Element_Def_Builder *def ACEXML_ENV_ARG_DECL);
+
+ /**
+ * Acquire a pointer to an attributes definition builder.
+ *
+ */
+ virtual ACEXML_Attributes_Def_Builder *getAttribute_Def_Builder ();
+
+ /**
+ * Insert a new attributes definition into the DTD Manager.
+ *
+ * @retval 0 if success, -1 otherwise.
+ */
+ virtual int insertAttributes_Definition (ACEXML_Attributes_Def_Builder *def ACEXML_ENV_ARG_DECL);
+
+ /**
+ * Acquire an element validator to validate an XML element.
+ *
+ * @todo I haven't figured out what memory management scheme
+ * we should use for the acquired validator.
+ */
+ virtual ACEXML_Validator *getValidator (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL);
+};
+
+#include /**/ "ace/post.h"
+
+
+#endif /* _ACEXML_DTD_Manager_H_ */
diff --git a/ACE/ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h b/ACE/ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h
new file mode 100644
index 00000000000..b4cf1c8a536
--- /dev/null
+++ b/ACE/ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h
@@ -0,0 +1,38 @@
+
+// -*- C++ -*-
+// $Id$
+// Definition for Win32 Export directives.
+// This file is generated automatically by generate_export_file.pl -s ACEXML_DEBUG_DTD_MANAGER
+// ------------------------------
+#ifndef ACEXML_DEBUG_DTD_MANAGER_EXPORT_H
+#define ACEXML_DEBUG_DTD_MANAGER_EXPORT_H
+
+#include "ace/config-all.h"
+
+#if defined (ACE_AS_STATIC_LIBS) && !defined (ACEXML_DEBUG_DTD_MANAGER_HAS_DLL)
+# define ACEXML_DEBUG_DTD_MANAGER_HAS_DLL 0
+#endif /* ACE_AS_STATIC_LIBS && ACEXML_DEBUG_DTD_MANAGER_HAS_DLL */
+
+#if !defined (ACEXML_DEBUG_DTD_MANAGER_HAS_DLL)
+# define ACEXML_DEBUG_DTD_MANAGER_HAS_DLL 1
+#endif /* ! ACEXML_DEBUG_DTD_MANAGER_HAS_DLL */
+
+#if defined (ACEXML_DEBUG_DTD_MANAGER_HAS_DLL) && (ACEXML_DEBUG_DTD_MANAGER_HAS_DLL == 1)
+# if defined (ACEXML_DEBUG_DTD_MANAGER_BUILD_DLL)
+# define ACEXML_DEBUG_DTD_MANAGER_Export ACE_Proper_Export_Flag
+# define ACEXML_DEBUG_DTD_MANAGER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define ACEXML_DEBUG_DTD_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* ACEXML_DEBUG_DTD_MANAGER_BUILD_DLL */
+# define ACEXML_DEBUG_DTD_MANAGER_Export ACE_Proper_Import_Flag
+# define ACEXML_DEBUG_DTD_MANAGER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define ACEXML_DEBUG_DTD_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* ACEXML_DEBUG_DTD_MANAGER_BUILD_DLL */
+#else /* ACEXML_DEBUG_DTD_MANAGER_HAS_DLL == 1 */
+# define ACEXML_DEBUG_DTD_MANAGER_Export
+# define ACEXML_DEBUG_DTD_MANAGER_SINGLETON_DECLARATION(T)
+# define ACEXML_DEBUG_DTD_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* ACEXML_DEBUG_DTD_MANAGER_HAS_DLL == 1 */
+
+#endif /* ACEXML_DEBUG_DTD_MANAGER_EXPORT_H */
+
+// End of auto generated file.
diff --git a/ACE/ACEXML/parser/debug_validator/Debug_Element_Builder.cpp b/ACE/ACEXML/parser/debug_validator/Debug_Element_Builder.cpp
new file mode 100644
index 00000000000..48fff495365
--- /dev/null
+++ b/ACE/ACEXML/parser/debug_validator/Debug_Element_Builder.cpp
@@ -0,0 +1,148 @@
+// $Id$
+
+#include "ACEXML/common/SAXExceptions.h"
+#include "ACEXML/parser/debug_validator/Debug_Element_Builder.h"
+
+ACEXML_Debug_Element_Builder::ACEXML_Debug_Element_Builder ()
+ : type_ (UNDEFINED),
+ root_ (0)
+{
+}
+
+ACEXML_Debug_Element_Builder::~ACEXML_Debug_Element_Builder ()
+{
+ delete this->root_;
+}
+
+int
+ACEXML_Debug_Element_Builder::setElementName (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ this->element_.set (qName, 0);
+ return 0;
+}
+
+int
+ACEXML_Debug_Element_Builder::setContentType (CONTENT_TYPE type ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->type_ == UNDEFINED)
+ {
+ this->type_ = type;
+ return 0;
+ }
+
+ ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("Element type redefinition in Debug_Validator.")), -1);
+}
+
+int
+ACEXML_Debug_Element_Builder::insertMixedElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Element_Tree_Name_Node *node;
+
+ // @@ We should "throw" an exception here instead of returning -1.
+ ACE_NEW_RETURN (node,
+ ACEXML_Element_Tree_Name_Node (qName),
+ -1);
+
+ if (this->root_ == 0)
+ // @@ Memory leak if fail?
+ ACE_NEW_RETURN (this->root_,
+ ACEXML_Element_Tree_List_Node (),
+ -1);
+
+
+ return this->root_->insert (node);
+}
+
+int
+ACEXML_Debug_Element_Builder::startChildGroup ()
+{
+ ACEXML_Element_Tree_List_Node *lnode;
+
+ ACE_NEW_RETURN (lnode,
+ ACEXML_Element_Tree_List_Node (),
+ -1);
+
+ if (this->root_ == 0)
+ {
+ this->root_ = lnode;
+ }
+ else
+ {
+ // @@ check error?
+ this->root_->insert (lnode);
+ }
+
+ this->active_list_.push (lnode);
+ return 0;
+}
+
+int
+ACEXML_Debug_Element_Builder::endChildGroup (CARDINALITY ACEXML_ENV_ARG_DECL_NOT_USED)
+{
+ this->active_list_.pop ();
+ return 0;
+}
+
+int
+ACEXML_Debug_Element_Builder::setChoice ()
+{
+ this->active_list_.top ()->set (ACEXML_Element_Tree_List_Node::CHOICE);
+ return 0;
+}
+
+int
+ACEXML_Debug_Element_Builder::setSequence ()
+{
+ this->active_list_.top ()->set (ACEXML_Element_Tree_List_Node::SEQUENCE);
+ return 0;
+}
+
+int
+ACEXML_Debug_Element_Builder::insertElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Element_Tree_Name_Node *node;
+
+ // @@ We should "throw" an exception here instead of returning -1.
+ ACE_NEW_RETURN (node,
+ ACEXML_Element_Tree_Name_Node (qName),
+ -1);
+
+ return this->active_list_.top ()->insert (node);
+}
+
+void
+ACEXML_Debug_Element_Builder::dump ()
+{
+ cout << "<!ELEMENT " << this->element_;
+
+ // @@ Also dump element contentspec here.
+ switch (this->type_)
+ {
+ case EMPTY:
+ cout << "EMPTY";
+ break;
+ case ANY:
+ cout << "ANY";
+ break;
+ case MIXED:
+ case CHILDREN:
+ // @@ Dump the content of this->root_
+ cout << "*** not implemented ***";
+ break;
+ default:
+ cout << "*** Unidentified element type ***";
+ break;
+ }
+
+ cout << ">" << endl;
+}
diff --git a/ACE/ACEXML/parser/debug_validator/Debug_Element_Builder.h b/ACE/ACEXML/parser/debug_validator/Debug_Element_Builder.h
new file mode 100644
index 00000000000..79443b276ea
--- /dev/null
+++ b/ACE/ACEXML/parser/debug_validator/Debug_Element_Builder.h
@@ -0,0 +1,127 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Debug_Element_Builder.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_DEBUG_ELEMENT_BUILDER_H_
+#define _ACEXML_DEBUG_ELEMENT_BUILDER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Element_Def_Builder.h"
+#include "ACEXML/parser/debug_validator/Element_Tree.h"
+
+/**
+ * @class ACEXML_Debug_Element_Builder Debug_Element_Builder.h "parser/debug_validator/Debug_Element_Builder.h"
+ *
+ * This class prints out the element definition for debugging purpose.
+ *
+ * @todo This class is not namespace-aware.
+ */
+class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Debug_Element_Builder
+ : public ACEXML_Element_Def_Builder
+{
+public:
+ ACEXML_Debug_Element_Builder ();
+
+ virtual ~ACEXML_Debug_Element_Builder ();
+
+ /**
+ * Define the name of the element.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int setElementName (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /**
+ * Define the content type of the element.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int setContentType (CONTENT_TYPE type ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /**
+ * Insert one more element into Mixed definition.
+ */
+ virtual int insertMixedElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /**
+ * Start a new group of children.
+ */
+ virtual int startChildGroup ();
+
+ /**
+ * End a new group of children.
+ *
+ * @retval 0 on success.
+ */
+ virtual int endChildGroup (CARDINALITY card ACEXML_ENV_ARG_DECL);
+
+ /**
+ * Set the type of current child group to Choice.
+ *
+ * @retval 0 on success, -1 if the type of the child group has
+ * already been set and this action conflicts with the previous
+ * setting.
+ */
+ virtual int setChoice ();
+
+ /**
+ * Set the type of current child group to Sequence.
+ *
+ * @retval 0 on success, -1 if the type of the child group has
+ * already been set and this action conflicts with the previous
+ * setting.
+ */
+ virtual int setSequence ();
+
+ /**
+ * Insert an new element into the current child group.
+ *
+ * @retval 0 on success, -1 otherwise.
+ */
+ virtual int insertElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /**
+ * Dump the content of the attribute definition.
+ */
+ virtual void dump (void);
+private:
+ CONTENT_TYPE type_;
+
+ ACEXML_String element_;
+
+ ACEXML_Element_Tree_List_Node *root_;
+
+ ACEXML_Element_Tree_List_Stack active_list_;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_DEBUG_ELEMENT_BUILDER_H_ */
diff --git a/ACE/ACEXML/parser/debug_validator/Element_Tree.cpp b/ACE/ACEXML/parser/debug_validator/Element_Tree.cpp
new file mode 100644
index 00000000000..e9275061b52
--- /dev/null
+++ b/ACE/ACEXML/parser/debug_validator/Element_Tree.cpp
@@ -0,0 +1,72 @@
+// $Id$
+
+#include "ACEXML/parser/debug_validator/Element_Tree.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/parser/debug_validator/Element_Tree.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_Element_Tree_Node::~ACEXML_Element_Tree_Node ()
+{
+ delete this->next_;
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACEXML_Element_Tree_Node)
+
+void
+ACEXML_Element_Tree_Name_Node::dump ()
+{
+ cout << this->name_;
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACEXML_Element_Tree_Name_Node)
+
+ACEXML_Element_Tree_List_Node::~ACEXML_Element_Tree_List_Node (void)
+{
+ delete this->head_;
+}
+
+int
+ACEXML_Element_Tree_List_Node::insert (ACEXML_Element_Tree_Node *node)
+{
+ if (this->head_ == 0)
+ {
+ this->tail_ = this->head_ = node;
+ }
+ else
+ {
+ this->tail_->next (node);
+ this->tail_ = node;
+ }
+ return 0;
+}
+
+void
+ACEXML_Element_Tree_List_Node::dump (void)
+{
+ ACEXML_Element_Tree_Node *ptr = this->head_;
+ const ACEXML_Char *separator = (this->type_ == SEQUENCE) ? ACE_TEXT(" , ") : ACE_TEXT(" | ");
+
+ cout << "(";
+
+ if (ptr != 0)
+ {
+ ptr->dump ();
+ ptr = ptr->next ();
+
+ while (ptr != 0)
+ {
+ cout << separator;
+ ptr->dump ();
+ ptr->next ();
+ }
+ }
+
+ cout << ")";
+}
+
+ACE_ALLOC_HOOK_DEFINE (ACEXML_Element_Tree_List_Node)
+
+
+
+ACE_ALLOC_HOOK_DEFINE (ACEXML_Element_Tree_List_Stack)
diff --git a/ACE/ACEXML/parser/debug_validator/Element_Tree.h b/ACE/ACEXML/parser/debug_validator/Element_Tree.h
new file mode 100644
index 00000000000..a4efdbf1318
--- /dev/null
+++ b/ACE/ACEXML/parser/debug_validator/Element_Tree.h
@@ -0,0 +1,160 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Element_Tree.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_ELEMENT_TREE_H_
+#define _ACEXML_ELEMENT_TREE_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+
+/**
+ * @class ACEXML_Element_Tree_Node Element_Tree.h "parser/debug_validator/Element_Tree.h"
+ *
+ * @brief An abstract base class for describing DTD child element definition.
+ *
+ * @sa ACEXML_Element_Tree_Name_Node, ACEXML_Element_Tree_List_Node
+ */
+class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Element_Tree_Node
+{
+public:
+
+ /// Default constructor.
+ ACEXML_Element_Tree_Node ();
+
+ /// Destructor
+ virtual ~ACEXML_Element_Tree_Node ();
+
+ /// Accessor for next element in chain
+ ACEXML_Element_Tree_Node *next ();
+ void next (ACEXML_Element_Tree_Node *n);
+
+ /// Displaying the content.
+ virtual void dump () = 0;
+
+ ACE_ALLOC_HOOK_DECLARE;
+
+protected:
+ ACEXML_Element_Tree_Node *next_;
+};
+
+/**
+ * @class ACEXML_Element_Tree_Name_Node Element_Tree.h "parser/debug_validator/Element_Tree.h"
+ *
+ * @brief An abstract base class for describing a name node in a DTD child
+ * element definition.
+ *
+ * @sa ACEXML_Element_Tree_Node, ACEXML_Element_Tree_List_Node
+ */
+class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Element_Tree_Name_Node
+ : public ACEXML_Element_Tree_Node
+{
+public:
+ /// Constructor.
+ ACEXML_Element_Tree_Name_Node (const ACEXML_Char *name,
+ int release = 1);
+
+ /// Change the name of this node.
+ void set (const ACEXML_Char *name,
+ int release = 1);
+
+ virtual void dump ();
+
+ ACE_ALLOC_HOOK_DECLARE;
+protected:
+ ACEXML_String name_;
+};
+
+class ACEXML_Element_Tree_List_Stack;
+
+/**
+ * @class ACEXML_Element_Tree_List_Node Element_Tree.h "parser/debug_validator/Element_Tree.h"
+ *
+ * @brief An abstract base class for describing a node list in a DTD child
+ * element definition.
+ *
+ * @sa ACEXML_Element_Tree_Node, ACEXML_Element_Tree_Name_Node
+ */
+class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Element_Tree_List_Node
+ : public ACEXML_Element_Tree_Node
+{
+public:
+ friend class ACEXML_Element_Tree_List_Stack;
+
+ typedef enum {
+ SEQUENCE,
+ CHOICE
+ } LIST_TYPE;
+
+ /// Default constructor.
+ ACEXML_Element_Tree_List_Node (void);
+
+ /// Destructor.
+ virtual ~ACEXML_Element_Tree_List_Node (void);
+
+ /// Insert a new ACEXML_Element_Tree_Node into the list.
+ int insert (ACEXML_Element_Tree_Node *node);
+
+ /// Get/set the type of list.
+ LIST_TYPE get (void);
+ int set (LIST_TYPE type);
+
+ virtual void dump ();
+
+ ACE_ALLOC_HOOK_DECLARE;
+protected:
+ LIST_TYPE type_;
+
+ ACEXML_Element_Tree_Node *head_;
+
+ ACEXML_Element_Tree_Node *tail_;
+
+ ACEXML_Element_Tree_List_Node *pop_next_;
+};
+
+/**
+ * @class ACEXML_Element_Tree_List_Stack Element_Tree.h "parser/debug_validator/Element_Tree.h"
+ *
+ * @brief A class for managing a stack of ACEXML_Element_Tree_List_Node's.
+ *
+ * @sa ACEXML_Element_Tree_List_Node
+ */
+class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Element_Tree_List_Stack
+{
+public:
+ ACEXML_Element_Tree_List_Stack ();
+
+ void push (ACEXML_Element_Tree_List_Node *n);
+
+ ACEXML_Element_Tree_List_Node *pop (void);
+
+ ACEXML_Element_Tree_List_Node *top (void);
+
+ int empty (void);
+
+ ACE_ALLOC_HOOK_DECLARE;
+
+protected:
+ ACEXML_Element_Tree_List_Node *top_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/parser/debug_validator/Element_Tree.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ELEMENT_TREE_H_ */
diff --git a/ACE/ACEXML/parser/debug_validator/Element_Tree.i b/ACE/ACEXML/parser/debug_validator/Element_Tree.i
new file mode 100644
index 00000000000..4b408835403
--- /dev/null
+++ b/ACE/ACEXML/parser/debug_validator/Element_Tree.i
@@ -0,0 +1,92 @@
+// $Id$
+
+ACEXML_INLINE
+ACEXML_Element_Tree_Node::ACEXML_Element_Tree_Node ()
+ : next_ (0)
+{
+}
+
+ACEXML_INLINE ACEXML_Element_Tree_Node *
+ACEXML_Element_Tree_Node::next ()
+{
+ return this->next_;
+}
+
+ACEXML_INLINE void
+ACEXML_Element_Tree_Node::next (ACEXML_Element_Tree_Node * n)
+{
+ this->next_ = n;
+}
+
+ACEXML_INLINE
+ACEXML_Element_Tree_Name_Node::ACEXML_Element_Tree_Name_Node (const ACEXML_Char *name,
+ int release)
+ : name_ (name, 0, release)
+{
+}
+
+ACEXML_INLINE void
+ACEXML_Element_Tree_Name_Node::set (const ACEXML_Char *name,
+ int release)
+{
+ this->name_.set (name, release);
+}
+
+ACEXML_INLINE
+ACEXML_Element_Tree_List_Node::ACEXML_Element_Tree_List_Node (void)
+ : type_ (SEQUENCE),
+ head_ (0),
+ tail_ (0),
+ pop_next_ (0)
+{
+}
+
+ACEXML_INLINE ACEXML_Element_Tree_List_Node::LIST_TYPE
+ACEXML_Element_Tree_List_Node::get (void)
+{
+ return this->type_;
+}
+
+ACEXML_INLINE int
+ACEXML_Element_Tree_List_Node::set (ACEXML_Element_Tree_List_Node::LIST_TYPE type)
+{
+ this->type_ = type;
+ return 0;
+}
+
+ACEXML_INLINE
+ACEXML_Element_Tree_List_Stack::ACEXML_Element_Tree_List_Stack (void)
+ : top_ (0)
+{
+}
+
+ACEXML_INLINE ACEXML_Element_Tree_List_Node *
+ACEXML_Element_Tree_List_Stack::top ()
+{
+ return this->top_;
+}
+
+ACEXML_INLINE void
+ACEXML_Element_Tree_List_Stack::push (ACEXML_Element_Tree_List_Node *n)
+{
+ n->pop_next_ = this->top_;
+ this->top_ = n;
+}
+
+ACEXML_INLINE ACEXML_Element_Tree_List_Node *
+ACEXML_Element_Tree_List_Stack::pop ()
+{
+ if (this->top_ != 0)
+ {
+ ACEXML_Element_Tree_List_Node *ptr = this->top_;
+ this->top_ = this->top_->pop_next_;
+ return ptr;
+ }
+ return 0;
+}
+
+ACEXML_INLINE int
+ACEXML_Element_Tree_List_Stack::empty ()
+{
+ return this->top_ == 0;
+}
diff --git a/ACE/ACEXML/parser/parser/ACEXML_Parser.pc.in b/ACE/ACEXML/parser/parser/ACEXML_Parser.pc.in
new file mode 100644
index 00000000000..61fb0d02374
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/ACEXML_Parser.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ACEXML_Parser
+Description: ACE XML Parser Library
+Requires: ACEXML
+Version: @VERSION@
+Libs: -L${libdir} -lACEXML_Parser
+Cflags: -I${includedir}
diff --git a/ACE/ACEXML/parser/parser/Entity_Manager.cpp b/ACE/ACEXML/parser/parser/Entity_Manager.cpp
new file mode 100644
index 00000000000..cbc20c00fec
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/Entity_Manager.cpp
@@ -0,0 +1,20 @@
+// $Id$
+
+#include "ACEXML/parser/parser/Entity_Manager.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/parser/parser/Entity_Manager.i"
+#endif /* __ACEXML_INLINE__ */
+
+
+ACEXML_Entity_Manager::ACEXML_Entity_Manager (void)
+ : entities_ (0)
+{
+
+}
+
+ACEXML_Entity_Manager::~ACEXML_Entity_Manager (void)
+{
+ this->reset();
+}
+
diff --git a/ACE/ACEXML/parser/parser/Entity_Manager.h b/ACE/ACEXML/parser/parser/Entity_Manager.h
new file mode 100644
index 00000000000..9e264bf8d5e
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/Entity_Manager.h
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Entity_Manager.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef ACEXML_ENTITY_MANAGER_H
+#define ACEXML_ENTITY_MANAGER_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 */
+
+#include "ACEXML/common/XML_Types.h"
+#include "ace/Hash_Map_Manager.h"
+#include "ace/Null_Mutex.h"
+
+typedef ACE_Hash_Map_Entry<ACEXML_String,
+ ACEXML_String> ACEXML_ENTITY_ENTRY;
+
+typedef ACE_Hash_Map_Manager_Ex<ACEXML_String,
+ ACEXML_String,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_ENTITIES_MANAGER;
+
+typedef ACE_Hash_Map_Iterator_Ex<ACEXML_String,
+ ACEXML_String,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_ENTITIES_MANAGER_ITER;
+
+typedef ACE_Hash_Map_Reverse_Iterator_Ex<ACEXML_String,
+ ACEXML_String,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_ENTITIES_MANAGER_REVERSE_ITER;
+
+typedef ACE_Hash_Map_Bucket_Iterator<ACEXML_String,
+ ACEXML_String,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_ENTITY_ENTRY_ITERATOR;
+
+/**
+ * @class ACEXML_Entity_Manager Entity_Manager.h "ACEXML/parser/parser/Entity_Manager.h"
+ *
+ * @brief Class to manage and resolve entity references.
+ *
+ * @todo Fill in details for this class.
+ */
+class ACEXML_PARSER_Export ACEXML_Entity_Manager
+{
+public:
+ /// Default constructor.
+ ACEXML_Entity_Manager (void);
+
+ /// Destructor.
+ ~ACEXML_Entity_Manager (void);
+
+ /// Add a new entity declaration.
+ int add_entity (const ACEXML_Char *ref, const ACEXML_Char *value);
+
+ /// Resolve an entity reference.
+ const ACEXML_Char* resolve_entity (const ACEXML_Char *ref);
+
+ /// Resolve an entity reference and return the tuple of @c systemId and
+ /// @c publicId
+ int resolve_entity (const ACEXML_Char* ref, ACEXML_Char*& systemId,
+ ACEXML_Char*& publicId);
+
+ /// Number of items in the Entity Manager
+ size_t size(void) const;
+
+ /// Reset the state
+ int reset (void);
+
+private:
+ ACEXML_ENTITIES_MANAGER* entities_;
+ bool init_;
+
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/parser/parser/Entity_Manager.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* ACEXML_ENTITY_MANAGER_H */
diff --git a/ACE/ACEXML/parser/parser/Entity_Manager.i b/ACE/ACEXML/parser/parser/Entity_Manager.i
new file mode 100644
index 00000000000..05b258e980e
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/Entity_Manager.i
@@ -0,0 +1,66 @@
+// $Id$
+
+ACEXML_INLINE int
+ACEXML_Entity_Manager::add_entity (const ACEXML_Char *ref,
+ const ACEXML_Char *v)
+{
+ if (!this->entities_ )
+ ACE_NEW_RETURN (this->entities_, ACEXML_ENTITIES_MANAGER, -1);
+ ACEXML_String name (ref, 0, 0);
+ ACEXML_String value (v, 0, 0);
+ return this->entities_->bind (name, value);
+}
+
+ACEXML_INLINE const ACEXML_Char*
+ACEXML_Entity_Manager::resolve_entity (const ACEXML_Char *ref)
+{
+ if (!this->entities_)
+ return 0;
+
+ ACEXML_ENTITY_ENTRY *entry = 0;
+
+ if (this->entities_->find (ACEXML_String (ref, 0, 0),
+ entry) == 0)
+ return entry->int_id_.c_str();
+ return 0;
+}
+
+ACEXML_INLINE int
+ACEXML_Entity_Manager::resolve_entity (const ACEXML_Char* ref,
+ ACEXML_Char*& systemId,
+ ACEXML_Char*& publicId)
+{
+ if (!this->entities_)
+ return 0;
+
+ publicId = systemId = 0;
+ ACEXML_ENTITY_ENTRY_ITERATOR iter (*this->entities_, ref);
+ ACEXML_ENTITY_ENTRY_ITERATOR end (*this->entities_, ref, 1);
+
+ if (iter != end)
+ {
+ systemId = const_cast<ACEXML_Char*> ((*iter).int_id_.c_str());
+ ++iter;
+ if (iter != end)
+ publicId = const_cast<ACEXML_Char*> ((*iter).int_id_.c_str());
+ return 0;
+ }
+ return -1;
+}
+
+ACEXML_INLINE int
+ACEXML_Entity_Manager::reset (void)
+{
+ delete this->entities_;
+ this->entities_ = 0;
+ return 0;
+}
+
+
+ACEXML_INLINE size_t
+ACEXML_Entity_Manager::size (void) const
+{
+ if (!this->entities_)
+ return 0;
+ return this->entities_->current_size();
+}
diff --git a/ACE/ACEXML/parser/parser/Makefile.am b/ACE/ACEXML/parser/parser/Makefile.am
new file mode 100644
index 00000000000..10347078b5a
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/Makefile.am
@@ -0,0 +1,73 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+includedir = @includedir@/ACEXML/parser/parser
+pkgconfigdir = @libdir@/pkgconfig
+
+ACE_BUILDDIR = $(top_builddir)
+ACE_ROOT = $(top_srcdir)
+
+
+## Makefile.ACEXML_Parser.am
+
+if !BUILD_ACE_FOR_TAO
+
+lib_LTLIBRARIES = libACEXML_Parser.la
+
+libACEXML_Parser_la_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -DACEXML_PARSER_BUILD_DLL
+
+libACEXML_Parser_la_SOURCES = \
+ Entity_Manager.cpp \
+ Parser.cpp \
+ ParserContext.cpp \
+ ParserInternals.cpp
+
+libACEXML_Parser_la_LDFLAGS = \
+ -release @ACE_VERSION_NAME@
+
+libACEXML_Parser_la_LIBADD = \
+ $(ACE_BUILDDIR)/ACEXML/common/libACEXML.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+nobase_include_HEADERS = \
+ Entity_Manager.h \
+ Entity_Manager.i \
+ Parser.h \
+ Parser.i \
+ ParserContext.h \
+ ParserContext.inl \
+ ParserInternals.h \
+ Parser_export.h
+
+pkgconfig_DATA = \
+ ACEXML_Parser.pc
+
+CLEANFILES = \
+ ACEXML_Parser.pc
+
+ACEXML_Parser.pc: ${top_builddir}/config.status ${srcdir}/ACEXML_Parser.pc.in
+ ${top_builddir}/config.status --file "$@":${srcdir}/ACEXML_Parser.pc.in
+
+endif !BUILD_ACE_FOR_TAO
+
+EXTRA_DIST = \
+ ACEXML_Parser.pc.in
+
+
+## Clean up template repositories, etc.
+clean-local:
+ -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.*
+ -rm -f gcctemp.c gcctemp so_locations *.ics
+ -rm -rf cxx_repository ptrepository ti_files
+ -rm -rf templateregistry ir.out
+ -rm -rf ptrepository SunWS_cache Templates.DB
diff --git a/ACE/ACEXML/parser/parser/Parser.cpp b/ACE/ACEXML/parser/parser/Parser.cpp
new file mode 100644
index 00000000000..8aed213da69
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/Parser.cpp
@@ -0,0 +1,3397 @@
+// $Id$
+
+#include "ACEXML/parser/parser/Parser.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/parser/parser/Parser.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include "ace/ACE.h"
+#include "ACEXML/common/Transcode.h"
+#include "ACEXML/common/AttributesImpl.h"
+#include "ACEXML/common/StrCharStream.h"
+#include "ACEXML/common/StreamFactory.h"
+#include "ACEXML/parser/parser/ParserInternals.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_strings.h"
+
+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_[] = ACE_TEXT ("Simple");
+
+const ACEXML_Char
+ACEXML_Parser::namespaces_feature_[] = ACE_TEXT ("http://xml.org/sax/features/namespaces");
+
+const ACEXML_Char
+ACEXML_Parser::namespace_prefixes_feature_[] = ACE_TEXT ("http://xml.org/sax/features/namespace-prefixes");
+
+const ACEXML_Char
+ACEXML_Parser::validation_feature_[] = ACE_TEXT ("http://xml.org/sax/features/validation");
+
+ACEXML_Parser::ACEXML_Parser (void)
+ : dtd_handler_ (0),
+ entity_resolver_ (0),
+ content_handler_ (0),
+ error_handler_ (0),
+ doctype_ (0),
+ current_ (0),
+ alt_stack_ (MAXPATHLEN),
+ nested_namespace_ (0),
+ ref_state_ (ACEXML_ParserInt::INVALID),
+ external_subset_ (0),
+ external_entity_ (0),
+ has_pe_refs_ (0),
+ standalone_ (0),
+ external_dtd_ (0),
+ internal_dtd_ (0),
+ simple_parsing_ (0),
+ validate_ (1),
+ namespaces_(1),
+ namespace_prefixes_ (0)
+{
+}
+
+ACEXML_Parser::~ACEXML_Parser (void)
+{
+
+}
+
+int
+ACEXML_Parser::initialize(ACEXML_InputSource* input)
+{
+ // Initialize namespace support
+ if (this->xml_namespace_.init() == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Error initializing namespace support\n")));
+ return -1;
+ }
+ for (int i = 0; i < 5; ++i)
+ {
+ if (this->predef_entities_.add_entity (ACEXML_ParserInt::predef_ent_[i],
+ ACEXML_ParserInt::predef_val_[i])
+ != 0)
+ {
+ ACE_ERROR ((LM_DEBUG,
+ ACE_TEXT ("Error adding entity %s to Manager\n"),
+ ACEXML_ParserInt::predef_ent_[i]));
+ return -1;
+ }
+ }
+ return this->switch_input (input, input->getSystemId());
+}
+
+void
+ACEXML_Parser::parse (const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_InputSource* input = 0;
+ ACE_NEW (input, ACEXML_InputSource (systemId));
+ this->parse (input ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_Parser::parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (input == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid input source")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+ if (this->content_handler_ == 0)
+ {
+ this->fatal_error (ACE_TEXT ("No content handlers defined. Exiting..")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+
+ if (this->validate_ && this->dtd_handler_ == 0)
+ {
+ this->fatal_error (ACE_TEXT ("No DTD handlers defined. Exiting..")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+
+
+ if (this->initialize(input) == -1)
+ {
+ this->fatal_error (ACE_TEXT ("Failed to initialize parser state")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+ // Set up Locator.
+ this->content_handler_->setDocumentLocator (this->current_->getLocator());
+
+ int xmldecl_defined = 0;
+ ACEXML_Char fwd = this->get(); // Consume '<'
+ if (fwd == '<' && this->peek() == '?')
+ {
+ this->get(); // Consume '?'
+ fwd = this->peek();
+ if (fwd == 'x' && !xmldecl_defined)
+ {
+ this->parse_xml_decl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK;
+ xmldecl_defined = 1;
+ }
+ }
+ // We need a XMLDecl in a Valid XML document
+ if (this->validate_ && !xmldecl_defined)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting an XMLDecl at the beginning of")
+ ACE_TEXT (" a valid document")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+ this->content_handler_->startDocument (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK;
+
+ int doctype_defined = 0;
+ for (int prolog_done = 0; prolog_done == 0; )
+ {
+ // Expect a '<' only if we have encountered a XMLDecl, or we are
+ // looping through Misc blocks.
+ if (xmldecl_defined)
+ {
+ if (this->skip_whitespace () != '<')
+ {
+ this->fatal_error (ACE_TEXT ("Expecting '<' at the beginning of ")
+ ACE_TEXT ("Misc section")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+ fwd = this->peek();
+ }
+ switch (fwd)
+ {
+ case '?':
+ this->get();
+ this->parse_processing_instruction (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK;
+ xmldecl_defined = 1;
+ break;
+ case '!':
+ this->get();
+ fwd = this->peek ();
+ if (fwd == 'D' && !doctype_defined) // DOCTYPE
+ {
+ // This will also take care of the trailing MISC block if any.
+ this->parse_doctypedecl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK;
+ doctype_defined = 1;
+ // Now that we have a DOCTYPE Decl defined, we shouldn't
+ // accept XML Decl any longer
+ xmldecl_defined = 1;
+ }
+ else if (fwd == 'D')
+ {
+ this->fatal_error (ACE_TEXT ("Duplicate DOCTYPE declaration")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+ else if (fwd == '-') // COMMENT
+ {
+ if (this->parse_comment () < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid comment in document")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+ xmldecl_defined = 1;
+ }
+ break;
+ case 0:
+ this->fatal_error (ACE_TEXT ("Unexpected end-of-file")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ default: // Root element begins
+ prolog_done = 1;
+ break;
+ }
+ }
+
+ if (this->validate_ && !doctype_defined)
+ {
+ this->warning (ACE_TEXT ("No doctypeDecl in valid document")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+
+ // Now parse root element.
+ this->parse_element (1 ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+
+ this->content_handler_->endDocument (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK;
+
+ // Reset the parser state
+ this->reset();
+
+}
+
+int
+ACEXML_Parser::parse_doctypedecl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->parse_token (ACE_TEXT ("DOCTYPE")) < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting keyword DOCTYPE in a doctypedecl")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ ACEXML_Char nextch = 0;
+ if (this->skip_whitespace_count (&nextch) == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting a space between DOCTYPE keyword ")
+ ACE_TEXT ("and name") ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ this->doctype_ = this->parse_name ();
+ if (this->doctype_ == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid DOCTYPE name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ int count = this->skip_whitespace_count (&nextch);
+
+ if (nextch == 'S' || nextch == 'P') // ExternalID defined
+ {
+ if (count == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting a space between DOCTYPE")
+ ACE_TEXT ("keyword and name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ this->external_dtd_ = 1;
+ this->parse_external_dtd (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ nextch = this->skip_whitespace ();
+ switch (nextch)
+ {
+ case '[':
+ this->internal_dtd_ = 1; // Internal DTD definition
+ this->parse_internal_dtd (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ case '>': // End of DTD definition
+ // This is an XML document without a doctypedecl.
+ if (this->validate_ && !this->external_dtd_)
+ {
+ this->fatal_error (ACE_TEXT ("No DTD defined")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ return 0;
+ case '0':
+ this->fatal_error (ACE_TEXT ("Unexpected end-of-file")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ default:
+ break;
+ }
+
+ if (this->skip_whitespace() != '>')
+ {
+ this->fatal_error(ACE_TEXT ("Expecting '>' at end of doctypedecl")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ return 0;
+}
+
+int
+ACEXML_Parser::parse_internal_dtd (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ this->ref_state_ = ACEXML_ParserInt::IN_INT_DTD;
+ ACEXML_Char nextch = this->skip_whitespace ();
+ do {
+ switch (nextch)
+ {
+ case '<':
+ nextch = this->get();
+ switch (nextch)
+ {
+ case '!':
+ this->parse_markup_decl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ case '?':
+ this->parse_processing_instruction (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ default:
+ this->fatal_error (ACE_TEXT ("Invalid internal subset")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ }
+ break;
+ case '%':
+ this->has_pe_refs_ = 1;
+ this->parse_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ case ']': // End of internal definitions.
+ return 0;
+ case '&':
+ this->fatal_error (ACE_TEXT ("Invalid Reference in internal DTD")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ case 0:
+ this->pop_context (0 ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ default:
+ this->fatal_error (ACE_TEXT ("Invalid content in internal subset")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ };
+ nextch = this->skip_whitespace ();
+ } while (1);
+
+ ACE_NOTREACHED (return -1);
+}
+
+int
+ACEXML_Parser::parse_external_dtd (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ this->ref_state_ = ACEXML_ParserInt::IN_EXT_DTD;
+ ACEXML_Char* publicId = 0;
+ ACEXML_Char* systemId = 0;
+ if (this->parse_external_id (publicId, systemId
+ ACEXML_ENV_ARG_PARAMETER) != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Error in parsing ExternalID")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (this->validate_)
+ {
+ ACEXML_Char* uri = this->normalize_systemid (systemId);
+ ACE_Auto_Basic_Array_Ptr<ACEXML_Char> cleanup_uri (uri);
+ ACEXML_InputSource* ip = 0;
+ if (this->entity_resolver_)
+ {
+ ip = this->entity_resolver_->resolveEntity (publicId,
+ (uri ? uri : systemId)
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (ip)
+ {
+ if (this->switch_input (ip, (uri ? uri : systemId), publicId) != 0)
+ return -1;
+ }
+ else
+ {
+ ACEXML_StreamFactory factory;
+ ACEXML_CharStream* cstream = factory.create_stream (uri ?
+ uri: systemId);
+ if (!cstream) {
+ this->fatal_error (ACE_TEXT ("Invalid input source")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (this->switch_input (cstream, systemId, publicId) != 0)
+ return -1;
+ }
+ this->parse_external_subset (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ return 0;
+}
+
+
+int
+ACEXML_Parser::parse_external_subset (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ this->ref_state_ = ACEXML_ParserInt::IN_EXT_DTD;
+ this->external_subset_ = 1;
+ int nrelems = 0;
+ ACEXML_Char nextch = this->skip_whitespace();
+ do {
+ switch (nextch)
+ {
+ case '<':
+ nextch = this->get();
+ switch (nextch)
+ {
+ case '!':
+ nextch = this->peek();
+ if (nextch == '[')
+ this->parse_conditional_section (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ else
+ this->parse_markup_decl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ case '?':
+ nextch = this->peek();
+ if (nextch == 'x')
+ this->parse_text_decl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ else
+ this->parse_processing_instruction (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ default:
+ this->fatal_error (ACE_TEXT ("Invalid content in external DTD")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ case '%':
+ this->parse_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ case 0:
+ nrelems = this->pop_context (0 ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (nrelems == 1)
+ return 0;
+ break;
+ default:
+ this->fatal_error (ACE_TEXT ("Invalid content in external DTD")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ nextch = this->skip_whitespace();
+ } while (1);
+}
+
+int
+ACEXML_Parser::parse_conditional_section (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char ch = this->get ();
+ int include = 0;
+ if (ch != '[')
+ {
+ this->fatal_error(ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ ch = this->skip_whitespace();
+ if (ch == '%')
+ {
+ this->parse_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ ch = this->skip_whitespace();
+ }
+ if (ch == 'I')
+ {
+ ch = this->get();
+ switch (ch)
+ {
+ case 'N':
+ if (this->parse_token (ACE_TEXT ("CLUDE")) < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting keyword INCLUDE in ")
+ ACE_TEXT ("conditionalSect")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ include = 1;
+ break;
+ case 'G':
+ if (this->parse_token (ACE_TEXT ("GNORE")) < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting keyword IGNORE in ")
+ ACE_TEXT ("conditionalSect")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ include = 0;
+ break;
+ default:
+ this->fatal_error (ACE_TEXT ("Invalid conditionalSect")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ ACEXML_Char fwd = '\xFF';
+ this->skip_whitespace_count (&fwd);
+ if (fwd == 0)
+ {
+ this->get(); // Consume the 0
+ this->pop_context (0 ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ }
+ else
+ {
+ this->fatal_error (ACE_TEXT ("Invalid conditionalSect")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (this->skip_whitespace() != '[')
+ {
+ this->fatal_error (ACE_TEXT ("Expecting '[' in conditionalSect")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (include)
+ this->parse_includesect (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ else
+ this->parse_ignoresect (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ return 0;
+}
+
+int
+ACEXML_Parser::parse_ignoresect (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char nextch = this->skip_whitespace();
+ int count = 0;
+ int done = 0;
+ do {
+ switch (nextch)
+ {
+ case '<':
+ if (this->peek() == '!')
+ {
+ this->get();
+ if (this->peek() == '[')
+ {
+ this->get();
+ count++;
+ }
+ }
+ break;
+ case ']':
+ if (this->peek() == ']')
+ {
+ this->get();
+ if (this->peek() == '>')
+ {
+ this->get();
+ if (count)
+ {
+ --count;
+ break;
+ }
+ done = 1;
+ }
+ }
+ break;
+ case 0: // [VC: Proper Conditional Section/PE Nesting]
+ if (count != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Invalid Conditional Section/PE ")
+ ACE_TEXT ("Nesting ")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ default:
+ break;
+ }
+ if (done)
+ break;
+ nextch = this->get();
+ } while (1);
+
+ return 0;
+}
+
+int
+ACEXML_Parser::parse_includesect (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char nextch = this->skip_whitespace();
+ do {
+ switch (nextch)
+ {
+ case '<':
+ nextch = this->get();
+ switch (nextch)
+ {
+ case '!':
+ nextch = this->peek();
+ if (nextch == '[')
+ this->parse_conditional_section (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ else
+ this->parse_markup_decl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ case '?':
+ nextch = this->peek();
+ this->parse_processing_instruction (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ default:
+ this->fatal_error (ACE_TEXT ("Invalid includeSect")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ case '%':
+ this->parse_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ case 0: // [VC: Proper Conditional Section/PE Nesting]
+ this->fatal_error (ACE_TEXT ("Invalid Conditional Section/PE ")
+ ACE_TEXT ("Nesting ")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ case ']':
+ if (this->peek() == ']')
+ {
+ nextch = this->get();
+ if (this->peek() == '>')
+ {
+ nextch = this->get();
+ return 0;
+ }
+ }
+ default:
+ this->fatal_error (ACE_TEXT ("Invalid includeSect")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ nextch = this->skip_whitespace();
+ } while (1);
+}
+
+int
+ACEXML_Parser::parse_markup_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char nextch = this->peek ();
+ switch (nextch)
+ {
+ case 'E': // An ELEMENT or ENTITY decl
+ this->get ();
+ nextch = this->peek ();
+ switch (nextch)
+ {
+ case 'L':
+ this->parse_element_decl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ case 'N':
+ this->parse_entity_decl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ default:
+ this->fatal_error(ACE_TEXT ("Expecting keyword ELEMENT/ENTITY")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+
+ case 'A': // An ATTLIST decl
+ this->parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+
+ case 'N': // A NOTATION decl
+ this->parse_notation_decl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+
+ case '-': // a comment.
+ if (this->parse_comment () < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid comment")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ case 0: // [VC: Proper Declaration/PE Nesting]
+ this->fatal_error (ACE_TEXT ("Unexpected end-of-file")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ default:
+ this->fatal_error (ACE_TEXT ("Invalid markupDecl")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ return 0;
+}
+
+int
+ACEXML_Parser::parse_external_id (ACEXML_Char *&publicId,
+ ACEXML_Char *&systemId
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ publicId = systemId = 0;
+ ACEXML_Char nextch = this->get ();
+ ACEXML_Char fwd = 0;
+ switch (nextch)
+ {
+ case 'S': // External SYSTEM id.
+ if (this->parse_token (ACE_TEXT ("YSTEM")) < 0 ||
+ this->skip_whitespace_count () < 1)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting keyword SYSTEM")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (this->parse_system_literal (systemId) != 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid systemLiteral")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ case 'P': // External PUBLIC id or previously defined PUBLIC id.
+ if (this->parse_token (ACE_TEXT ("UBLIC")) < 0 ||
+ this->skip_whitespace_count () < 1)
+ {
+ this->fatal_error(ACE_TEXT ("Expecing keyword PUBLIC")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (this->parse_pubid_literal (publicId) != 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid PubidLiteral")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ this->skip_whitespace_count(&fwd);
+ if (fwd == '\'' || fwd == '"')
+ {
+ if (this->parse_system_literal (systemId) != 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid systemLiteral")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ }
+ else if (this->ref_state_ != ACEXML_ParserInt::IN_NOTATION)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting systemLiteral after a ")
+ ACE_TEXT ("PUBLIC keyword")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ default:
+ this->fatal_error(ACE_TEXT ("Invalid system/public Literal")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ return 0;
+}
+
+ACEXML_Char*
+ACEXML_Parser::normalize_systemid (const ACEXML_Char* systemId)
+{
+ if (ACE_OS::strstr (systemId, ACE_TEXT("ftp://")) != 0 ||
+ ACE_OS::strstr (systemId, ACE_TEXT ("http://")) != 0 ||
+ ACE_OS::strstr (systemId, ACE_TEXT ("file://")) != 0)
+ return 0;
+ else
+ {
+ ACEXML_Char* normalized_uri = 0;
+ const ACEXML_Char* baseURI = this->current_->getLocator()->getSystemId();
+ ACE_ASSERT (baseURI);
+ const ACEXML_Char* temp = 0;
+ if (ACE_OS::strstr (baseURI, ACE_TEXT ("http://")) != 0)
+ // baseURI is a HTTP URL and systemId is relative. Note that this
+ // is not compliant with RFC2396. Caveat Emptor !
+ temp = ACE_OS::strrchr (baseURI, '/');
+ else
+ // baseURI is a local file and systemId is relative
+ // Unlike the HTTP one, this will work always.
+ temp = ACE_OS::strrchr (baseURI,ACE_DIRECTORY_SEPARATOR_CHAR);
+ if (temp)
+ {
+ size_t pos = temp - baseURI + 1;
+ size_t len = pos + ACE_OS::strlen (systemId) + 1;
+ ACE_NEW_RETURN (normalized_uri, ACEXML_Char[len], 0);
+ ACE_OS::strncpy (normalized_uri, baseURI, pos);
+ ACE_OS::strcpy (normalized_uri + pos, systemId);
+ return normalized_uri;
+ }
+ return 0;
+ }
+}
+
+void
+ACEXML_Parser::parse_element (int is_root ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // Parse STag.
+ const ACEXML_Char *startname = this->parse_name ();
+ if (startname == 0)
+ {
+ this->fatal_error (ACE_TEXT ("Unexpected end-of-file")
+ ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+ if (is_root && this->doctype_ != 0
+ && ACE_OS::strcmp (startname, this->doctype_) != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Root element different from DOCTYPE")
+ ACEXML_ENV_ARG_PARAMETER);
+ return ;
+ }
+ ACEXML_AttributesImpl attributes;
+ ACEXML_Char ch;
+ int ns_flag = 0; // Push only one namespace context onto the stack
+ // if there are multiple namespaces declared.
+
+ const ACEXML_Char* ns_uri = 0;
+ const ACEXML_Char* ns_lname = 0; // namespace URI and localName
+ for (int start_element_done = 0; start_element_done == 0;)
+ {
+ ch = this->skip_whitespace ();
+
+ switch (ch)
+ {
+ case 0:
+ this->fatal_error(ACE_TEXT ("Internal Parser error")
+ ACEXML_ENV_ARG_PARAMETER);
+ return;
+ case '/':
+ if (this->get () != '>')
+ {
+ this->fatal_error(ACE_TEXT ("Expecting '>' at end of element ")
+ ACE_TEXT ("definition")
+ ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+ this->xml_namespace_.processName(startname, ns_uri,
+ ns_lname, 0);
+ this->prefix_mapping (this->xml_namespace_.getPrefix(ns_uri),
+ ns_uri, 1
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ this->content_handler_->startElement(ns_uri, ns_lname,
+ startname, &attributes
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ this->content_handler_->endElement (ns_uri, ns_lname, startname
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ this->prefix_mapping (this->xml_namespace_.getPrefix(ns_uri),
+ ns_uri, 0
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ if (ns_flag)
+ {
+ this->xml_namespace_.popContext ();
+ this->nested_namespace_--;
+ }
+ return;
+ case '>':
+ this->xml_namespace_.processName (startname, ns_uri,
+ ns_lname, 0);
+ this->prefix_mapping (this->xml_namespace_.getPrefix(ns_uri),
+ ns_uri, 1
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ this->content_handler_->startElement(ns_uri, ns_lname, startname,
+ &attributes
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ start_element_done = 1;
+ break;
+ default:
+ ACEXML_Char *attvalue = 0;
+ ACEXML_Char *attname = this->parse_name (ch);
+
+ if (attname == 0 ||
+ this->skip_equal () != 0 ||
+ this->parse_attvalue (attvalue ACEXML_ENV_ARG_PARAMETER) != 0)
+ {
+ this->fatal_error(ACE_TEXT ("Error reading attribute value")
+ ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+
+ // Handling new namespace if any. Notice that the order of
+ // namespace declaration does matter.
+ if (ACE_OS::strncmp (attname, ACE_TEXT("xmlns"), 5) == 0)
+ {
+ if (this->namespaces_)
+ {
+ if (!ns_flag)
+ {
+ this->xml_namespace_.pushContext ();
+ this->nested_namespace_++;
+ ns_flag = 1;
+ }
+
+ ACEXML_Char* name = ACE_OS::strchr (attname, ':');
+ const ACEXML_Char* ns_name = (name == 0)?
+ empty_string:name+1;
+ if (this->xml_namespace_.declarePrefix (ns_name,
+ attvalue) == -1)
+ {
+ this->fatal_error(ACE_TEXT ("Duplicate definition of ")
+ ACE_TEXT ("prefix")
+ ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+ }
+ if (this->namespace_prefixes_)
+ {
+ // Namespace_prefixes_feature_ is required. So add the
+ // xmlns:foo to the list of attributes.
+ if (attributes.addAttribute (ACE_TEXT (""), ACE_TEXT (""),
+ attname,
+ default_attribute_type,
+ attvalue) == -1)
+ {
+ this->fatal_error(ACE_TEXT ("Duplicate attribute ")
+ ACE_TEXT ("definition. Hint: Try ")
+ ACE_TEXT ("setting namespace_prefix")
+ ACE_TEXT ("es feature to 0")
+ ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+ }
+ if (!this->namespaces_ && !this->namespace_prefixes_)
+ {
+ this->fatal_error(ACE_TEXT ("One of namespaces or ")
+ ACE_TEXT ("namespace_prefixes should be")
+ ACE_TEXT (" declared")
+ ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+ }
+ else
+ {
+ const ACEXML_Char *uri, *lName;
+ this->xml_namespace_.processName (attname, uri, lName, 1);
+ if (attributes.addAttribute (uri, lName, attname,
+ default_attribute_type,
+ attvalue) == -1)
+ {
+ this->fatal_error(ACE_TEXT ("Duplicate attribute ")
+ ACE_TEXT ("definition")
+ ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+ }
+ break;
+ }
+ }
+ if (this->parse_content (startname, ns_uri, ns_lname, ns_flag
+ ACEXML_ENV_ARG_PARAMETER) != 0)
+ return;
+}
+
+int
+ACEXML_Parser::parse_content (const ACEXML_Char* startname,
+ const ACEXML_Char*& ns_uri,
+ const ACEXML_Char*& ns_lname, int ns_flag ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char *cdata;
+ size_t cdata_length = 0;
+
+ // Parse element contents.
+ while (1)
+ {
+ ACEXML_Char ch = this->get ();
+ switch (ch)
+ {
+ case 0:
+ this->pop_context (1 ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ 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);
+ ACEXML_CHECK_RETURN (-1);
+ this->obstack_.unwind (cdata);
+ cdata_length = 0;
+ }
+ ch = this->peek();
+ switch (ch)
+ {
+ case '!': // a comment or a CDATA section.
+ this->get (); // consume '!'
+ ch = this->peek ();
+ if (ch == '-') // a comment
+ {
+ if (this->parse_comment () < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid comment in ")
+ ACE_TEXT ("document")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ }
+ else if (ch == '[') // a CDATA section.
+ {
+ this->parse_cdata (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ else
+ {
+ this->fatal_error(ACE_TEXT ("Expecting a CDATA section ")
+ ACE_TEXT ("or a comment section")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ case '?': // a PI.
+ this->get(); // consume the '?'
+ this->parse_processing_instruction
+ (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ case '/': // an ETag.
+ {
+ this->get (); // consume '/'
+ ACEXML_Char* endname = this->parse_name ();
+ if (endname == 0 ||
+ ACE_OS::strcmp (startname, endname) != 0)
+ {
+ this->fatal_error(ACE_TEXT ("Name in ETag doesn't ")
+ ACE_TEXT ("match name in STag")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (this->skip_whitespace () != '>')
+ {
+ this->fatal_error(ACE_TEXT ("Expecting '>' at end ")
+ ACE_TEXT ("of element")
+ ACEXML_ENV_ARG_PARAMETER);
+ return -1;
+ }
+ this->content_handler_->endElement (ns_uri, ns_lname,
+ endname
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ this->prefix_mapping (this->xml_namespace_.getPrefix(ns_uri),
+ ns_uri, 0
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (this->namespaces_ && ns_flag)
+ {
+ if (this->nested_namespace_ >= 1)
+ {
+ this->xml_namespace_.popContext ();
+ this->nested_namespace_--;
+ }
+ }
+ return 0;
+ }
+ default: // a new nested element?
+ this->parse_element (0 ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ }
+ break;
+ case '&':
+ if (this->peek () == '#')
+ {
+ ACEXML_Char buf[7];
+ size_t len = 0;
+ do
+ {
+ len = sizeof (buf);
+ if (this->parse_char_reference (buf, len) != 0)
+ {
+ // [WFC: Legal Character]
+ this->fatal_error (ACE_TEXT ("Invalid CharRef")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ } while (buf[0] == '&' && this->peek() == '#');
+ for (size_t j = 0; j < len; ++j)
+ this->obstack_.grow (buf[j]);
+ cdata_length += len;
+ }
+ else
+ {
+ this->ref_state_ = ACEXML_ParserInt::IN_CONTENT;
+ int length = this->parse_entity_reference(ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (length == 1)
+ cdata_length++;
+ }
+ break;
+ case '\x20': case '\x0D': case '\x0A': case '\x09':
+// if (this->validate_)
+// {
+// // Flush out any non-whitespace characters
+// if (cdata_length != 0)
+// {
+// cdata = this->obstack_.freeze ();
+// this->content_handler_->characters(cdata, 0, cdata_length
+// ACEXML_ENV_ARG_PARAMETER);
+// ACEXML_CHECK_RETURN (-1);
+// this->obstack_.unwind (cdata);
+// cdata_length = 0;
+// }
+// ++cdata_length;
+// this->obstack_.grow (ch);
+// while (1)
+// {
+// ch = this->peek();
+// if (ch == '\x20' || ch == '\x0D' || ch == '\x0A' ||
+// ch == '\x09')
+// {
+// ch = this->get();
+// this->obstack_.grow (ch);
+// continue;
+// }
+// break;
+// }
+// cdata = this->obstack_.freeze ();
+// this->content_handler_->ignorableWhitespace (cdata, 0,
+// cdata_length
+// ACEXML_ENV_ARG_PARAMETER);
+// ACEXML_CHECK_RETURN (-1);
+// this->obstack_.unwind (cdata);
+// cdata_length = 0;
+// break;
+// }
+ // Fall thru...
+ default:
+ ++cdata_length;
+ this->obstack_.grow (ch);
+ }
+ }
+ ACE_NOTREACHED (return 0;)
+}
+
+
+int
+ACEXML_Parser::parse_cdata (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->parse_token (ACE_TEXT ("[CDATA[")) < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting '[CDATA[' at beginning of CDATA ")
+ ACE_TEXT ("section")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ ACEXML_Char ch;
+ int datalen = 0;
+ ACEXML_Char *cdata = 0;
+ while (1)
+ {
+ ch = this->get ();
+ // Anything goes except the sequence "]]>".
+ if (ch == ']' && this->peek() == ']')
+ {
+ 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->obstack_.unwind(cdata);
+ return 0;
+ }
+ this->obstack_.grow (temp);
+ ++datalen;
+ }
+ this->obstack_.grow (ch);
+ ++datalen;
+ };
+ ACE_NOTREACHED (return -1);
+}
+
+
+int
+ACEXML_Parser::parse_entity_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char nextch = 0;
+
+ if ((this->parse_token (ACE_TEXT ("NTITY")) < 0) ||
+ this->skip_whitespace_count (&nextch) == 0)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting keyword ENTITY followed by a ")
+ ACE_TEXT ("space") ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ int is_GEDecl = 1;
+ if (nextch == '%') // This is a PEDecl.
+ {
+ is_GEDecl = 0;
+ this->get (); // consume the '%'
+ if (this->skip_whitespace_count (&nextch) == 0)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting space between % and ")
+ ACE_TEXT ("entity name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ }
+
+ ACEXML_Char *entity_name = this->parse_name ();
+ if (entity_name == 0)
+ {
+ this->fatal_error (ACE_TEXT ("Invalid entity name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ if (this->skip_whitespace_count (&nextch) == 0)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting space between entity name and ")
+ ACE_TEXT ("entityDef")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ int retval = 0;
+ if (nextch == '\'' || nextch == '"')
+ {
+ ACEXML_Char *entity_value = 0;
+ if (this->parse_entity_value (entity_value
+ ACEXML_ENV_ARG_PARAMETER) != 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid EntityValue")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (is_GEDecl)
+ retval = this->internal_GE_.add_entity (entity_name,
+ entity_value);
+ else
+ retval = this->internal_PE_.add_entity (entity_name,
+ entity_value);
+ if (retval < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Internal Parser Error in adding")
+ ACE_TEXT ("Entity to map")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ else if (retval == 1)
+ {
+ this->warning (ACE_TEXT ("Duplicate entity found")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ }
+ else
+ {
+ ACEXML_Char *systemid, *publicid;
+
+ this->parse_external_id (publicid, systemid
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (systemid == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid SystemLiteral")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ this->skip_whitespace_count (&nextch);
+ if (nextch == 'N') // NDATA section followed
+ {
+ if (is_GEDecl == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid NDataDecl in PEDef")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ if ((this->parse_token (ACE_TEXT ("NDATA")) < 0) ||
+ this->skip_whitespace_count (&nextch) == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting keyword NDATA followed ")
+ ACE_TEXT ("by a space") ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ ACEXML_Char *ndata = this->parse_name ();
+ if (this->validate_) // [VC: Notation Declared]
+ {
+ if (!this->notations_.resolve_entity (ndata))
+ {
+ this->fatal_error (ACE_TEXT ("Undeclared Notation name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ this->dtd_handler_->unparsedEntityDecl(entity_name, publicid,
+ systemid, ndata
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ }
+ else
+ {
+ if (is_GEDecl)
+ retval = this->external_GE_.add_entity (entity_name,
+ systemid);
+ else
+ retval = this->external_PE_.add_entity (entity_name,
+ systemid);
+ if (retval < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ else if (retval == 1)
+ this->warning(ACE_TEXT ("Duplicate external entity")
+ ACEXML_ENV_ARG_PARAMETER);
+ if (is_GEDecl)
+ retval = this->external_GE_.add_entity (entity_name,
+ publicid);
+ else
+ retval = this->external_PE_.add_entity (entity_name,
+ publicid);
+ if (retval < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ else if (retval == 1)
+ this->warning (ACE_TEXT ("Duplicate entity definition")
+ ACEXML_ENV_ARG_PARAMETER);
+ }
+ }
+
+ // End of ENTITY definition
+ if (this->skip_whitespace() != '>')
+ {
+ this->fatal_error(ACE_TEXT ("Expecting '>' at end of entityDef")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ return 0;
+}
+
+int
+ACEXML_Parser::parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->parse_token (ACE_TEXT ("ATTLIST")) < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting keyword 'ATTLIST'")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ int count = check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (!count)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting space between ATTLIST and ")
+ ACE_TEXT ("element name") ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ ACEXML_Char *element_name = this->parse_name ();
+ if (element_name == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid element Name in attlistDecl")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ ACEXML_Char fwd = 0;
+ count = this->skip_whitespace_count (&fwd);
+ // Parse AttDef*
+ while (fwd != '>')
+ {
+ if (!this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER)
+ && !count)
+ this->fatal_error(ACE_TEXT ("Expecting space between element ")
+ ACE_TEXT ("name and AttDef")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ this->skip_whitespace_count (&fwd);
+ if (fwd == '>')
+ break;
+
+ count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+
+ this->parse_attname (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+
+ count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (!count)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting space between AttName and ")
+ ACE_TEXT ("AttType") ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ this->parse_atttype (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+
+ count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (!count)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting space between AttType and")
+ ACE_TEXT (" DefaultDecl")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ this->parse_defaultdecl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+
+ count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ this->skip_whitespace_count(&fwd);
+ }
+ this->get (); // consume closing '>'
+ return 0;
+}
+
+
+int
+ACEXML_Parser::check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_DECL)
+{
+ ACEXML_Char fwd = '\xFF';
+ // Skip any leading whitespaces and store the number of such chars skipped
+ int count = this->skip_whitespace_count (&fwd);
+ if (fwd == 0)
+ {
+ this->get(); // Consume the 0
+ this->pop_context (0 ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ fwd = this->peek();
+ }
+ if (fwd == '%')
+ {
+ this->get(); // Consume the %
+ if (this->external_subset_)
+ {
+ this->parse_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ else
+ {
+ this->fatal_error(ACE_TEXT ("Illegal PERef within markupDecl")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ }
+ if (count)
+ {
+ // We have atleast one whitespace. So just skip any more whitespaces
+ // and return the count
+ this->skip_whitespace_count();
+ return count;
+ }
+ return this->skip_whitespace_count();
+}
+
+ACEXML_Char*
+ACEXML_Parser::parse_attname (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // Parse attribute name
+ ACEXML_Char *att_name = this->parse_name ();
+ if (att_name == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid AttName")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (0);
+ }
+ return att_name;
+}
+
+int
+ACEXML_Parser::parse_defaultdecl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)
+ ACEXML_Char nextch = this->peek ();
+ ACEXML_Char *fixed_attr = 0;
+ switch (nextch)
+ {
+ case '#':
+ this->get (); // consume the '#'
+ switch (this->get ())
+ {
+ case 'R':
+ if (this->parse_token (ACE_TEXT ("EQUIRED")) < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting keyword REQUIRED")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ // We now know this attribute is required
+ // @@ Set up the validator as such.
+ break;
+ case 'I':
+ if (this->parse_token (ACE_TEXT ("MPLIED")) < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting keyword IMPLIED")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ // We now know this attribute is implied.
+ // @@ Set up the validator as such.
+ break;
+ case 'F':
+ if (this->parse_token (ACE_TEXT ("IXED")) < 0 ||
+ this->skip_whitespace_count () == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting keyword FIXED")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ // We now know this attribute is fixed.
+ if (this->parse_attvalue (fixed_attr
+ ACEXML_ENV_ARG_PARAMETER) != 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid Default AttValue")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ // @@ set up validator
+ break;
+ default:
+ this->fatal_error (ACE_TEXT ("Invalid DefaultDecl")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ case '\'':
+ case '"':
+ if (this->parse_attvalue (fixed_attr ACEXML_ENV_ARG_PARAMETER) != 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid AttValue")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ // @@ set up validator
+ break;
+ default:
+ this->fatal_error (ACE_TEXT ("Invalid DefaultDecl")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ }
+ return 0;
+}
+
+int
+ACEXML_Parser::parse_tokenized_type (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char ch = this->get();
+ switch (ch)
+ {
+ case 'I':
+ if (this->get () == 'D')
+ {
+ if (this->peek() != 'R' && this->is_whitespace (this->peek()))
+ {
+ // We have successfully identified the type of the
+ // attribute as ID
+ // @@ Set up validator as such.
+ break;
+ }
+ if (this->parse_token (ACE_TEXT ("REF")) == 0)
+ {
+ if (this->peek() != 'S' && this->is_whitespace (this->peek()))
+ {
+ // We have successfully identified the type of
+ // the attribute as IDREF
+ // @@ Set up validator as such.
+ break;
+ }
+ else if (this->peek() == 'S'
+ && this->get() // consume the 'S'
+ && this->is_whitespace (this->peek()))
+ {
+ // We have successfully identified the type of
+ // the attribute as IDREFS
+ // @@ Set up validator as such.
+ break;
+ }
+ }
+ }
+ // Admittedly, this error message is not precise enough
+ this->fatal_error(ACE_TEXT ("Expecting keyword `ID', `IDREF', or")
+ ACE_TEXT ("`IDREFS'") ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ case 'E': // ENTITY or ENTITIES
+ if (this->parse_token (ACE_TEXT ("NTIT")) == 0)
+ {
+ ACEXML_Char nextch = this->get ();
+ if (nextch == 'Y')
+ {
+ // We have successfully identified the type of
+ // the attribute as ENTITY
+ // @@ Set up validator as such.
+ }
+ else if (this->parse_token (ACE_TEXT ("IES")) == 0)
+ {
+ // We have successfully identified the type of
+ // the attribute as ENTITIES
+ // @@ Set up validator as such.
+ }
+ if (this->is_whitespace (this->peek()))
+ {
+ // success
+ break;
+ }
+ }
+ // Admittedly, this error message is not precise enough
+ this->fatal_error(ACE_TEXT ("Expecting keyword `ENTITY', or")
+ ACE_TEXT ("`ENTITIES'") ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ case 'M':
+ if (this->parse_token (ACE_TEXT ("TOKEN")) == 0)
+ {
+ if (this->is_whitespace (this->peek()))
+ {
+ // We have successfully identified the type of
+ // the attribute as NMTOKEN
+ // @@ Set up validator as such.
+ break;
+ }
+ else if (this->peek() == 'S'
+ && this->get()
+ && this->is_whitespace (this->peek()))
+ {
+ // We have successfully identified the type of
+ // the attribute as NMTOKENS
+ // @@ Set up validator as such.
+ break;
+ }
+ }
+ this->fatal_error(ACE_TEXT ("Expecting keyword `NMTOKEN' or `NMTO")
+ ACE_TEXT ("KENS'") ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ default:
+ this->fatal_error (ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ }
+ return 0;
+}
+
+
+/**
+ * AttType ::= StringType | TokenizedType | EnumeratedType
+ * StringType ::= 'CDATA'
+ * TokenizedType ::= 'ID' [VC: ID]
+ * [VC: One ID per Element Type]
+ * [VC: ID Attribute Default]
+ * | 'IDREF' [VC: IDREF]
+ * | 'IDREFS' [VC: IDREF]
+ * | 'ENTITY' [VC: Entity Name]
+ * | 'ENTITIES' [VC: Entity Name]
+ * | 'NMTOKEN' [VC: Name Token]
+ * | 'NMTOKENS'
+ *
+ * EnumeratedType ::= NotationType | Enumeration
+ * NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'
+ * [VC: Notation Attributes]
+ * [VC: One Notation Per Element Type]
+ * [VC: No Notation on Empty Element]
+ * Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'
+ * [VC: Enumeration]
+ */
+int
+ACEXML_Parser::parse_atttype (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char nextch = this->peek();
+ switch (nextch)
+ {
+ case 'C': // CDATA
+ if (this->parse_token (ACE_TEXT ("CDATA")) < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting keyword 'CDATA'")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ // Else, we have successfully identified the type of the
+ // attribute as CDATA
+ // @@ Set up validator appropriately here.
+ break;
+ case 'I': case 'E': // ID, IDREF, IDREFS, ENTITY or ENTITIES
+ this->parse_tokenized_type (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ case 'N': // NMTOKEN, NMTOKENS, or NOTATION
+ this->get();
+ nextch = this->peek();
+ if (nextch != 'M' && nextch != 'O')
+ {
+ this->fatal_error (ACE_TEXT ("Expecting keyword 'NMTOKEN', ")
+ ACE_TEXT ("'NMTOKENS' or 'NOTATION'")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (nextch == 'M')
+ {
+ this->parse_tokenized_type (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ }
+ else // NOTATION
+ {
+ if (this->parse_token (ACE_TEXT ("OTATION")) < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting keyword `NOTATION'")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ int count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (!count)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting space between keyword ")
+ ACE_TEXT ("NOTATION and '('")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (this->get () != '(')
+ {
+ this->fatal_error(ACE_TEXT ("Expecting '(' in NotationType")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ do {
+ this->skip_whitespace_count();
+ ACEXML_Char *notation_name = this->parse_name ();
+ if (notation_name == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid notation name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ // @@ get another notation name, set up validator as such
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ nextch = this->get();
+ } while (nextch == '|');
+ if (nextch != ')')
+ {
+ this->fatal_error (ACE_TEXT ("Expecting a ')' after a ")
+ ACE_TEXT ("NotationType declaration")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ }
+ break;
+ case '(': // EnumeratedType - Enumeration
+ this->get();
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ do {
+ this->skip_whitespace_count();
+ ACEXML_Char *token_name = this->parse_nmtoken ();
+ if (token_name == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid enumeration name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ // @@ get another nmtoken, set up validator as such
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ nextch = this->get();
+ } while (nextch == '|');
+ if (nextch != ')')
+ {
+ this->fatal_error (ACE_TEXT ("Expecting a ')' after a ")
+ ACE_TEXT ("Enumeration declaration")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ default:
+ {
+ this->fatal_error(ACE_TEXT ("Invalid AttType")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ ACE_NOTREACHED (break);
+ }
+ return 0;
+}
+
+int
+ACEXML_Parser::parse_notation_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->parse_token (ACE_TEXT ("NOTATION")) < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting Keyword 'NOTATION'")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ int count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (!count)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting a space between keyword NOTATION")
+ ACE_TEXT (" and notation name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ ACEXML_Char *notation = this->parse_name ();
+ if (notation == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid Notation name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (!count)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting a space between notation name ")
+ ACE_TEXT ("and ExternalID/PublicID")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ ACEXML_Char *systemid, *publicid;
+
+ // Gross hack but otherwise we need to go around a lot of loops to parse,
+ // When the ExternalID starts with 'PUBLIC' we cannot distinguish a
+ // PublicId from a ExternalID by looking using a one character read-ahead
+ ACEXML_ParserInt::ReferenceState temp = this->ref_state_;
+ this->ref_state_ = ACEXML_ParserInt::IN_NOTATION;
+
+ this->parse_external_id (publicid, systemid
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ // Restore the original value.
+ this->ref_state_ = temp;
+
+ // [VC: Unique Notation Name]
+ if (systemid && this->notations_.add_entity (notation, systemid) != 0
+ && this->validate_)
+ {
+ this->fatal_error(ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (publicid)
+ {
+ int retval = this->notations_.add_entity (notation, publicid);
+ if (retval != 0 && !systemid && this->validate_)
+ {
+ this->fatal_error(ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ }
+
+ if (this->skip_whitespace() != '>')
+ {
+ this->fatal_error(ACE_TEXT ("Expecting '>' at end of NotationDecl")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ if (this->validate_ && this->dtd_handler_)
+ {
+ this->dtd_handler_->notationDecl (notation,
+ publicid,
+ systemid ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ return 0;
+}
+
+int
+ACEXML_Parser::parse_element_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->parse_token (ACE_TEXT ("LEMENT")) < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting keyword ELEMENT")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ int count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (!count)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting a space between keyword ELEMENT")
+ ACE_TEXT (" and element name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ ACEXML_Char *element_name = this->parse_name ();
+ if (element_name == 0)
+ {
+ this->fatal_error (ACE_TEXT ("Invalid element name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (!count)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting a space between element name ")
+ ACE_TEXT ("and element definition")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ ACEXML_Char nextch = this->peek();
+ switch (nextch)
+ {
+ case 'E': // EMPTY
+ if (this->parse_token (ACE_TEXT ("EMPTY")) < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting keyword EMPTY")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ case 'A': // ANY
+ if (this->parse_token (ACE_TEXT ("ANY")) < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Expecting keyword ANY")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ case '(': // children
+ this->parse_children_definition (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ default: // error
+ this->fatal_error (ACE_TEXT ("Invalid element definition")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ count = this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (this->skip_whitespace () != '>')
+ {
+ this->fatal_error (ACE_TEXT ("Expecting '>' after element defintion")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ return 0;
+}
+
+
+int
+ACEXML_Parser::parse_children_definition (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ this->get (); // consume the '('
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ int subelement_number = 0;
+ ACEXML_Char nextch = this->peek();
+ switch (nextch)
+ {
+ case '#': // Mixed element,
+ if (this->parse_token (ACE_TEXT ("#PCDATA")) < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting keyword '#PCDATA'")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ nextch = this->get();
+ while (nextch == '|')
+ {
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ ACEXML_Char *name = this->parse_name ();
+ // @@ name will be used in the Validator later.
+ ACE_UNUSED_ARG (name);
+ ++subelement_number;
+ // @@ Install Mixed element name into the validator.
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ nextch = this->skip_whitespace();
+ }
+ if (nextch != ')' ||
+ (subelement_number && this->get () != '*'))
+ {
+ this->fatal_error(ACE_TEXT ("Expecing ')' or ')*' at end of Mixed")
+ ACE_TEXT (" element") ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ // @@ close the element definition in the validator.
+ break;
+ default:
+ int status = this->parse_child (1 ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (status != 0)
+ return -1;
+ }
+
+ // Check for trailing '?', '*', '+'
+ nextch = this->peek ();
+ switch (nextch)
+ {
+ case '?':
+ // @@ Consume the character and inform validator as such,
+ this->get ();
+ break;
+ case '*':
+ // @@ Consume the character and inform validator as such,
+ this->get ();
+ break;
+ case '+':
+ // @@ Consume the character and inform validator as such,
+ this->get ();
+ break;
+ default:
+ break; // not much to do.
+ }
+
+ return 0;
+}
+
+int
+ACEXML_Parser::parse_child (int skip_open_paren ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // Conditionally consume the open paren.
+ if (skip_open_paren == 0 && this->get () != '(')
+ {
+ this->fatal_error(ACE_TEXT ("Expecting '(' at beginning of children")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ ACEXML_Char node_type = 0;
+ ACEXML_Char nextch;
+
+ do {
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ this->skip_whitespace_count (&nextch);
+ switch (nextch)
+ {
+ case '(':
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ this->parse_child (0 ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ default:
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ // must be an element name here.
+ ACEXML_Char *subelement = this->parse_name ();
+ if (subelement == 0)
+ {
+ this->fatal_error(ACE_TEXT ("Invalid subelement name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ // Check for trailing '?', '*', '+'
+ nextch = this->peek ();
+ switch (nextch)
+ {
+ case '?':
+ // @@ Consume the character and inform validator as such,
+ this->get ();
+ break;
+ case '*':
+ // @@ Consume the character and inform validator as such,
+ this->get ();
+ break;
+ case '+':
+ // @@ Consume the character and inform validator as such,
+ this->get ();
+ break;
+ default:
+ break; // not much to do.
+ }
+
+ // @@ Inform validator of the new element here.
+ break;
+ }
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ this->skip_whitespace_count (&nextch);
+ switch (nextch)
+ {
+ case '|':
+ switch (node_type)
+ {
+ case 0:
+ node_type = '|';
+ // @@ inform validator of this new type??
+ break;
+ case '|':
+ break;
+ default:
+ this->fatal_error (ACE_TEXT ("Expecting `,', `|', or `)' ")
+ ACE_TEXT ("while defining an element")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ case ',':
+ switch (node_type)
+ {
+ case 0:
+ node_type = ',';
+ // @@ inform validator of this new type??
+ break;
+ case ',':
+ break;
+ default:
+ this->fatal_error (ACE_TEXT ("Expecting `,', `|', or `)' ")
+ ACE_TEXT ("while defining an element")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ case ')':
+ break;
+ default:
+ this->fatal_error (ACE_TEXT ("Expecting `,', `|', or `)' ")
+ ACE_TEXT ("while defining an element")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ nextch = this->get(); // Consume the `,' or `|' or `)'
+ if (nextch == ')')
+ break;
+ this->check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ this->skip_whitespace_count (&nextch);
+ } while (nextch != ')');
+
+ // Check for trailing '?', '*', '+'
+ nextch = this->peek ();
+ switch (nextch)
+ {
+ case '?':
+ // @@ Consume the character and inform validator as such,
+ this->get ();
+ break;
+ case '*':
+ // @@ Consume the character and inform validator as such,
+ this->get ();
+ break;
+ case '+':
+ // @@ Consume the character and inform validator as such,
+ this->get ();
+ break;
+ default:
+ break; // not much to do.
+ }
+
+
+ return 0;
+}
+
+int
+ACEXML_Parser::parse_char_reference (ACEXML_Char *buf, size_t& len)
+{
+ if (len < 7) // Max size of a CharRef plus terminating '\0'
+ return -1;
+ ACEXML_Char ch = this->get();
+ if (ch != '#') // Internal error.
+ return -1;
+ int hex = 0;
+ ch = this->peek();
+ if (ch == 'x')
+ {
+ hex = 1;
+ this->get ();
+ }
+ size_t i = 0;
+ int more_digit = 0;
+ ch = this->get ();
+ for ( ; i < len &&
+ (this->isNormalDigit (ch) || (hex ? this->isCharRef(ch): 0)); ++i)
+ {
+ buf[i] = ch;
+ ch = this->get();
+ ++more_digit;
+ }
+ if (ch != ';' || !more_digit)
+ return -1;
+ buf[i] = 0;
+ ACEXML_UCS4 sum = (ACEXML_UCS4) ACE_OS::strtol (buf, 0, (hex ? 16 : 10));
+ // [WFC: Legal Character]
+ if (!this->isChar (sum))
+ return -1;
+ int clen;
+#if defined (ACE_USES_WCHAR)
+# if (ACE_SIZEOF_WCHAR == 2) // UTF-16
+ if ((clen = ACEXML_Transcoder::ucs42utf16 (sum, buf, len)) < 0)
+ return -1;
+# elif (ACE_SIZEOF_WCHAR == 4) // UCS 4
+ buf [0] = sum;
+ buf [1] = 0;
+ clen = 2;
+# endif /* ACE_SIZEOF_WCHAR */
+
+#else // or UTF-8
+ if ((clen = ACEXML_Transcoder::ucs42utf8 (sum, buf, len)) < 0)
+ return -1;
+#endif
+ buf [clen] = 0;
+ len = clen;
+ return 0;
+}
+
+ACEXML_Char*
+ACEXML_Parser::parse_reference_name (void)
+{
+ ACEXML_Char ch = this->get ();
+ if (!this->isLetter (ch) && (ch != '_' || ch != ':'))
+ return 0;
+ while (ch) {
+ this->alt_stack_.grow (ch);
+ ch = this->peek ();
+ if (!this->isNameChar (ch))
+ break;
+ ch = this->get ();
+ };
+ if (ch != ';')
+ return 0;
+ ch = this->get();
+ return this->alt_stack_.freeze ();
+}
+
+int
+ACEXML_Parser::parse_attvalue (ACEXML_Char *&str ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char quote = this->get ();
+ if (quote != '\'' && quote != '"') // Not a quoted string.
+ return -1;
+ ACEXML_Char ch = this->get ();
+ while (1)
+ {
+ if (ch == quote)
+ {
+ ACEXML_Char* temp = this->obstack_.freeze ();
+ // If the attribute type is not CDATA, then the XML processor
+ // must further process the normalized attribute value by
+ // discarding any leading and trailing space (#x20) characters,
+ // and by replacing sequences of space (#x20) characters by a
+ // single space (#x20) character.
+
+ // if (atttype != CDATA) {
+ // ACEXML_Char* start = temp;
+ // ACEXML_Char* end = temp + ACE_OS::strlen (temp);
+ // while (*start == '\x20')
+ // start++;
+ // if (start == end) // String which is all spaces
+ // str = start;
+ // while (*start != 0)
+ // {
+ // this->obstack_.grow (*start);
+ // start++;
+ // while (*start == '\x20')
+ // start++;
+ // }
+ // str = this->obstack_.freeze();
+ // }
+ str = temp;
+ return 0;
+ }
+ switch (ch)
+ {
+ case '&':
+ if (this->peek () == '#')
+ {
+ ACEXML_Char buf[7];
+ size_t len = sizeof (buf);
+ if (this->parse_char_reference (buf, len) != 0)
+ {
+ // [WFC: Legal Character]
+ this->fatal_error (ACE_TEXT ("Invalid CharacterRef")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ for (size_t j = 0; j < len; ++j)
+ this->obstack_.grow (buf[j]);
+ }
+ else
+ {
+ this->ref_state_ = ACEXML_ParserInt::IN_ATT_VALUE;
+ this->parse_entity_reference (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ break;
+ case '\x20': case '\x0D': case '\x0A': case '\x09':
+ this->obstack_.grow ('\x20');
+ break;
+ case '<': // [WFC: No < in Attribute Values]
+ this->fatal_error (ACE_TEXT ("Illegal '<' in AttValue")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ case 0:
+ this->pop_context (1 ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ default:
+ this->obstack_.grow (ch);
+ break;
+ }
+ ch = this->get();
+ }
+}
+
+
+
+int
+ACEXML_Parser::parse_entity_reference (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char* replace = this->parse_reference_name ();
+ if (replace == 0)
+ {
+ this->fatal_error (ACE_TEXT ("Invalid Reference name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ // [WFC: Parsed Entity]
+ if (this->unparsed_entities_.resolve_entity (replace)) {
+ this->fatal_error (ACE_TEXT ("EntityRef refers to unparsed entity")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ // Look in the internal general entities set first.
+ const ACEXML_Char* entity = this->internal_GE_.resolve_entity(replace);
+
+ // Look in the predefined entities.
+ if (!entity)
+ {
+ entity = this->predef_entities_.resolve_entity (replace);
+ if (entity)
+ {
+ // Special case to return the length in case of predefined entities
+ this->obstack_.grow (*entity);
+ return 1;
+ }
+ }
+
+ if (!this->validate_)
+ {
+ if (this->standalone_)
+ {
+ // [WFC: Entity Declared]
+ this->fatal_error (ACE_TEXT ("Undeclared Entity reference")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ else
+ {
+ this->content_handler_->skippedEntity (replace
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ return 0;
+ }
+ }
+
+ // No match in internal subset
+ if (!entity
+ // or No DTDs
+ && (!(this->internal_dtd_ || this->external_dtd_)
+ // or Only Internal DTD and no parameter entity references
+ || (this->internal_dtd_ && !this->external_dtd_
+ && !this->has_pe_refs_)
+ // or Standalone = 'yes'
+ || this->standalone_))
+ {
+ // [WFC: Entity Declared]
+ this->fatal_error (ACE_TEXT ("Undeclared Entity reference")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ ACEXML_Char* systemId = 0;
+ ACEXML_Char* publicId = 0;
+ if (!entity)
+ {
+ if (this->external_GE_.resolve_entity (replace, systemId, publicId) < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Undeclared Entity reference")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (this->ref_state_ == ACEXML_ParserInt::IN_ATT_VALUE)
+ {
+ this->fatal_error (ACE_TEXT ("External EntityRef in Attribute Value")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ this->external_entity_++;
+ }
+
+
+ // [WFC: No Recursion]
+ ACEXML_Char* ref_name = replace;
+ int present = this->GE_reference_.insert (ref_name);
+ if (present == 1 || present == -1)
+ {
+ while (this->GE_reference_.pop(ref_name) != -1)
+ ;
+ this->fatal_error (ACE_TEXT ("Recursion in resolving entity")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ if (!this->external_entity_)
+ {
+ ACEXML_StrCharStream* str = 0;
+ ACE_NEW_RETURN (str, ACEXML_StrCharStream, -1);
+ if (str->open (entity, replace) < 0
+ || this->switch_input (str, replace) != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Unable to create internal input ")
+ ACE_TEXT ("stream")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ return 0;
+ }
+ else
+ {
+ ACEXML_Char* uri = this->normalize_systemid (systemId);
+ ACE_Auto_Basic_Array_Ptr<ACEXML_Char> cleanup_uri (uri);
+ ACEXML_InputSource* ip = 0;
+ if (this->entity_resolver_)
+ {
+ ip = this->entity_resolver_->resolveEntity (publicId,
+ (uri ? uri : systemId)
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ if (ip)
+ {
+ if (this->switch_input (ip, (uri ? uri : systemId),
+ publicId) != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ return 0;
+ }
+ }
+ ACEXML_StreamFactory factory;
+ ACEXML_CharStream* cstream = factory.create_stream (uri ? uri: systemId);
+ if (!cstream) {
+ this->fatal_error (ACE_TEXT ("Invalid input source")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (this->switch_input (cstream, systemId, publicId) != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_Parser::parse_PE_reference (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char* replace = this->parse_reference_name ();
+ if (replace == 0)
+ {
+ this->fatal_error (ACE_TEXT ("Invalid PEReference name")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ // Look in the internal general entities set first.
+ const ACEXML_Char* entity = this->internal_PE_.resolve_entity(replace);
+
+ if (!entity && // No match in internal
+ (!this->external_dtd_ || // or No External DTDs
+ this->standalone_)) // or Standalone
+ {
+ // [VC: Entity Declared]
+ this->fatal_error (ACE_TEXT ("Undefined Internal PEReference")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ ACEXML_Char* systemId = 0;
+ ACEXML_Char* publicId = 0;
+ if (!entity && this->validate_)
+ {
+ if (this->external_PE_.resolve_entity (replace, systemId, publicId) < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Undefined PEReference")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ this->external_entity_++;
+ }
+
+ // [WFC: No Recursion]
+ ACEXML_Char* ref_name = replace;
+ int present = this->PE_reference_.insert (ref_name);
+ if (present == 1 || present == -1)
+ {
+ while (this->PE_reference_.pop(ref_name) != -1)
+ ;
+ this->fatal_error (ACE_TEXT ("Recursion in resolving entity")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ if (entity && !this->external_entity_)
+ {
+ ACEXML_StrCharStream* sstream = 0;
+ ACEXML_String str (entity);
+ if (this->ref_state_ != ACEXML_ParserInt::IN_ENTITY_VALUE)
+ {
+ const ACEXML_Char* ch = ACE_TEXT (" ");
+ str = ch + str + ch;
+ }
+ // ACE_DEBUG ((LM_DEBUG,
+ // ACE_TEXT ("Entity is %s\n Replacement Text is : %s\n"),
+ // replace, str.c_str()));
+ ACE_NEW_RETURN (sstream, ACEXML_StrCharStream, -1);
+ if (sstream->open (str.c_str(), replace) < 0
+ || this->switch_input (sstream, replace) != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Error in switching InputSource")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ return 0;
+ }
+ else if (this->external_entity_ && this->validate_)
+ {
+ ACEXML_Char* uri = this->normalize_systemid (systemId);
+ ACE_Auto_Basic_Array_Ptr<ACEXML_Char> cleanup_uri (uri);
+ ACEXML_InputSource* ip = 0;
+ if (this->entity_resolver_)
+ {
+ ip = this->entity_resolver_->resolveEntity (publicId,
+ (uri ? uri : systemId)
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (ip)
+ {
+ if (this->switch_input (ip, (uri ? uri : systemId), publicId) != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Error in switching InputSource")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ return 0;
+ }
+ else
+ {
+ ACEXML_StreamFactory factory;
+ ACEXML_CharStream* cstream = factory.create_stream (uri ? uri: systemId);
+ if (!cstream) {
+ this->fatal_error (ACE_TEXT ("Invalid input source")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (this->switch_input (cstream, systemId, publicId) != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Error in switching InputSource")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ if (this->ref_state_ == ACEXML_ParserInt::IN_ENTITY_VALUE)
+ {
+ ACEXML_Char less, mark;
+ if (this->peek() == '<')
+ {
+ less = this->get();
+ if (this->peek() == '?')
+ {
+ mark = this->get();
+ if (this->peek() == 'x')
+ {
+ this->parse_text_decl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ else
+ {
+ this->obstack_.grow (less);
+ this->obstack_.grow (mark);
+ }
+ }
+ this->obstack_.grow (less);
+ }
+ }
+ return 0;
+ }
+ }
+ this->fatal_error (ACE_TEXT ("Undefined PEReference")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ return -1;
+}
+
+int
+ACEXML_Parser::parse_entity_value (ACEXML_Char *&str
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_ParserInt::ReferenceState temp = this->ref_state_;
+ ACEXML_Char quote = this->get ();
+ if (quote != '\'' && quote != '"') // Not a quoted string.
+ return -1;
+ ACEXML_Char ch = this->get ();
+ while (1)
+ {
+ if (ch == quote)
+ {
+ str = this->obstack_.freeze ();
+ this->ref_state_ = temp;
+ return 0;
+ }
+ switch (ch)
+ {
+ case '&':
+ if (this->peek () == '#')
+ {
+ if (!this->external_entity_)
+ {
+ ACEXML_Char buf[7];
+ size_t len = sizeof (buf);
+ if (this->parse_char_reference (buf, len) != 0)
+ {
+ // [WFC: Legal Character]
+ this->fatal_error (ACE_TEXT ("Invalid character ")
+ ACE_TEXT ("reference")
+ ACEXML_ENV_ARG_PARAMETER);
+ return -1;
+ }
+ for (size_t j = 0; j < len; ++j)
+ this->obstack_.grow (buf[j]);
+ break;
+ }
+ }
+ this->obstack_.grow (ch);
+ break;
+ case '%':
+ if (!this->external_entity_)
+ {
+ this->ref_state_ = ACEXML_ParserInt::IN_ENTITY_VALUE;
+ this->parse_PE_reference(ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ }
+ this->obstack_.grow (ch);
+ break;
+ case 0:
+ this->pop_context (0 ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ break;
+ default:
+ this->obstack_.grow (ch);
+ break;
+ }
+ ch = this->get();
+ }
+}
+
+ACEXML_Char *
+ACEXML_Parser::parse_name (ACEXML_Char ch)
+{
+ if (ch == 0)
+ ch = this->get ();
+ if (!this->isLetter (ch) && ch != '_' && ch != ':')
+ return 0;
+ while (ch) {
+ this->obstack_.grow (ch);
+ ch = this->peek ();
+ if (!this->isNameChar (ch))
+ break;
+ ch = this->get ();
+ };
+ return this->obstack_.freeze ();
+}
+
+ACEXML_Char*
+ACEXML_Parser::parse_nmtoken (ACEXML_Char ch)
+{
+ if (ch == 0)
+ ch = this->get ();
+ if (!this->isNameChar (ch))
+ return 0;
+ while (ch) {
+ this->obstack_.grow (ch);
+ ch = this->peek ();
+ if (!this->isNameChar (ch))
+ break;
+ ch = this->get ();
+ };
+ return this->obstack_.freeze ();
+}
+
+int
+ACEXML_Parser::parse_version_num (ACEXML_Char*& str)
+{
+ ACEXML_Char quote = this->get ();
+ if (quote != '\'' && quote != '"') // Not a quoted string.
+ return -1;
+ int numchars = 0;
+ while (1)
+ {
+ ACEXML_Char ch = this->get ();
+ if (ch == quote && !numchars)
+ return -1;
+ else if (ch == quote)
+ {
+ str = this->obstack_.freeze ();
+ return 0;
+ }
+ // [26] VersionNum ::= ([a-zA-Z0-9_.:] | '-')+
+ if (ch == '-' || ((ch >= 'a' && ch <= 'z') ||
+ (ch >= 'A' && ch <= 'Z') ||
+ (ch >= '0' && ch <= '9') ||
+ (ch == '_' || ch == '.' || ch == ':')))
+ {
+ this->obstack_.grow (ch);
+ numchars++;
+ }
+ else
+ return -1;
+ }
+}
+
+int
+ACEXML_Parser::parse_system_literal (ACEXML_Char*& str)
+{
+ const ACEXML_Char quote = this->get();
+ if (quote != '\'' && quote != '"') // Not a quoted string.
+ return -1;
+ while (1)
+ {
+ ACEXML_Char ch = this->get ();
+ if (ch == quote)
+ {
+ str = this->obstack_.freeze ();
+ return 0;
+ }
+ switch (ch)
+ {
+ case '\x00': case '\x01': case '\x02': case '\x03': case '\x04':
+ case '\x05': case '\x06': case '\x07': case '\x08': case '\x09':
+ case '\x0A': case '\x0B': case '\x0C': case '\x0D': case '\x0E':
+ case '\x0F': case '\x10': case '\x11': case '\x12': case '\x13':
+ case '\x14': case '\x15': case '\x16': case '\x17': case '\x18':
+ case '\x19': case '\x1A': case '\x1B': case '\x1C': case '\x1D':
+ case '\x1E': case '\x1F': case '\x7F': case '\x20': case '<':
+ case '>': case '#': case '%':
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Invalid char %c in SystemLiteral\n"), ch));
+ return -1;
+ default:
+ this->obstack_.grow (ch);
+ }
+ }
+}
+
+int
+ACEXML_Parser::parse_pubid_literal (ACEXML_Char*& str)
+{
+ const ACEXML_Char quote = this->get();
+ if (quote != '\'' && quote != '"') // Not a quoted string.
+ return -1;
+ while (1)
+ {
+ ACEXML_Char ch = this->get ();
+ if (ch == quote)
+ {
+ str = this->obstack_.freeze ();
+ return 0;
+ }
+ else if (this->isPubidChar (ch))
+ this->obstack_.grow (ch);
+ else
+ return -1;
+ }
+}
+
+int
+ACEXML_Parser::parse_encname (ACEXML_Char*& str)
+{
+ const ACEXML_Char quote = this->get ();
+ if (quote != '\'' && quote != '"') // Not a quoted string.
+ return -1;
+ int numchars = 0;
+ while (1)
+ {
+ ACEXML_Char ch = this->get ();
+ if (ch == quote && !numchars)
+ return -1;
+ else if (ch == quote)
+ {
+ str = this->obstack_.freeze ();
+ return 0;
+ }
+ // [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
+ if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
+ && !numchars)
+ return -1;
+ if (ch == '-' || ((ch >= 'a' && ch <= 'z') ||
+ (ch >= 'A' && ch <= 'Z') ||
+ (ch >= '0' && ch <= '9') ||
+ (ch == '_' || ch == '.')))
+ {
+ this->obstack_.grow (ch);
+ numchars++;
+ }
+ else
+ return -1;
+ }
+}
+
+int
+ACEXML_Parser::parse_sddecl (ACEXML_Char*& str)
+{
+ ACEXML_Char quote = this->get ();
+ if (quote != '\'' && quote != '"') // Not a quoted string.
+ return -1;
+ int numchars = 0;
+ while (1)
+ {
+ ACEXML_Char ch = this->get ();
+ if (ch == quote && numchars < 2)
+ return -1;
+ else if (ch == quote)
+ {
+ str = this->obstack_.freeze ();
+ return 0;
+ }
+ // [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'")
+ // | ('"' ('yes' | 'no') '"'))
+ switch (ch)
+ {
+ case 'y': case 'e': case 's': case 'n': case 'o':
+ this->obstack_.grow (ch);
+ numchars++;
+ break;
+ default:
+ return -1;
+ }
+ }
+}
+
+void
+ACEXML_Parser::prefix_mapping (const ACEXML_Char* prefix,
+ const ACEXML_Char* uri,
+ int start ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->namespaces_)
+ {
+ const ACEXML_Char* temp = (prefix == 0) ? empty_string : prefix;
+ if (start) {
+ this->content_handler_->startPrefixMapping (temp, uri
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+ else
+ {
+ this->content_handler_->endPrefixMapping(temp
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+ }
+}
+
+int
+ACEXML_Parser::switch_input (ACEXML_CharStream* cstream,
+ const ACEXML_Char* systemId,
+ const ACEXML_Char* publicId)
+{
+ ACEXML_InputSource* input = 0;
+ ACE_NEW_RETURN (input, ACEXML_InputSource (cstream), -1);
+ return this->switch_input (input, systemId, publicId);
+}
+
+int
+ACEXML_Parser::switch_input (ACEXML_InputSource* input,
+ const ACEXML_Char* systemId,
+ const ACEXML_Char* publicId)
+{
+ ACEXML_LocatorImpl* locator = 0;
+ if (!systemId)
+ systemId = input->getSystemId();
+ ACE_NEW_RETURN (locator, ACEXML_LocatorImpl (systemId, publicId), -1);
+ ACEXML_Parser_Context* new_context = 0;
+ ACE_NEW_RETURN (new_context, ACEXML_Parser_Context(input, locator), -1);
+ if (this->push_context (new_context) != 0)
+ {
+ ACE_ERROR ((LM_ERROR, "Unable to switch input streams"));
+ delete new_context;
+ return -1;
+ }
+ this->current_ = new_context;
+ this->content_handler_->setDocumentLocator (this->current_->getLocator());
+ return 0;
+}
+
+int
+ACEXML_Parser::push_context (ACEXML_Parser_Context* context)
+{
+ if (this->ctx_stack_.push (context) < 0)
+ {
+ ACE_ERROR ((LM_ERROR, "Unable to push input source onto the stack"));
+ return -1;
+ }
+ return 0;
+}
+
+int
+ACEXML_Parser::pop_context (int GE_ref ACEXML_ENV_ARG_DECL)
+{
+ size_t nrelems = this->ctx_stack_.size();
+ if (nrelems <= 1)
+ {
+ this->fatal_error(ACE_TEXT ("Unexpected end-of-file")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ ACEXML_Parser_Context* temp = 0;
+ int retval = this->ctx_stack_.pop (temp);
+ if (retval != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Unable to pop element of the input stack")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ delete temp;
+ if (this->ctx_stack_.top (this->current_) != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Unable to read top element of input stack")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ ACEXML_Char* reference = 0;
+ if (GE_ref == 1 && this->GE_reference_.size() > 0)
+ {
+ if (this->GE_reference_.pop (reference) < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ }
+ else if (GE_ref == 0 && this->PE_reference_.size() > 0)
+ {
+ if (this->PE_reference_.pop (reference) < 0)
+ {
+ this->fatal_error (ACE_TEXT ("Internal Parser Error")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+ }
+ nrelems = this->ctx_stack_.size();
+
+ if (this->external_entity_ && (GE_ref == 0 || GE_ref == 1))
+ this->external_entity_--;
+
+ this->content_handler_->setDocumentLocator (this->current_->getLocator());
+
+ return nrelems;
+}
+
+int
+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)
+ {
+ return this->simple_parsing_;
+ }
+ else if (ACE_OS::strcmp (name, ACEXML_Parser::namespaces_feature_) == 0)
+ {
+ return this->namespaces_;
+ }
+ else if (ACE_OS::strcmp (name,
+ ACEXML_Parser::namespace_prefixes_feature_) == 0)
+ {
+ return this->namespace_prefixes_;
+ }
+ else if (ACE_OS::strcmp (name, ACEXML_Parser::validation_feature_) == 0)
+ {
+ return this->validate_;
+ }
+ ACEXML_THROW_RETURN (ACEXML_SAXNotRecognizedException (name), -1);
+}
+
+
+
+void
+ACEXML_Parser::setFeature (const ACEXML_Char *name,
+ int boolean_value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException))
+{
+ 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)
+ {
+ this->namespaces_ = (boolean_value == 0 ? 0 : 1);
+ return;
+ }
+ else if (ACE_OS::strcmp (name,
+ ACEXML_Parser::namespace_prefixes_feature_) == 0)
+ {
+ this->namespace_prefixes_ = (boolean_value == 0 ? 0 : 1);
+ return;
+ }
+ else if (ACE_OS::strcmp (name, ACEXML_Parser::validation_feature_) == 0)
+ {
+ this->validate_ = (boolean_value == 0 ? 0 : 1);
+ return;
+ }
+
+ ACEXML_THROW (ACEXML_SAXNotRecognizedException (name));
+}
+
+void *
+ACEXML_Parser::getProperty (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException))
+{
+ ACEXML_THROW_RETURN (ACEXML_SAXNotSupportedException (name), 0);
+}
+
+void
+ACEXML_Parser::setProperty (const ACEXML_Char *name,
+ void *value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException))
+{
+ ACE_UNUSED_ARG (value);
+
+ ACEXML_THROW (ACEXML_SAXNotSupportedException (name));
+}
+
+void
+ACEXML_Parser::error (const ACEXML_Char* msg ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_SAXParseException* exception = 0;
+ ACE_NEW_NORETURN (exception, ACEXML_SAXParseException (msg));
+ if (this->error_handler_)
+ this->error_handler_->error (*exception ACEXML_ENV_ARG_PARAMETER);
+ else
+ ACEXML_ENV_RAISE (exception);
+ return;
+}
+
+void
+ACEXML_Parser::warning (const ACEXML_Char* msg ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_SAXParseException* exception = 0;
+ ACE_NEW_NORETURN (exception, ACEXML_SAXParseException (msg));
+ if (this->error_handler_)
+ this->error_handler_->warning (*exception ACEXML_ENV_ARG_PARAMETER);
+ delete exception;
+ return;
+}
+
+void
+ACEXML_Parser::fatal_error (const ACEXML_Char* msg ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_SAXParseException* exception = 0;
+ ACE_NEW_NORETURN (exception, ACEXML_SAXParseException (msg));
+ if (this->error_handler_)
+ this->error_handler_->fatalError (*exception ACEXML_ENV_ARG_PARAMETER);
+ this->reset();
+ ACEXML_ENV_RAISE (exception);
+ return;
+}
+
+void
+ACEXML_Parser::parse_version_info (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char* astring;
+ if (this->parse_token (ACE_TEXT("ersion")) < 0
+ || this->skip_equal () != 0
+ || this->parse_version_num (astring) != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Invalid VersionInfo specification")
+ ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+ if (ACE_OS::strcmp (astring, ACE_TEXT ("1.0")) != 0)
+ {
+ this->fatal_error (ACE_TEXT ("ACEXML Parser supports XML version 1.0 ")
+ ACE_TEXT ("documents only") ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+}
+
+void
+ACEXML_Parser::parse_encoding_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ ACEXML_Char* astring = 0;
+ if ((this->parse_token (ACE_TEXT("ncoding")) < 0)
+ || this->skip_equal () != 0
+ || this->parse_encname (astring) != 0)
+ {
+ this->fatal_error (ACE_TEXT ("Invalid EncodingDecl specification")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+ const ACEXML_Char* encoding = this->current_->getInputSource()->getEncoding();
+ if (encoding != 0 && ACE_OS::strcmp (astring, encoding) != 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("Detected Encoding is %s ")
+ ACE_TEXT (": Declared Encoding is %s\n"),
+ encoding, astring));
+ this->warning (ACE_TEXT ("Declared encoding differs from detected ")
+ ACE_TEXT ("encoding") ACEXML_ENV_ARG_PARAMETER);
+ }
+}
+
+int
+ACEXML_Parser::parse_text_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // Read xml
+ if (this->parse_token (ACE_TEXT("xml")) < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting keyword 'xml' in TextDecl")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ ACEXML_Char fwd = this->skip_whitespace();
+ // Read version
+ if (fwd == 'v')
+ {
+ this->parse_version_info (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ fwd = this->skip_whitespace();
+ }
+
+ if (fwd == 'e')
+ {
+ this->parse_encoding_decl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ fwd = this->skip_whitespace();
+ }
+ else
+ {
+ this->fatal_error (ACE_TEXT ("Missing encodingDecl in TextDecl")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ if (fwd == '?' && this->get() == '>')
+ return 0;
+ // All the rules fail. So return an error.
+ this->fatal_error (ACE_TEXT ("Invalid TextDecl") ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ return -1;
+}
+
+void
+ACEXML_Parser::parse_xml_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // Read <?xml
+ if (this->parse_token (ACE_TEXT("xml")) < 0)
+ {
+ this->fatal_error(ACE_TEXT ("Expecting keyword xml in XMLDecl")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+
+ ACEXML_Char fwd = this->skip_whitespace();
+
+ // Read version
+ if (fwd != 'v')
+ {
+ this->fatal_error (ACE_TEXT ("Expecting VersionInfo declaration")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+ }
+
+ this->parse_version_info (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK;
+
+ fwd = this->skip_whitespace();
+ if (fwd != '?')
+ {
+ if (fwd == 'e')
+ {
+ this->parse_encoding_decl (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+ ACEXML_CHECK;
+ fwd = this->skip_whitespace();
+ }
+ if (fwd == 's')
+ {
+ ACEXML_Char* astring;
+ if ((this->parse_token (ACE_TEXT("tandalone")) == 0) &&
+ this->skip_equal () == 0 &&
+ this->parse_sddecl (astring) == 0)
+ {
+ if (ACE_OS::strcmp (astring, ACE_TEXT ("yes")) == 0)
+ this->standalone_ = 1;
+ fwd = this->skip_whitespace();
+ }
+ }
+ }
+ if (fwd == '?' && this->get() == '>')
+ return;
+ // All the rules fail. So return an error.
+ this->fatal_error (ACE_TEXT ("Invalid XMLDecl declaration")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK;
+}
+
+int
+ACEXML_Parser::parse_comment (void)
+{
+ int state = 0;
+
+ if (this->get () != '-' || // Skip the opening "<!--"
+ this->get () != '-' || // completely.
+ this->get () == '-') // and at least something not '-'.
+ return -1;
+
+ while (state < 3)
+ // Waiting for the trailing three character '-->'. Notice that
+ // according to the spec, '--->' is not a valid closing comment
+ // sequence. But we'll let it pass anyway.
+ {
+ ACEXML_Char fwd = this->get ();
+ if ((fwd == '-' && state < 2) ||
+ (fwd == '>' && state == 2))
+ state += 1;
+ else
+ state = 0; // Reset parse state.
+ }
+ return 0;
+}
+
+int
+ACEXML_Parser::parse_processing_instruction (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ const ACEXML_Char *pitarget = this->parse_name ();
+ ACEXML_Char *instruction = 0;
+
+ if (!ACE_OS::strcasecmp (ACE_TEXT ("xml"), pitarget))
+ {
+ // Invalid PITarget name.
+ this->fatal_error(ACE_TEXT ("PI can't have 'xml' in PITarget")
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ }
+
+ int state = 0;
+
+ ACEXML_Char ch = this->skip_whitespace();
+ while (state < 2)
+ {
+ switch (ch)
+ {
+ case '?':
+ if (state == 0)
+ state = 1;
+ break;
+ case '>':
+ if (state == 1)
+ {
+ instruction = this->obstack_.freeze ();
+ this->content_handler_->processingInstruction (pitarget,
+ instruction
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_CHECK_RETURN (-1);
+ this->obstack_.unwind (const_cast<ACEXML_Char*> (pitarget));
+ return 0;
+ }
+ break;
+ case 0x0A:
+ // Fall thru...
+ default:
+ if (state == 1)
+ this->obstack_.grow ('?');
+ this->obstack_.grow (ch);
+ state = 0;
+ }
+ ch = this->get ();
+ }
+ return -1;
+}
+
+void
+ACEXML_Parser::reset (void)
+{
+ this->doctype_ = 0;
+ if (this->ctx_stack_.pop (this->current_) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Mismatched push/pop of Context stack")));
+ if (this->current_)
+ {
+ this->current_->getInputSource()->getCharStream()->rewind();
+
+ this->current_->setInputSource (0);
+ delete this->current_;
+ this->current_ = 0;
+ }
+
+ ACEXML_Char* temp = 0;
+ while (this->GE_reference_.pop (temp) != -1)
+ ;
+ while (this->PE_reference_.pop (temp) != -1)
+ ;
+ this->obstack_.release();
+ this->alt_stack_.release();
+ this->xml_namespace_.reset();
+ this->nested_namespace_ = 0;
+ this->internal_GE_.reset();
+ this->external_GE_.reset();
+ this->unparsed_entities_.reset();
+ this->predef_entities_.reset();
+ this->internal_PE_.reset();
+ this->external_PE_.reset();
+ this->notations_.reset();
+ this->ref_state_ = ACEXML_ParserInt::INVALID;
+ this->external_subset_ = 0;
+ this->external_entity_ = 0;
+ this->has_pe_refs_ = 0;
+ this->standalone_ = 0;
+ this->external_dtd_ = 0;
+ this->internal_dtd_ = 0;
+}
+
diff --git a/ACE/ACEXML/parser/parser/Parser.h b/ACE/ACEXML/parser/parser/Parser.h
new file mode 100644
index 00000000000..0fbbcb31fc6
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/Parser.h
@@ -0,0 +1,904 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Parser.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_BASIC_PARSER_H_
+#define _ACEXML_BASIC_PARSER_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 */
+
+#include "ACEXML/common/XMLReader.h"
+#include "ACEXML/common/LocatorImpl.h"
+#include "ACEXML/common/NamespaceSupport.h"
+#include "ACEXML/common/CharStream.h"
+#include "ace/Obstack.h"
+#include "ace/Functor.h"
+#include "ace/SString.h"
+#include "ace/Hash_Map_Manager.h"
+#include "ace/Unbounded_Set.h"
+#include "ace/Containers_T.h"
+#include "ace/Auto_Ptr.h"
+#include "ACEXML/parser/parser/Entity_Manager.h"
+#include "ACEXML/parser/parser/ParserInternals.h"
+#include "ACEXML/parser/parser/ParserContext.h"
+
+/**
+ * @class ACEXML_Parser Parser.h "ACEXML/parser/parser/Parser.h"
+ *
+ * @brief A SAX based parser.
+ *
+ */
+class ACEXML_PARSER_Export ACEXML_Parser : public ACEXML_XMLReader
+{
+public:
+ /// Default constructor.
+ ACEXML_Parser (void);
+
+ /// Destructor.
+ virtual ~ACEXML_Parser (void);
+
+ /**
+ * Initialize the parser state.
+ *
+ * @retval 0 if parser was initialized correctly else -1.
+ */
+ int initialize (ACEXML_InputSource* input);
+
+ /**
+ * Return the current content handler.
+ */
+ virtual ACEXML_ContentHandler *getContentHandler (void) const;
+
+ /*
+ * Return the current DTD handler.
+ */
+ virtual ACEXML_DTDHandler *getDTDHandler (void) const;
+
+ /*
+ * Return the current entity resolver.
+ */
+ virtual ACEXML_EntityResolver *getEntityResolver (void) const;
+
+ /*
+ * Return the current error handler.
+ */
+ virtual ACEXML_ErrorHandler *getErrorHandler (void) const;
+
+ /**
+ * Look up the value of a feature. This method allows
+ * programmers to check whether a specific feature has been
+ * activated in the parser.
+ */
+ virtual int getFeature (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) ;
+
+ /**
+ * Activating or deactivating a feature.
+ */
+ virtual void setFeature (const ACEXML_Char *name,
+ int boolean_value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) ;
+
+ /*
+ * Look up the value of a property.
+ */
+ virtual void * getProperty (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) ;
+
+ /*
+ * Set the value of a property.
+ */
+ virtual void setProperty (const ACEXML_Char *name,
+ void *value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) ;
+
+ /*
+ * Parse an XML document.
+ */
+ virtual void parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Parse an XML document from a system identifier (URI).
+ */
+ virtual void parse (const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+ ;
+
+ /*
+ * Allow an application to register a content event handler.
+ */
+ virtual void setContentHandler (ACEXML_ContentHandler *handler);
+
+ /*
+ * Allow an application to register a DTD event handler.
+ */
+ virtual void setDTDHandler (ACEXML_DTDHandler *handler);
+
+ /*
+ * Allow an application to register an entity resolver.
+ */
+ virtual void setEntityResolver (ACEXML_EntityResolver *resolver);
+
+ /*
+ * Allow an application to register an error event handler.
+ */
+ virtual void setErrorHandler (ACEXML_ErrorHandler *handler);
+
+
+
+protected:
+ /**
+ * Parse XML Prolog.
+ */
+ void parse_xml_prolog (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse VersionInfo declaration.
+ *
+ */
+ void parse_version_info (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a EncodingDecl declaration.
+ *
+ */
+ void parse_encoding_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a XMLDecl declaration.
+ *
+ */
+ void parse_xml_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a TextDecl declaration.
+ */
+ int parse_text_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a PI statement. The first character encountered
+ * should always be '?' in the PI prefix "@<?".
+ *
+ * @retval 0 on success, -1 otherwise.
+ */
+ int parse_processing_instruction (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse the DOCTYPE declaration. The first character encountered
+ * should always be 'D' in doctype prefix: "@<@!DOCTYPE".
+ */
+ int parse_doctypedecl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse an XML element. The first character encountered should
+ * be the first character of the element "Name".
+ *
+ * @param is_root If not 0, then we are expecting to see the "root"
+ * element now, and the next element's name need to match the name
+ * defined in DOCTYPE definition, i.e., @a this->doctype_.
+ *
+ * @todo Instead of simply checking for the root element based on the
+ * argument @a is_root, we should instead either pass in some sort
+ * of validator or allow the function to return the element name so it
+ * can be used in a validator.
+ */
+ void parse_element (int is_root ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a content declaration.
+ *
+ */
+ int parse_content (const ACEXML_Char* startname, const ACEXML_Char*& ns_uri,
+ const ACEXML_Char*& ns_lname, int ns_flag
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a character reference, i.e., "&#x20;" or "&#30;". The first
+ * character encountered should be the '#' char.
+ *
+ * @param buf points to a character buffer for the result.
+ *
+ * @param len In/out argument which initially specifies the size of the
+ * buffer and is later set to the no. of characters in the reference.
+ *
+ * @retval 0 on success and -1 otherwise.
+ */
+ int parse_char_reference (ACEXML_Char *buf, size_t& len);
+
+ /**
+ * Parse a reference name, i.e., foo in "&foo;" or "%foo;". The first
+ * character encountered should be the character following '&' or '%'.
+ * Effectively the same as @sa parse_name but we don't use the parser's
+ * obstack. Caller is responsible for deleting the memory.
+ *
+ * @retval A pointer to name of reference, 0 otherwise.
+ */
+ ACEXML_Char* parse_reference_name (void);
+
+ /**
+ * Parse a CDATA section. The first character should always be the first
+ * '[' in CDATA definition.
+ *
+ * @retval 0 on success.
+ * @retval -1 if fail.
+ */
+ int parse_cdata (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a "markupdecl" section, this includes both "markupdecl" and
+ * "DeclSep" sections in XML specification
+ */
+ int parse_internal_dtd (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Skip over a comment. The first character encountered should always be
+ * the first '-' in the comment prefix "@<@!--".
+ */
+ int parse_comment (void);
+
+ /**
+ * Parse an "ELEMENT" decl. The first character this method
+ * expects is always the 'L' (the second char) in the word
+ * "ELEMENT".
+ *
+ * @retval 0 on success, -1 otherwise.
+ */
+ int parse_element_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse an "ENTITY" decl. The first character this method expects
+ * is always the 'N' (the second char) in the word "ENTITY".
+ *
+ * @retval 0 on success, -1 otherwise.
+ */
+ int parse_entity_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse an "ATTLIST" decl. Thse first character this method
+ * expects is always the 'A' (the first char) in the word
+ * "ATTLIST".
+ *
+ * @retval 0 on success, -1 otherwise.
+ */
+ int parse_attlist_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a AttType declaration.
+ *
+ */
+ int parse_atttype (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ *Parse a "NOTATION" decl. The first character this method
+ * expects is always the 'N' (the first char) in the word
+ * "NOTATION".
+ *
+ * @retval 0 on success, -1 otherwise.
+ */
+ int parse_notation_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse an ExternalID or a reference to PUBLIC ExternalID.
+ * Possible cases are in the forms of: <code>
+ *
+ * SYSTEM 'quoted string representing system resource'
+ * PUBLIC 'quoted name of public ID' 'quoted resource'
+ * PUBLIC 'quoted name we are referring to'
+ * </code>
+ *
+ * The first character this function sees must be either 'S' or 'P'.
+ * When the function finishes parsing, the input stream points
+ * at the first non-whitespace character.
+ *
+ * @param publicId returns the unquoted publicId read. If none
+ * is available, it will be reset to 0.
+ * @param systemId returns the unquoted systemId read. If none
+ * is available, it will be reset to 0.
+ *
+ * @retval 0 on success, -1 otherwise.
+ */
+ int parse_external_id (ACEXML_Char *&publicId, ACEXML_Char *&systemId
+ ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse an external DTD.
+ *
+ */
+ int parse_external_dtd (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse an external subset. This does the actual parsing of an external
+ * subset and is called by @sa parse_external_dtd.
+ *
+ */
+ int parse_external_subset (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a markupDecl section.
+ *
+ */
+ int parse_markup_decl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a conditionalSect declaration.
+ *
+ */
+ int parse_conditional_section (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a includeSect declaration.
+ *
+ */
+ int parse_includesect (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ *
+ * Parse a ignoreSect declaration.
+ */
+ int parse_ignoresect (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a PEReference.
+ *
+ */
+ int parse_PE_reference (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a Reference.
+ *
+ */
+ int parse_entity_reference (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse an entityValue.
+ *
+ */
+ int parse_entity_value (ACEXML_Char *&str ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a DefaultDecl specification.
+ *
+ */
+ int parse_defaultdecl (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+
+ /**
+ * Parse the "children" and "Mixed" non-terminals in contentspec.
+ *
+ * The first character this function sees must be the first
+ * open paren '(' in children.
+ *
+ * @retval 0 on success, -1 otherwise.
+ */
+ int parse_children_definition (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a @c cp non-terminal. @c cp can either be a @c seq or a @c choice.
+ * This function calls itself recursively.
+ *
+ * @param skip_open_paren when non-zero, it indicates that the open paren of
+ * the @c seq or @c choice has already been removed from the input
+ * stream.
+ *
+ * @retval 0 on success, -1 otherwise.
+ */
+ int parse_child (int skip_open_paren ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a name from the input CharStream. If @a ch @!= 0, then we have
+ * already consumed the first name character from the input CharStream,
+ * otherwise, parse_name will use this->get() to acquire the initial
+ * character.
+ *
+ * @return A pointer to the string in the obstack, 0 if it's not a
+ * valid name.
+ */
+ ACEXML_Char *parse_name (ACEXML_Char ch = 0);
+
+ /**
+ * Parse a NMTOKEN from the input stream.
+ *
+ * @return A pointer to the string in the obstack, 0 if it's not a valid
+ * NMTOKEN.
+ */
+ ACEXML_Char* parse_nmtoken (ACEXML_Char ch = 0);
+
+ /**
+ * Parse the version string in an XML Prolog section.
+ *
+ * @param str String containing the version number if successful.
+ * @return 0 if the string was read successfully, 0 otherwise.
+ */
+ int parse_version (ACEXML_Char*& str);
+
+ /**
+ * Parse the version number in a VersionInfo declaration.
+ */
+ int parse_version_num (ACEXML_Char*& str);
+
+ /**
+ * Parse the encoding name in an XML Prolog section.
+ *
+ * @param str String containing the encoding name if successful.
+ * @return 0 if the string was read successfully, 0 otherwise.
+ */
+ int parse_encname (ACEXML_Char*& str);
+
+ /**
+ * Parse a SDDecl string.
+ *
+ * @param str String containing the encoding name if successful.
+ * @return 0 if the string was read successfully, -1 otherwise.
+ */
+ int parse_sddecl (ACEXML_Char*& str);
+
+ /**
+ * Parse an attribute name.
+ *
+ * @retval str String containing the value of the attribute name
+ * if successful.
+ * @retval 0 otherwise.
+ */
+ ACEXML_Char* parse_attname (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse an attribute value.
+ *
+ * @param str String containing the value of the attribute if successful.
+ * @return 0 if attribute value was read successfully, -1 otherwise.
+ */
+ int parse_attvalue (ACEXML_Char*& str ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a tokenized type attribute.
+ *
+ * @return 0 if attribute type was read successfully, -1 otherwise.
+ */
+ int parse_tokenized_type (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Parse a SystemLiteral.
+ *
+ * @param str String containing the SystemLiteral if successful.
+ * @return 0 if the string was read successfully, 0 otherwise.
+ */
+ int parse_system_literal (ACEXML_Char*& str);
+
+ /**
+ * Parse a PubidLiteral.
+ *
+ * @param str String containing the PubidLiteral if successful.
+ * @return 0 if the string was read successfully, 0 otherwise.
+ */
+ int parse_pubid_literal (ACEXML_Char*& str);
+
+ /**
+ * Check if a character @a c is a whitespace.
+ *
+ * @retval 1 if @a c is a valid white space character. 0 otherwise.
+ */
+ int is_whitespace (const ACEXML_Char c) const;
+
+ /**
+ * Check if a character @a c is a valid Char.
+ *
+ * @retval 1 if @a c is a valid character. 0 otherwise.
+ */
+ int isChar (ACEXML_UCS4 c) const;
+
+ /**
+ * Check if a character @a c is a valid CharRef character.
+ *
+ * @retval 1 if @a c is a valid character reference character, 0 otherwise.
+ */
+ int isCharRef (const ACEXML_Char c) const;
+
+ /**
+ * Check if a character @a c is a BaseChar.
+ *
+ * @retval 1 if @a c is a valid BaseChar character, 0 otherwise.
+ */
+ int isBasechar (const ACEXML_Char c) const;
+
+ /**
+ * Check if a character @a c is a Ideographic.
+ *
+ * @retval 1 if @a c is a valid Ideographic character, 0 otherwise.
+ */
+ int isIdeographic (const ACEXML_Char c) const;
+
+ /**
+ * Check if a character @a c is a CombiningChar.
+ *
+ * @retval 1 if @a c is a valid CombiningChar character, 0 otherwise.
+ */
+ int isCombiningchar (const ACEXML_Char c) const;
+
+ /**
+ * Check if a character @a c is a Digit.
+ *
+ * @retval 1 if @a c is a valid Digit character, 0 otherwise.
+ */
+ int isDigit (const ACEXML_Char c) const;
+
+ /**
+ * Check if a character @a c is an Extender.
+ *
+ * @retval 1 if @a c is a valid Extender character, 0 otherwise.
+ */
+ int isExtender (const ACEXML_Char c) const;
+
+ /**
+ * Check if a character @a c is a Letter.
+ *
+ * @retval 1 if @a c is a valid Letter character, 0 otherwise.
+ */
+ int isLetter (const ACEXML_Char c) const;
+
+ /**
+ * Check if a character is an acceptable NameChar.
+ *
+ * @retval 1 if @a c is a valid NameChar character, 0 otherwise.
+ */
+ int isNameChar (const ACEXML_Char c) const;
+
+ /**
+ * Check if a character is a PubidChar.
+ *
+ * @retval 1 if @a c is a valid PubidChar character, 0 otherwise.
+ */
+ int isPubidChar (const ACEXML_Char c) const;
+
+ /// Get a character.
+ virtual ACEXML_Char get (void);
+
+ /// Peek a character.
+ virtual ACEXML_Char peek (void);
+
+private:
+
+ // *** Helper functions for parsing XML
+
+ /**
+ * Skip any whitespaces encountered until the first non-whitespace
+ * character is encountered.
+ *
+ * @return The next non-whitespace character from the CharStream.
+ *
+ * @sa skip_whitespace_count
+ */
+ ACEXML_Char skip_whitespace (void);
+
+ /**
+ * Skip any whitespaces encountered until the first non-whitespace
+ * character. The first non-whitespace character is not consumed.
+ * This method does peek into the input CharStream and therefore
+ * is more expensive than @ref skip_whitespace.
+ *
+ * @param peek If non-null, @a peek points to a ACEXML_Char where
+ * skip_whitespace_count stores the first non-whitespace
+ * character it sees (character is not removed from the stream.)
+ *
+ * @return The number of whitespace characters consumed.
+ *
+ * @sa skip_whitespace
+ */
+ int skip_whitespace_count (ACEXML_Char *peek = 0);
+
+ /**
+ * Skip an equal sign.
+ *
+ * @retval 0 when succeeds, -1 if no equal sign is found.
+ */
+ int skip_equal (void);
+
+ /**
+ * Get a quoted string. Quoted strings are used to specify
+ * attribute values and this routine will replace character and
+ * entity references on-the-fly. Parameter entities are not allowed
+ * (or replaced) in this function. (But regular entities are.)
+ *
+ * @param str returns the un-quoted string.
+ *
+ * @retval 0 on success, -1 otherwise.
+ */
+ int get_quoted_string (ACEXML_Char *&str);
+
+ /**
+ * Check if a character @a c is a Digit.
+ *
+ * @retval 1 if @a c is a valid Digit character, 0 otherwise.
+ */
+ int isNormalDigit (const ACEXML_Char c) const;
+
+ /**
+ * Dispatch errors to ErrorHandler.
+ *
+ */
+ void error (const ACEXML_Char* msg ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Dispatch warnings to ErrorHandler.
+ *
+ */
+ void warning (const ACEXML_Char* msg ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Dispatch fatal errors to ErrorHandler.
+ *
+ */
+ void fatal_error (const ACEXML_Char* msg ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /**
+ * Dispatch prefix mapping calls to the ContentHandler.
+ *
+ * @param prefix Namespace prefix
+ * @param uri Namespace URI
+ * @param name Local name
+ * @param start 1 => startPrefixMapping 0 => endPrefixMapping
+ */
+ void prefix_mapping (const ACEXML_Char* prefix,
+ const ACEXML_Char* uri,
+ int start ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+ /**
+ * Parse a keyword.
+ */
+ int parse_token (const ACEXML_Char* keyword);
+
+ /**
+ * Push the current context on to the stack.
+ *
+ */
+ int push_context (ACEXML_Parser_Context* context);
+
+ /**
+ * Pop the top element in the stack and replace current context with that.
+ */
+ int pop_context (int GE_ref ACEXML_ENV_ARG_DECL);
+
+ /**
+ * Create a new ACEXML_CharStream from @a systemId and @a publicId and
+ * replace the current input stream with the newly created stream.
+ */
+ virtual int switch_input (ACEXML_CharStream* cstream,
+ const ACEXML_Char* systemId,
+ const ACEXML_Char* publicId = 0);
+ /**
+ * Create a new ACEXML_InputSource from @a systemId and @a publicId and
+ * replace the current input source with the newly created InputSource.
+ */
+ virtual int switch_input (ACEXML_InputSource* input,
+ const ACEXML_Char* systemId,
+ const ACEXML_Char* publicId = 0);
+
+ /**
+ * Check for a parameter entity reference. This is used to check for the
+ * occurence of a PE Reference withing markupDecl. Additionally this
+ * function consumes any leading or trailing whitespace around the PE
+ * Reference.
+ *
+ * @retval Number of whitespace characters skipped.
+ */
+ int check_for_PE_reference (ACEXML_ENV_SINGLE_ARG_DECL);
+
+ /**
+ * Reset the parser state.
+ *
+ */
+ void reset (void);
+
+ /**
+ * Very trivial, non-conformant normalization of a systemid.
+ *
+ */
+ ACEXML_Char* normalize_systemid (const ACEXML_Char* systemId);
+
+ // Feature names:
+
+ /**
+ * \addtogroup acexml_parser_features
+ * @{
+ */
+
+ /**
+ * @var simple_parsing_feature_
+ *
+ * This constant string defines the name of "simple XML parsing"
+ * feature. When this feature is enabled, ACEXML parser is allowed
+ * to parse a simple XML stream without mandated XML prolog
+ * and no DTD defintion.
+ */
+ static const ACEXML_Char simple_parsing_feature_[];
+
+ /**
+ * @var namespaces_feature_
+ *
+ * This constant string defines the SAX XML Namespace feature. When this
+ * feature is enabled, ACEXML parser allows access by namespace qualified
+ * names.
+ */
+ static const ACEXML_Char namespaces_feature_[];
+
+ /**
+ * @var namespace_prefixes_feature_
+ *
+ * This constant string defines the SAX XML Namespace prefixes feature.
+ * Normally the list of attributes returned by the parser will not
+ * contain attributes used as namespace declarations (xmlns*). When this
+ * feature is enabled, the list of attributes contains the namespace
+ * declarations also.
+ */
+ static const ACEXML_Char namespace_prefixes_feature_[];
+
+ /**
+ * @var validation_feature_
+ *
+ * This constant string defines the SAX XML Validation feature. When
+ * this feature is enabled, the parser validates the document in
+ * addition to checking for well-formedness.
+ */
+ static const ACEXML_Char validation_feature_[];
+
+ /* @} */
+
+ /// Keeping track of the handlers. We do not manage the memory for
+ /// handlers.
+ ACEXML_DTDHandler *dtd_handler_;
+ ACEXML_EntityResolver *entity_resolver_;
+ ACEXML_ContentHandler *content_handler_;
+ ACEXML_ErrorHandler *error_handler_;
+
+ /// Document Type
+ ACEXML_Char *doctype_;
+
+ /// Current parser context
+ ACEXML_Parser_Context* current_;
+
+ /// Stack used to hold the Parser_Context
+ ACE_Unbounded_Stack<ACEXML_Parser_Context*> ctx_stack_;
+
+ /*
+ * The following two are essentially chains of references and is used by
+ * the parser to determine if there is any recursion. We keep two of
+ * these one for general entities and one for parameter entities, as they
+ * both fall under different namespaces.
+ *
+ */
+ /// Set used to hold the general entity references that are active.
+ ACE_Unbounded_Stack<ACEXML_Char*> GE_reference_;
+
+ /// Set used to hold the parameter entity references that are active.
+ ACE_Unbounded_Stack<ACEXML_Char*> PE_reference_;
+
+ /// Obstack used by the parser to hold all the strings parsed
+ ACE_Obstack_T<ACEXML_Char> obstack_;
+
+ /// Alternative obstack used to hold any strings when the original is in use
+ ACE_Obstack_T<ACEXML_Char> alt_stack_;
+
+ /// Namespace stack used by the parser to implement support for Namespaces
+ ACEXML_NamespaceSupport xml_namespace_;
+
+ /// T => We are processing a nested namespace
+ int nested_namespace_;
+
+ /// Set of internal parsed general entities in the document
+ ACEXML_Entity_Manager internal_GE_;
+
+ /// Set of external parsed general entities in the document
+ ACEXML_Entity_Manager external_GE_;
+
+ /// Set of unparsed entities in the document
+ ACEXML_Entity_Manager unparsed_entities_;
+
+ /// Set of predefined entities used by the parser
+ ACEXML_Entity_Manager predef_entities_;
+
+ /// Set of internal parsed parameter entities in the document
+ ACEXML_Entity_Manager internal_PE_;
+
+ /// Set of external parsed parameter entities in the document
+ ACEXML_Entity_Manager external_PE_;
+
+ /// Set of notations declared in the document
+ ACEXML_Entity_Manager notations_;
+
+ /// State of the parser when it encounters a reference.
+ ACEXML_ParserInt::ReferenceState ref_state_;
+
+ /// T => We are parsing an external subset
+ int external_subset_;
+
+ /// T => We are parsing an external entity value
+ int external_entity_;
+
+ /// T => Internal DTD has parameter entity references
+ int has_pe_refs_;
+
+ /// If set, the document is a standalone XML document
+ int standalone_;
+
+ /// If set, the document has an external DTD subset
+ int external_dtd_;
+
+ /// If set, the document has an internal DTD
+ int internal_dtd_;
+
+ /// Feature flags
+ /// If set, the parser should parse a document without a prolog
+ int simple_parsing_;
+
+ /// If set, the parser should also validate
+ int validate_;
+
+ /// If set, the parser should allow access by namespace qualified names.
+ int namespaces_;
+
+ /// If set, the parser should include namespace declarations in the list
+ /// of attributes of an element.
+ int namespace_prefixes_;
+
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/parser/parser/Parser.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_BASIC_PARSER_H_ */
diff --git a/ACE/ACEXML/parser/parser/Parser.i b/ACE/ACEXML/parser/parser/Parser.i
new file mode 100644
index 00000000000..97896a68388
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/Parser.i
@@ -0,0 +1,257 @@
+//=============================================================================
+/**
+ * @file Parser.i
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+ACEXML_INLINE ACEXML_ContentHandler *
+ACEXML_Parser::getContentHandler (void) const
+{
+ return this->content_handler_;
+}
+
+ACEXML_INLINE ACEXML_DTDHandler *
+ACEXML_Parser::getDTDHandler (void) const
+{
+ return this->dtd_handler_;
+}
+
+ACEXML_INLINE ACEXML_EntityResolver *
+ACEXML_Parser::getEntityResolver (void) const
+{
+ return this->entity_resolver_;
+}
+
+ACEXML_INLINE ACEXML_ErrorHandler *
+ACEXML_Parser::getErrorHandler (void) const
+{
+ return this->error_handler_;
+}
+
+ACEXML_INLINE void
+ACEXML_Parser::setContentHandler (ACEXML_ContentHandler *handler)
+{
+ this->content_handler_ = handler;
+}
+
+ACEXML_INLINE void
+ACEXML_Parser::setDTDHandler (ACEXML_DTDHandler *handler)
+{
+ this->dtd_handler_ = handler;
+}
+
+ACEXML_INLINE void
+ACEXML_Parser::setEntityResolver (ACEXML_EntityResolver *resolver)
+{
+ this->entity_resolver_ = resolver;
+}
+
+ACEXML_INLINE void
+ACEXML_Parser::setErrorHandler (ACEXML_ErrorHandler *handler)
+{
+ this->error_handler_ = handler;
+}
+
+ACEXML_INLINE int
+ACEXML_Parser::isChar (ACEXML_UCS4 c) const
+{
+ return (c == 0x9 || c == 0xA || c == 0xD ||
+ c >= 0x20 && c <= 0xD7FF ||
+ c >= 0xE000 && c <= 0xFFFD ||
+ c >= 0x10000 && c <= 0x10FFFF);
+}
+
+ACEXML_INLINE int
+ACEXML_Parser::isCharRef (const ACEXML_Char c) const
+ {
+ return ((c >= 'a' && c <= 'f') ||
+ (c >= 'A' && c <= 'F'));
+}
+
+ACEXML_INLINE int
+ACEXML_Parser::isNormalDigit (const ACEXML_Char c) const
+{
+ return (c >= '\x30' && c <= '\x39');
+}
+
+ACEXML_INLINE int
+ACEXML_Parser::isBasechar (const ACEXML_Char c) const
+{
+#if defined (ACE_USES_WCHAR)
+ return ACEXML_ParserInt::isBasechar_i (c);
+#else
+ return ACEXML_ParserInt::base_char_table_[(int) c];
+#endif /* ACE_USES_WCHAR */
+}
+
+ACEXML_INLINE int
+ACEXML_Parser::isIdeographic (const ACEXML_Char c) const
+{
+#if defined (ACE_USES_WCHAR)
+ return ACEXML_ParserInt::isIdeographic_i (c);
+#else
+ ACE_UNUSED_ARG (c);
+ return 0;
+#endif /* ACE_USES_WCHAR */
+}
+
+ACEXML_INLINE int
+ACEXML_Parser::isCombiningchar (const ACEXML_Char c) const
+{
+#if defined (ACE_USES_WCHAR)
+ return ACEXML_ParserInt::isCombiningchar_i (c);
+#else
+ ACE_UNUSED_ARG (c);
+ return 0;
+#endif /* ACE_USES_WCHAR */
+ }
+
+ACEXML_INLINE int
+ACEXML_Parser::isDigit (const ACEXML_Char c) const
+{
+#if defined (ACE_USES_WCHAR)
+ return ACEXML_ParserInt::isDigit_i (c);
+#else
+ return (this->isNormalDigit (c));
+#endif /* ACE_USES_WCHAR */
+}
+
+ACEXML_INLINE int
+ACEXML_Parser::isExtender (const ACEXML_Char c) const
+{
+#if defined (ACE_USES_WCHAR)
+ return ACEXML_ParserInt::isExtender_i (c);
+#else
+ return (c == '\xB7');
+#endif /* ACE_USES_WCHAR */
+}
+
+ACEXML_INLINE int
+ACEXML_Parser::isLetter (const ACEXML_Char c) const
+{
+ return (this->isBasechar (c) || this->isIdeographic (c));
+}
+
+ACEXML_INLINE int
+ACEXML_Parser::isNameChar (const ACEXML_Char c) const
+{
+ return (this->isLetter (c) || this->isDigit (c) || c == '.' || c == '-' ||
+ c == '_' || c == ':' || this->isCombiningchar (c) ||
+ this->isExtender (c));
+}
+
+ACEXML_INLINE int
+ACEXML_Parser::isPubidChar (const ACEXML_Char c) const
+{
+ return (c == '\x20' || c == '\x0D' || c == '\x0A' ||
+ (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9') || c == '-' || c == '\'' || c == '(' ||
+ c == ')' || c == '+' || c == ',' || c == '.' || c == '/' ||
+ c == ':' || c == '=' || c == '?' || c == ';' || c == '!' ||
+ c == '*' || c == '#' || c == '@' || c == '$' || c == '_' ||
+ c == '%');
+}
+
+
+ACEXML_INLINE int
+ACEXML_Parser::is_whitespace (const ACEXML_Char c) const
+{
+ switch (c)
+ {
+ case '\x0A': case '\x20':
+ case '\x09': case '\x0D':
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+ACEXML_INLINE ACEXML_Char
+ACEXML_Parser::skip_whitespace (void)
+{
+ ACEXML_Char ch = this->get();
+ while (this->is_whitespace (ch))
+ ch = this->get ();
+ return ch;
+}
+
+
+ACEXML_INLINE int
+ACEXML_Parser::skip_whitespace_count (ACEXML_Char *peeky)
+{
+ int wscount = 0;
+ ACEXML_Char dummy;
+ ACEXML_Char &forward = (peeky == 0 ? dummy : *peeky);
+
+ for (;this->is_whitespace ((forward = this->peek ())); ++wscount)
+ this->get ();
+ return wscount;
+}
+
+ACEXML_INLINE int
+ACEXML_Parser::skip_equal (void)
+{
+ if (this->skip_whitespace() != '=')
+ return -1;
+ while (this->is_whitespace (this->peek()))
+ this->get();
+ return 0;
+}
+
+ACEXML_INLINE ACEXML_Char
+ACEXML_Parser::get (void)
+{
+ ACEXML_Char ch = 0;
+ const ACEXML_InputSource* ip = this->current_->getInputSource();
+ ACEXML_CharStream* instream = ip->getCharStream();
+
+ if (instream->get (ch) != -1)
+ {
+ this->current_->getLocator()->incrColumnNumber();
+ // Normalize white-space
+ if (ch == '\x0D')
+ {
+ if (instream->peek() == 0x0A)
+ instream->get (ch);
+ ch = '\x0A';
+ }
+ if (ch == '\x0A')
+ {
+ // Reset column number and increment Line Number.
+ this->current_->getLocator()->incrLineNumber();
+ this->current_->getLocator()->setColumnNumber (0);
+ }
+ return ch;
+ }
+ return 0;
+}
+
+ACEXML_INLINE ACEXML_Char
+ACEXML_Parser::peek (void)
+{
+ // Using an extra level of indirection so we can
+ // manage document location in the future.
+ ACEXML_Char ch = 0;
+ const ACEXML_InputSource* ip = this->current_->getInputSource();
+ ACEXML_CharStream* instream = ip->getCharStream();
+ ch = static_cast<ACEXML_Char> (instream->peek ());
+ return (ch > 0 ? ch : 0);
+}
+
+ACEXML_INLINE int
+ACEXML_Parser::parse_token (const ACEXML_Char* keyword)
+{
+ if (keyword == 0)
+ return -1;
+ const ACEXML_Char* ptr = keyword;
+ for (; *ptr != 0 && (this->get() == *ptr); ++ptr)
+ ;
+ if (*ptr == 0)
+ return 0;
+ else
+ return -1;
+}
diff --git a/ACE/ACEXML/parser/parser/ParserContext.cpp b/ACE/ACEXML/parser/parser/ParserContext.cpp
new file mode 100644
index 00000000000..663ae1ef1ac
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/ParserContext.cpp
@@ -0,0 +1,16 @@
+// $Id$
+
+#include "ACEXML/parser/parser/ParserContext.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/parser/parser/ParserContext.inl"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_Parser_Context::~ACEXML_Parser_Context()
+{
+ delete this->instream_;
+ this->instream_ = 0;
+ delete this->locator_;
+ this->locator_ = 0;
+}
+
diff --git a/ACE/ACEXML/parser/parser/ParserContext.h b/ACE/ACEXML/parser/parser/ParserContext.h
new file mode 100644
index 00000000000..6bb7c4122ad
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/ParserContext.h
@@ -0,0 +1,85 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ParserContext.h
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef ACEXML_PARSER_CONTEXT_H
+#define ACEXML_PARSER_CONTEXT_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 */
+
+#include "ACEXML/common/XML_Types.h"
+#include "ACEXML/common/InputSource.h"
+#include "ACEXML/common/Locator.h"
+#include "ACEXML/common/LocatorImpl.h"
+#include "ace/Functor.h"
+#include "ace/Containers_T.h"
+#include "ace/Swap.h"
+
+class ACEXML_PARSER_Export ACEXML_Parser_Context
+{
+public:
+ /// Default constructor
+ ACEXML_Parser_Context();
+
+ /// Constructor which initializes the context
+ ACEXML_Parser_Context (ACEXML_InputSource* instream,
+ ACEXML_LocatorImpl* locator);
+
+ /// Comparison operator
+ bool operator!= (const ACEXML_Parser_Context& src);
+
+ /// Destructor
+ virtual ~ACEXML_Parser_Context();
+
+ /// Reset the parser context. This does not free up the memory. Only sets
+ /// it to zero. Meant to be called after a context is pushed on to a
+ /// stack.
+ void reset (void);
+
+ /// Get the underlying input source.
+ virtual ACEXML_InputSource* getInputSource(void);
+
+ /// Get the underlying locator.
+ virtual ACEXML_LocatorImpl* getLocator(void);
+
+ /// Set the underlying input source.
+ virtual void setInputSource(ACEXML_InputSource* ip);
+
+ /// Set the underlying locator.
+ virtual void setLocator(ACEXML_LocatorImpl* locator);
+
+private:
+
+ /// Copy constructor
+ ACEXML_Parser_Context (const ACEXML_Parser_Context& src);
+
+ /// Assignment operator
+ ACEXML_Parser_Context& operator= (const ACEXML_Parser_Context& src);
+
+ /// Current input char stream.
+ ACEXML_InputSource *instream_;
+
+ /// Current Locator which provides line no., column no. systemId and publicId
+ ACEXML_LocatorImpl* locator_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/parser/parser/ParserContext.inl"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* ACEXML_PARSER_CONTEXT_H */
diff --git a/ACE/ACEXML/parser/parser/ParserContext.inl b/ACE/ACEXML/parser/parser/ParserContext.inl
new file mode 100644
index 00000000000..2814cf63476
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/ParserContext.inl
@@ -0,0 +1,76 @@
+// -*- C++ -*-
+//
+// $Id$
+
+
+ACEXML_INLINE
+ACEXML_Parser_Context::ACEXML_Parser_Context()
+ : instream_ (0),
+ locator_ (0)
+{
+
+}
+
+ACEXML_INLINE
+ACEXML_Parser_Context::ACEXML_Parser_Context (ACEXML_InputSource* instream,
+ ACEXML_LocatorImpl* locator)
+ : instream_ (instream),
+ locator_ (locator)
+{
+
+}
+
+ACEXML_INLINE
+ACEXML_Parser_Context::ACEXML_Parser_Context (const ACEXML_Parser_Context& src)
+ : instream_ (src.instream_),
+ locator_ (src.locator_)
+{
+
+}
+
+ACEXML_INLINE bool
+ACEXML_Parser_Context::operator!= (const ACEXML_Parser_Context& src)
+{
+ return (this->instream_ != src.instream_ && this->locator_ != src.locator_);
+}
+
+ACEXML_INLINE ACEXML_Parser_Context&
+ACEXML_Parser_Context::operator= (const ACEXML_Parser_Context& src)
+{
+ ACEXML_Parser_Context tmp (src);
+ ACE_Swap<ACEXML_InputSource*>::swap (this->instream_, tmp.instream_);
+ ACE_Swap<ACEXML_LocatorImpl*>::swap (this->locator_, tmp.locator_);
+ return *this;
+}
+
+
+ACEXML_INLINE ACEXML_InputSource*
+ACEXML_Parser_Context::getInputSource (void)
+{
+ return this->instream_;
+}
+
+ACEXML_INLINE ACEXML_LocatorImpl*
+ACEXML_Parser_Context::getLocator (void)
+{
+ return this->locator_;
+}
+
+ACEXML_INLINE void
+ACEXML_Parser_Context::setInputSource (ACEXML_InputSource* ip)
+{
+ this->instream_ = ip;
+}
+
+ACEXML_INLINE void
+ACEXML_Parser_Context::setLocator (ACEXML_LocatorImpl* locator)
+{
+ this->locator_ = locator;
+}
+
+ACEXML_INLINE void
+ACEXML_Parser_Context::reset (void)
+{
+ this->instream_ = 0;
+ this->locator_ = 0;
+}
diff --git a/ACE/ACEXML/parser/parser/ParserInternals.cpp b/ACE/ACEXML/parser/parser/ParserInternals.cpp
new file mode 100644
index 00000000000..38db8291fa5
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/ParserInternals.cpp
@@ -0,0 +1,394 @@
+// $Id$
+
+#include "ACEXML/parser/parser/ParserInternals.h"
+
+
+const ACEXML_Char* ACEXML_ParserInt::predef_ent_[] = {
+ ACE_TEXT ("amp"),
+ ACE_TEXT ("lt"),
+ ACE_TEXT ("gt"),
+ ACE_TEXT ("apos"),
+ ACE_TEXT ("quot")
+};
+
+const ACEXML_Char* ACEXML_ParserInt::predef_val_[] = {
+ ACE_TEXT ("&"),
+ ACE_TEXT ("<"),
+ ACE_TEXT (">"),
+ ACE_TEXT ("'"),
+ ACE_TEXT ("\"")
+};
+
+// Optimize away the most common cases. Any compiler worth it's salt should
+// give generate a single memory access.
+
+const ACEXML_Char ACEXML_ParserInt::base_char_table_[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0000 - 0x000F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0010 - 0x001F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0020 - 0x002F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0030 - 0x003F */
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x0040 - 0x004F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 0x0050 - 0x005F */
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x0060 - 0x006F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 0x0070 - 0x007F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0080 - 0x008F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0090 - 0x009F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00A0 - 0x00AF */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00B0 - 0x00BF */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00C0 - 0x00CF */
+ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00D0 - 0x00DF */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00E0 - 0x00EF */
+ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00F0 - 0x00FF */
+};
+
+#if defined (ACE_USES_WCHAR)
+
+int
+ACEXML_ParserInt::isBasechar_i (const ACEXML_Char c)
+{
+ if (c < 0x0100)
+ return ACEXML_ParserInt::base_char_table_[c];
+ else if (c < 0x0905)
+ return ((c >= 0x0100 && c <= 0x0131) ||
+ (c >= 0x0134 && c <= 0x013E) ||
+ (c >= 0x0141 && c <= 0x0148) ||
+ (c >= 0x014A && c <= 0x017E) ||
+ (c >= 0x0180 && c <= 0x01C3) ||
+ (c >= 0x01CD && c <= 0x01F0) ||
+ (c >= 0x01F4 && c <= 0x01F5) ||
+ (c >= 0x01FA && c <= 0x0217) ||
+ (c >= 0x0250 && c <= 0x02A8) ||
+ (c >= 0x02BB && c <= 0x02C1) ||
+ (c == 0x0386) ||
+ (c >= 0x0388 && c <= 0x038A) ||
+ (c == 0x038C) ||
+ (c >= 0x038E && c <= 0x03A1) ||
+ (c >= 0x03A3 && c <= 0x03CE) ||
+ (c >= 0x03D0 && c <= 0x03D6) ||
+ (c == 0x03DA) ||
+ (c == 0x03DC) ||
+ (c == 0x03DE) ||
+ (c == 0x03E0) ||
+ (c >= 0x03E2 && c <= 0x03F3) ||
+ (c >= 0x0401 && c <= 0x040C) ||
+ (c >= 0x040E && c <= 0x044F) ||
+ (c >= 0x0451 && c <= 0x045C) ||
+ (c >= 0x045E && c <= 0x0481) ||
+ (c >= 0x0490 && c <= 0x04C4) ||
+ (c >= 0x04C7 && c <= 0x04C8) ||
+ (c >= 0x04CB && c <= 0x04CC) ||
+ (c >= 0x04D0 && c <= 0x04EB) ||
+ (c >= 0x04EE && c <= 0x04F5) ||
+ (c >= 0x04F8 && c <= 0x04F9) ||
+ (c >= 0x0531 && c <= 0x0556) ||
+ (c == 0x0559) ||
+ (c >= 0x0561 && c <= 0x0586) ||
+ (c >= 0x05D0 && c <= 0x05EA) ||
+ (c >= 0x05F0 && c <= 0x05F2) ||
+ (c >= 0x0621 && c <= 0x063A) ||
+ (c >= 0x0641 && c <= 0x064A) ||
+ (c >= 0x0671 && c <= 0x06B7) ||
+ (c >= 0x06BA && c <= 0x06BE) ||
+ (c >= 0x06C0 && c <= 0x06CE) ||
+ (c >= 0x06D0 && c <= 0x06D3) ||
+ (c == 0x06D5) ||
+ (c >= 0x06E5 && c <= 0x06E6));
+ else if (c < 0x10A0)
+ return ((c >= 0x0905 && c <= 0x0939) ||
+ (c == 0x093D) ||
+ (c >= 0x0958 && c <= 0x0961) ||
+ (c >= 0x0985 && c <= 0x098C) ||
+ (c >= 0x098F && c <= 0x0990) ||
+ (c >= 0x0993 && c <= 0x09A8) ||
+ (c >= 0x09AA && c <= 0x09B0) ||
+ (c == 0x09B2) ||
+ (c >= 0x09B6 && c <= 0x09B9) ||
+ (c >= 0x09DC && c <= 0x09DD) ||
+ (c >= 0x09DF && c <= 0x09E1) ||
+ (c >= 0x09F0 && c <= 0x09F1) ||
+ (c >= 0x0A05 && c <= 0x0A0A) ||
+ (c >= 0x0A0F && c <= 0x0A10) ||
+ (c >= 0x0A13 && c <= 0x0A28) ||
+ (c >= 0x0A2A && c <= 0x0A30) ||
+ (c >= 0x0A32 && c <= 0x0A33) ||
+ (c >= 0x0A35 && c <= 0x0A36) ||
+ (c >= 0x0A38 && c <= 0x0A39) ||
+ (c >= 0x0A59 && c <= 0x0A5C) ||
+ (c == 0x0A5E) ||
+ (c >= 0x0A72 && c <= 0x0A74) ||
+ (c >= 0x0A85 && c <= 0x0A8B) ||
+ (c == 0x0A8D) ||
+ (c >= 0x0A8F && c <= 0x0A91) ||
+ (c >= 0x0A93 && c <= 0x0AA8) ||
+ (c >= 0x0AAA && c <= 0x0AB0) ||
+ (c >= 0x0AB2 && c <= 0x0AB3) ||
+ (c >= 0x0AB5 && c <= 0x0AB9) ||
+ (c == 0x0ABD || c == 0x0AE0) ||
+ (c >= 0x0B05 && c <= 0x0B0C) ||
+ (c >= 0x0B0F && c <= 0x0B10) ||
+ (c >= 0x0B13 && c <= 0x0B28) ||
+ (c >= 0x0B2A && c <= 0x0B30) ||
+ (c >= 0x0B32 && c <= 0x0B33) ||
+ (c >= 0x0B36 && c <= 0x0B39) ||
+ (c == 0x0B3D) ||
+ (c >= 0x0B5C && c <= 0x0B5D) ||
+ (c >= 0x0B5F && c <= 0x0B61) ||
+ (c >= 0x0B85 && c <= 0x0B8A) ||
+ (c >= 0x0B8E && c <= 0x0B90) ||
+ (c >= 0x0B92 && c <= 0x0B95) ||
+ (c >= 0x0B99 && c <= 0x0B9A) ||
+ (c == 0x0B9C) ||
+ (c >= 0x0B9E && c <= 0x0B9F) ||
+ (c >= 0x0BA3 && c <= 0x0BA4) ||
+ (c >= 0x0BA8 && c <= 0x0BAA) ||
+ (c >= 0x0BAE && c <= 0x0BB5) ||
+ (c >= 0x0BB7 && c <= 0x0BB9) ||
+ (c >= 0x0C05 && c <= 0x0C0C) ||
+ (c >= 0x0C0E && c <= 0x0C10) ||
+ (c >= 0x0C12 && c <= 0x0C28) ||
+ (c >= 0x0C2A && c <= 0x0C33) ||
+ (c >= 0x0C35 && c <= 0x0C39) ||
+ (c >= 0x0C60 && c <= 0x0C61) ||
+ (c >= 0x0C85 && c <= 0x0C8C) ||
+ (c >= 0x0C8E && c <= 0x0C90) ||
+ (c >= 0x0C92 && c <= 0x0CA8) ||
+ (c >= 0x0CAA && c <= 0x0CB3) ||
+ (c >= 0x0CB5 && c <= 0x0CB9) ||
+ (c == 0x0CDE) ||
+ (c >= 0x0CE0 && c <= 0x0CE1) ||
+ (c >= 0x0D05 && c <= 0x0D0C) ||
+ (c >= 0x0D0E && c <= 0x0D10) ||
+ (c >= 0x0D12 && c <= 0x0D28) ||
+ (c >= 0x0D2A && c <= 0x0D39) ||
+ (c >= 0x0D60 && c <= 0x0D61) ||
+ (c >= 0x0E01 && c <= 0x0E2E) ||
+ (c == 0x0E30) ||
+ (c >= 0x0E32 && c <= 0x0E33) ||
+ (c >= 0x0E40 && c <= 0x0E45) ||
+ (c >= 0x0E81 && c <= 0x0E82) ||
+ (c == 0x0E84) ||
+ (c >= 0x0E87 && c <= 0x0E88) ||
+ (c == 0x0E8A || c == 0x0E8D) ||
+ (c >= 0x0E94 && c <= 0x0E97) ||
+ (c >= 0x0E99 && c <= 0x0E9F) ||
+ (c >= 0x0EA1 && c <= 0x0EA3) ||
+ (c == 0x0EA5 || c == 0x0EA7) ||
+ (c >= 0x0EAA && c <= 0x0EAB) ||
+ (c >= 0x0EAD && c <= 0x0EAE) ||
+ (c == 0x0EB0) ||
+ (c >= 0x0EB2 && c <= 0x0EB3) ||
+ (c == 0x0EBD) ||
+ (c >= 0x0EC0 && c <= 0x0EC4) ||
+ (c >= 0x0F40 && c <= 0x0F47) ||
+ (c >= 0x0F49 && c <= 0x0F69));
+ else
+ return ((c >= 0x10A0 && c <= 0x10C5) ||
+ (c >= 0x10D0 && c <= 0x10F6) ||
+ (c == 0x1100) ||
+ (c >= 0x1102 && c <= 0x1103) ||
+ (c >= 0x1105 && c <= 0x1107) ||
+ (c == 0x1109) ||
+ (c >= 0x110B && c <= 0x110C) ||
+ (c >= 0x110E && c <= 0x1112) ||
+ (c == 0x113C || c == 0x113E || c == 0x1140) ||
+ (c == 0x114C || c == 0x114E || c == 0x1150) ||
+ (c >= 0x1154 && c <= 0x1155) ||
+ (c == 0x1159) ||
+ (c >= 0x115F && c <= 0x1161) ||
+ (c == 0x1163) ||
+ (c == 0x1165) ||
+ (c == 0x1167) ||
+ (c == 0x1169) ||
+ (c >= 0x116D && c <= 0x116E) ||
+ (c >= 0x1172 && c <= 0x1173) ||
+ (c == 0x1175) ||
+ (c == 0x119E) ||
+ (c == 0x11A8) ||
+ (c == 0x11AB) ||
+ (c >= 0x11AE && c <= 0x11AF) ||
+ (c >= 0x11B7 && c <= 0x11B8) ||
+ (c == 0x11BA) ||
+ (c >= 0x11BC && c <= 0x11C2) ||
+ (c == 0x11EB) ||
+ (c == 0x11F0) ||
+ (c == 0x11F9) ||
+ (c >= 0x1E00 && c <= 0x1E9B) ||
+ (c >= 0x1EA0 && c <= 0x1EF9) ||
+ (c >= 0x1F00 && c <= 0x1F15) ||
+ (c >= 0x1F18 && c <= 0x1F1D) ||
+ (c >= 0x1F20 && c <= 0x1F45) ||
+ (c >= 0x1F48 && c <= 0x1F4D) ||
+ (c >= 0x1F50 && c <= 0x1F57) ||
+ (c == 0x1F59) ||
+ (c == 0x1F5B) ||
+ (c == 0x1F5D) ||
+ (c >= 0x1F5F && c <= 0x1F7D) ||
+ (c >= 0x1F80 && c <= 0x1FB4) ||
+ (c >= 0x1FB6 && c <= 0x1FBC) ||
+ (c == 0x1FBE) ||
+ (c >= 0x1FC2 && c <= 0x1FC4) ||
+ (c >= 0x1FC6 && c <= 0x1FCC) ||
+ (c >= 0x1FD0 && c <= 0x1FD3) ||
+ (c >= 0x1FD6 && c <= 0x1FDB) ||
+ (c >= 0x1FE0 && c <= 0x1FEC) ||
+ (c >= 0x1FF2 && c <= 0x1FF4) ||
+ (c >= 0x1FF6 && c <= 0x1FFC) ||
+ (c == 0x2126) ||
+ (c >= 0x212A && c <= 0x212B) ||
+ (c == 0x212E) ||
+ (c >= 0x2180 && c <= 0x2182) ||
+ (c >= 0x3041 && c <= 0x3094) ||
+ (c >= 0x30A1 && c <= 0x30FA) ||
+ (c >= 0x3105 && c <= 0x312C) ||
+ (c >= 0xAC00 && c <= 0xD7A3));
+};
+
+int
+ACEXML_ParserInt::isIdeographic_i (const ACEXML_Char c)
+{
+ return ((c >= 0x4E00 && c <= 0x9FA5) ||
+ (c == 3007) ||
+ (c >= 0x3021 && c <= 0x3029));
+}
+
+int
+ACEXML_ParserInt::isCombiningchar_i (const ACEXML_Char c)
+{
+ if (c < 0x0901)
+ return ((c >= 0x0300 && c <= 0x0345) ||
+ (c >= 0x0360 && c <= 0x0361) ||
+ (c >= 0x0483 && c <= 0x0486) ||
+ (c >= 0x0591 && c <= 0x05A1) ||
+ (c >= 0x05A3 && c <= 0x05B9) ||
+ (c >= 0x05BB && c <= 0x05BD) ||
+ (c == 0x05BF) ||
+ (c >= 0x05C1 && c <= 0x05C2) ||
+ (c == 0x05C4) ||
+ (c >= 0x064B && c <= 0x0652) ||
+ (c == 0x0670) ||
+ (c >= 0x06D6 && c <= 0x06DC) ||
+ (c >= 0x06DD && c <= 0x06DF) ||
+ (c >= 0x06E0 && c <= 0x06E4) ||
+ (c >= 0x06E7 && c <= 0x06E8) ||
+ (c >= 0x06EA && c <= 0x06ED));
+ else
+ return ((c >= 0x0901 && c <= 0x0903) ||
+ (c == 0x093C) ||
+ (c >= 0x093E && c <= 0x094C) ||
+ (c == 0x094D) ||
+ (c >= 0x0951 && c <= 0x0954) ||
+ (c >= 0x0962 && c <= 0x0963) ||
+ (c >= 0x0981 && c <= 0x0983) ||
+ (c == 0x09BC) ||
+ (c == 0x09BE) ||
+ (c == 0x09BF) ||
+ (c >= 0x09C0 && c <= 0x09C4) ||
+ (c >= 0x09C7 && c <= 0x09C8) ||
+ (c >= 0x09CB && c <= 0x09CD) ||
+ (c == 0x09D7) ||
+ (c >= 0x09E2 && c <= 0x09E3) ||
+ (c == 0x0A02) ||
+ (c == 0x0A3C) ||
+ (c == 0x0A3E) ||
+ (c == 0x0A3F) ||
+ (c >= 0x0A40 && c <= 0x0A42) ||
+ (c >= 0x0A47 && c <= 0x0A48) ||
+ (c >= 0x0A4B && c <= 0x0A4D) ||
+ (c >= 0x0A70 && c <= 0x0A71) ||
+ (c >= 0x0A81 && c <= 0x0A83) ||
+ (c == 0x0ABC) ||
+ (c >= 0x0ABE && c <= 0x0AC5) ||
+ (c >= 0x0AC7 && c <= 0x0AC9) ||
+ (c >= 0x0ACB && c <= 0x0ACD) ||
+ (c >= 0x0B01 && c <= 0x0B03) ||
+ (c == 0x0B3C) ||
+ (c >= 0x0B3E && c <= 0x0B43) ||
+ (c >= 0x0B47 && c <= 0x0B48) ||
+ (c >= 0x0B4B && c <= 0x0B4D) ||
+ (c >= 0x0B56 && c <= 0x0B57) ||
+ (c >= 0x0B82 && c <= 0x0B83) ||
+ (c >= 0x0BBE && c <= 0x0BC2) ||
+ (c >= 0x0BC6 && c <= 0x0BC8) ||
+ (c >= 0x0BCA && c <= 0x0BCD) ||
+ (c == 0x0BD7) ||
+ (c >= 0x0C01 && c <= 0x0C03) ||
+ (c >= 0x0C3E && c <= 0x0C44) ||
+ (c >= 0x0C46 && c <= 0x0C48) ||
+ (c >= 0x0C4A && c <= 0x0C4D) ||
+ (c >= 0x0C55 && c <= 0x0C56) ||
+ (c >= 0x0C82 && c <= 0x0C83) ||
+ (c >= 0x0CBE && c <= 0x0CC4) ||
+ (c >= 0x0CC6 && c <= 0x0CC8) ||
+ (c >= 0x0CCA && c <= 0x0CCD) ||
+ (c >= 0x0CD5 && c <= 0x0CD6) ||
+ (c >= 0x0D02 && c <= 0x0D03) ||
+ (c >= 0x0D3E && c <= 0x0D43) ||
+ (c >= 0x0D46 && c <= 0x0D48) ||
+ (c >= 0x0D4A && c <= 0x0D4D) ||
+ (c == 0x0D57) ||
+ (c == 0x0E31) ||
+ (c >= 0x0E34 && c <= 0x0E3A) ||
+ (c >= 0x0E47 && c <= 0x0E4E) ||
+ (c == 0x0EB1) ||
+ (c >= 0x0EB4 && c <= 0x0EB9) ||
+ (c >= 0x0EBB && c <= 0x0EBC) ||
+ (c >= 0x0EC8 && c <= 0x0ECD) ||
+ (c >= 0x0F18 && c <= 0x0F19) ||
+ (c == 0x0F35) ||
+ (c == 0x0F37) ||
+ (c == 0x0F39) ||
+ (c == 0x0F3E) ||
+ (c == 0x0F3F) ||
+ (c >= 0x0F71 && c <= 0x0F84) ||
+ (c >= 0x0F86 && c <= 0x0F8B) ||
+ (c >= 0x0F90 && c <= 0x0F95) ||
+ (c == 0x0F97) ||
+ (c >= 0x0F99 && c <= 0x0FAD) ||
+ (c >= 0x0FB1 && c <= 0x0FB7) ||
+ (c == 0x0FB9) ||
+ (c >= 0x20D0 && c <= 0x20DC) ||
+ (c == 0x20E1) ||
+ (c >= 0x302A && c <= 0x302F) ||
+ (c == 0x3099) ||
+ (c == 0x309A));
+}
+
+int
+ACEXML_ParserInt::isDigit_i (const ACEXML_Char c)
+{
+ if (c < 0x0040)
+ return (c >= 0x0030 && c <= 0x0039);
+ else
+ return ((c >= 0x0660 && c <= 0x0669) ||
+ (c >= 0x06F0 && c <= 0x06F9) ||
+ (c >= 0x0966 && c <= 0x096F) ||
+ (c >= 0x09E6 && c <= 0x09EF) ||
+ (c >= 0x0A66 && c <= 0x0A6F) ||
+ (c >= 0x0AE6 && c <= 0x0AEF) ||
+ (c >= 0x0B66 && c <= 0x0B6F) ||
+ (c >= 0x0BE7 && c <= 0x0BEF) ||
+ (c >= 0x0C66 && c <= 0x0C6F) ||
+ (c >= 0x0CE6 && c <= 0x0CEF) ||
+ (c >= 0x0D66 && c <= 0x0D6F) ||
+ (c >= 0x0E50 && c <= 0x0E59) ||
+ (c >= 0x0ED0 && c <= 0x0ED9) ||
+ (c >= 0x0F20 && c <= 0x0F29));
+}
+
+int
+ACEXML_ParserInt::isExtender_i (const ACEXML_Char c)
+{
+ // The compiler should generate a jump table and index into it directly.
+ switch (c)
+ {
+ case 0x00B7: case 0x02D0: case 0x02D1: case 0x0387: case 0x0640:
+ case 0x0E46: case 0x0EC6: case 0x3005: case 0x3031: case 0x3032:
+ case 0x3033: case 0x3034: case 0x3035: case 0x309D: case 0x309E:
+ case 0x30FC: case 0x30FD: case 0x30FE:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+#endif /* ACE_USES_WCHAR */
diff --git a/ACE/ACEXML/parser/parser/ParserInternals.h b/ACE/ACEXML/parser/parser/ParserInternals.h
new file mode 100644
index 00000000000..88de5e747de
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/ParserInternals.h
@@ -0,0 +1,104 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ParserInternals.h
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_PARSER_INTERNALS_H_
+#define _ACEXML_PARSER_INTERNALS_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 */
+
+#include "ACEXML/common/XML_Types.h"
+
+/**
+ * @class ACEXML_ParserInt ParserInternals.h "ACEXML/parser/parser/ParserInternals.h"
+ *
+ * @brief A class to hide some of the internal implementation details of
+ * the parser.
+ *
+ */
+class ACEXML_PARSER_Export ACEXML_ParserInt
+{
+
+public:
+#if defined (ACE_USES_WCHAR)
+
+ /**
+ * Check if a character @a c is a BaseChar. This method checks for the
+ * complete set of characters allowed when WCHAR support is enabled.
+ *
+ * @retval 1 if @a c is a valid XML Character, 0 otherwise.
+ */
+ static int isBasechar_i (const ACEXML_Char c);
+
+ /**
+ * Check if a character @a c is a Ideographic. This method checks for the
+ * complete set of characters allowed when WCHAR support is enabled.
+ *
+ * @retval 1 if @a c is a valid XML Character, 0 otherwise.
+ */
+ static int isIdeographic_i (const ACEXML_Char c);
+
+ /**
+ * Check if a character @a c is a CombiningChar. This method checks for the
+ * complete set of characters allowed when WCHAR support is enabled.
+ *
+ * @retval 1 if @a c is a valid XML Character, 0 otherwise.
+ */
+ static int isCombiningchar_i (const ACEXML_Char c);
+
+ /**
+ * Check if a character @a c is a Digit. This method checks for the
+ * complete set of characters allowed when WCHAR support is enabled.
+ *
+ * @retval 1 if @a c is a valid XML Character, 0 otherwise.
+ */
+ static int isDigit_i (const ACEXML_Char c);
+
+ /**
+ * Check if a character @a c is an Extender. This method checks for the
+ * complete set of characters allowed when WCHAR support is enabled.
+ *
+ * @retval 1 if @a c is a valid XML Character, 0 otherwise.
+ */
+ static int isExtender_i (const ACEXML_Char c);
+
+#endif /* ACE_USES_WCHAR */
+
+ static const ACEXML_Char base_char_table_[256];
+
+ static const ACEXML_Char* msg_[];
+
+ static const ACEXML_Char* predef_ent_[];
+
+ static const ACEXML_Char* predef_val_[];
+
+ // Enum describing the position in a document when a reference occurs.
+ enum ReferenceState {
+ IN_CONTENT,
+ IN_ATT_VALUE,
+ AS_ATT_VALUE,
+ IN_ENTITY_VALUE,
+ IN_INT_DTD,
+ IN_EXT_DTD,
+ IN_NOTATION,
+ INVALID = -1
+ };
+
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_PARSER_INTERNALS_H_ */
diff --git a/ACE/ACEXML/parser/parser/Parser_export.h b/ACE/ACEXML/parser/parser/Parser_export.h
new file mode 100644
index 00000000000..71630ccd962
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/Parser_export.h
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Parser_export.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+// Definition for Win32 Export directives.
+// This file is generated automatically by generate_export_file.pl
+// ------------------------------
+#ifndef ACEXML_PARSER_EXPORT_H
+#define ACEXML_PARSER_EXPORT_H
+
+#include "ace/config-all.h"
+
+#if defined (ACE_AS_STATIC_LIBS) && !defined (ACEXML_PARSER_HAS_DLL)
+# define ACEXML_PARSER_HAS_DLL 0
+#endif /* ACE_AS_STATIC_LIBS && ACEXML_PARSER_HAS_DLL */
+
+#if !defined (ACEXML_PARSER_HAS_DLL)
+# define ACEXML_PARSER_HAS_DLL 1
+#endif /* ! ACEXML_PARSER_HAS_DLL */
+
+#if defined (ACEXML_PARSER_HAS_DLL) && (ACEXML_PARSER_HAS_DLL == 1)
+# if defined (ACEXML_PARSER_BUILD_DLL)
+# define ACEXML_PARSER_Export ACE_Proper_Export_Flag
+# define ACEXML_PARSER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define ACEXML_PARSER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* ACEXML_PARSER_BUILD_DLL */
+# define ACEXML_PARSER_Export ACE_Proper_Import_Flag
+# define ACEXML_PARSER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define ACEXML_PARSER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* ACEXML_PARSER_BUILD_DLL */
+#else /* ACEXML_PARSER_HAS_DLL == 1 */
+# define ACEXML_PARSER_Export
+# define ACEXML_PARSER_SINGLETON_DECLARATION(T)
+# define ACEXML_PARSER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* ACEXML_PARSER_HAS_DLL == 1 */
+
+#endif /* ACEXML_PARSER_EXPORT_H */
+
+// End of auto generated file.
diff --git a/ACE/ACEXML/parser/parser/parser.mpc b/ACE/ACEXML/parser/parser/parser.mpc
new file mode 100644
index 00000000000..9732f03fe76
--- /dev/null
+++ b/ACE/ACEXML/parser/parser/parser.mpc
@@ -0,0 +1,14 @@
+// -*- MPC -*-
+// $Id$
+
+project(ACEXML_Parser): acelib, core {
+ avoids += ace_for_tao
+ sharedname = ACEXML_Parser
+ after += ACEXML
+ libs += ACEXML
+ dynamicflags += ACEXML_PARSER_BUILD_DLL
+
+ Pkgconfig_Files {
+ ACEXML_Parser.pc.in
+ }
+}
diff --git a/ACE/ACEXML/tests/ContentHandler_Test.cpp b/ACE/ACEXML/tests/ContentHandler_Test.cpp
new file mode 100644
index 00000000000..ec4315f892a
--- /dev/null
+++ b/ACE/ACEXML/tests/ContentHandler_Test.cpp
@@ -0,0 +1,103 @@
+//=============================================================================
+/**
+ * @file ContentHandler_Test.cpp
+ *
+ * $Id$
+ *
+ * @author Steve Huston <shuston@riverace.com>
+ */
+//=============================================================================
+
+#include "ACEXML/common/DefaultHandler.h"
+#include "ACEXML/common/InputSource.h"
+#include "ACEXML/common/StrCharStream.h"
+#include "ACEXML/parser/parser/Parser.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_main.h"
+
+class Basic_Content_Tester : public ACEXML_DefaultHandler
+{
+public:
+ /**
+ * Receive notification of character data.
+ */
+ virtual void characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ const ACEXML_Char *get_test_string (void)
+ { return Basic_Content_Tester::test_string_; }
+
+private:
+ static const ACEXML_Char *test_string_;
+};
+
+const ACEXML_Char * Basic_Content_Tester::test_string_ =
+ ACE_TEXT ("<?xml version=\"1.0\"?>")
+ ACE_TEXT ("<translation type=\"unfinished\">Example\n")
+ ACE_TEXT ("d&apos;internationalisation</translation>");
+
+void
+Basic_Content_Tester::characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ static int already_called = 0;
+ static const ACEXML_Char *expect =
+ ACE_TEXT ("Example\nd'internationalisation");
+
+ if (already_called)
+ {
+ ACEXML_THROW (ACEXML_SAXException
+ (ACE_TEXT ("characters() called too much\n")));
+ }
+ already_called = 1;
+
+ int expected_len = static_cast<int> (ACE_OS::strlen (expect));
+ if (length != expected_len)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("characters() expected len %d (%*s); ")
+ ACE_TEXT ("got %d (%*s)\n"),
+ expected_len, expected_len, ch + start,
+ length, length, ch + start));
+ ACEXML_THROW (ACEXML_SAXException (ACE_TEXT ("Functionality failure")));
+ }
+ return;
+}
+
+int
+ACE_TMAIN (int, ACE_TCHAR *[])
+{
+ int status = 0;
+ Basic_Content_Tester tester;
+ ACEXML_StrCharStream *test_stream = 0;
+ ACE_NEW_RETURN (test_stream, ACEXML_StrCharStream, -1);
+ if (test_stream->open (tester.get_test_string (),
+ ACE_TEXT ("test_stream")) < 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unable to create input stream\n")));
+ return -1;
+ }
+ ACEXML_InputSource input (test_stream);
+ ACEXML_Parser parser;
+ parser.setContentHandler (&tester);
+ ACEXML_TRY_NEW_ENV
+ {
+ parser.setFeature (ACE_TEXT ("http://xml.org/sax/features/validation"),
+ 0
+ ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_TRY_CHECK;
+ parser.parse (&input ACEXML_ENV_ARG_PARAMETER);
+ ACEXML_TRY_CHECK;
+ }
+ ACEXML_CATCH (ACEXML_SAXException, ex)
+ {
+ ex.print();
+ status = 1;
+ }
+ ACEXML_ENDTRY;
+ return status;
+}
diff --git a/ACE/ACEXML/tests/HttpCharStream_Test.cpp b/ACE/ACEXML/tests/HttpCharStream_Test.cpp
new file mode 100644
index 00000000000..ba969753a3d
--- /dev/null
+++ b/ACE/ACEXML/tests/HttpCharStream_Test.cpp
@@ -0,0 +1,40 @@
+// $Id$
+
+#include "ACEXML/common/HttpCharStream.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_main.h"
+
+int ACE_TMAIN (int, ACE_TCHAR *[])
+{
+ const ACEXML_Char* test = ACE_TEXT("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd");
+
+ const ACEXML_Char* simple = ACE_TEXT("http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent");
+
+ ACEXML_HttpCharStream first;
+ ACEXML_HttpCharStream second;
+ ACEXML_Char ch;
+
+ if (first.open (test) != -1)
+ {
+ while (first.get (ch) != -1)
+ ACE_OS::printf ("%c", ch);
+ }
+ else
+ {
+ first.close();
+ ACE_ERROR ((LM_ERROR, "Error in opening stream : %m\n"));
+ }
+ if (second.open (simple) != -1)
+ {
+ while (second.get (ch) != -1)
+ ACE_OS::printf ("%c", ch);
+ }
+ else
+ {
+ second.close();
+ ACE_ERROR ((LM_ERROR, "Error in opening stream : %m\n"));
+ }
+ first.close();
+ second.close();
+ return 0;
+}
diff --git a/ACE/ACEXML/tests/Makefile.am b/ACE/ACEXML/tests/Makefile.am
new file mode 100644
index 00000000000..926a3fd9212
--- /dev/null
+++ b/ACE/ACEXML/tests/Makefile.am
@@ -0,0 +1,114 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+ACE_BUILDDIR = $(top_builddir)
+ACE_ROOT = $(top_srcdir)
+
+SUBDIRS = \
+ . \
+ util
+
+noinst_PROGRAMS =
+
+## Makefile.ContentHandler_Test.am
+
+if BUILD_ACEXML
+if !BUILD_ACE_FOR_TAO
+noinst_PROGRAMS += ContentHandler_Test
+
+ContentHandler_Test_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(ACE_ROOT)/ACEXML/common
+
+ContentHandler_Test_SOURCES = \
+ ContentHandler_Test.cpp
+
+ContentHandler_Test_LDADD = \
+ $(ACE_BUILDDIR)/ACEXML/parser/parser/libACEXML_Parser.la \
+ $(ACE_BUILDDIR)/ACEXML/common/libACEXML.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif !BUILD_ACE_FOR_TAO
+endif BUILD_ACEXML
+
+## Makefile.HttpCharStream_Test.am
+
+if BUILD_ACEXML
+if !BUILD_ACE_FOR_TAO
+noinst_PROGRAMS += HttpCharStream_Test
+
+HttpCharStream_Test_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(ACE_ROOT)/ACEXML/common
+
+HttpCharStream_Test_SOURCES = \
+ HttpCharStream_Test.cpp
+
+HttpCharStream_Test_LDADD = \
+ $(ACE_BUILDDIR)/ACEXML/parser/parser/libACEXML_Parser.la \
+ $(ACE_BUILDDIR)/ACEXML/common/libACEXML.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif !BUILD_ACE_FOR_TAO
+endif BUILD_ACEXML
+
+## Makefile.NamespaceSupport_Test.am
+
+if BUILD_ACEXML
+if !BUILD_ACE_FOR_TAO
+noinst_PROGRAMS += NamespaceSupport_Test
+
+NamespaceSupport_Test_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(ACE_ROOT)/ACEXML/common
+
+NamespaceSupport_Test_SOURCES = \
+ NamespaceSupport_Test.cpp
+
+NamespaceSupport_Test_LDADD = \
+ $(ACE_BUILDDIR)/ACEXML/parser/parser/libACEXML_Parser.la \
+ $(ACE_BUILDDIR)/ACEXML/common/libACEXML.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif !BUILD_ACE_FOR_TAO
+endif BUILD_ACEXML
+
+## Makefile.Transcoder_Test.am
+
+if BUILD_ACEXML
+if !BUILD_ACE_FOR_TAO
+noinst_PROGRAMS += Transcoder_Test
+
+Transcoder_Test_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(ACE_ROOT)/ACEXML/common
+
+Transcoder_Test_SOURCES = \
+ Transcoder_Test.cpp
+
+Transcoder_Test_LDADD = \
+ $(ACE_BUILDDIR)/ACEXML/parser/parser/libACEXML_Parser.la \
+ $(ACE_BUILDDIR)/ACEXML/common/libACEXML.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif !BUILD_ACE_FOR_TAO
+endif BUILD_ACEXML
+
+## Clean up template repositories, etc.
+clean-local:
+ -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.*
+ -rm -f gcctemp.c gcctemp so_locations *.ics
+ -rm -rf cxx_repository ptrepository ti_files
+ -rm -rf templateregistry ir.out
+ -rm -rf ptrepository SunWS_cache Templates.DB
diff --git a/ACE/ACEXML/tests/NamespaceSupport_Test.cpp b/ACE/ACEXML/tests/NamespaceSupport_Test.cpp
new file mode 100644
index 00000000000..2632c6dc571
--- /dev/null
+++ b/ACE/ACEXML/tests/NamespaceSupport_Test.cpp
@@ -0,0 +1,150 @@
+// $Id$
+
+#include "ACEXML/common/NamespaceSupport.h"
+#include "ace/OS_main.h"
+
+int ACE_TMAIN (int, ACE_TCHAR *[])
+{
+ ACEXML_NamespaceSupport xmlns;
+ if (xmlns.init() == -1)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Error in initializing namespace support.")));
+ return 1;
+ }
+ xmlns.pushContext();
+ xmlns.declarePrefix(ACE_TEXT (""),
+ ACE_TEXT ("http://www.w3.org/1999/xhtml"));
+ xmlns.declarePrefix(ACE_TEXT ("dc"),
+ ACE_TEXT ("http://www.purl.org/dc#"));
+ xmlns.declarePrefix(ACE_TEXT ("xc"),
+ ACE_TEXT ("http://www.purl.org/dc#"));
+
+ const ACEXML_Char *lName, *uri;
+ const ACEXML_Char *n1 = ACE_TEXT ("p");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("*** Checking processName:\n")));
+ if (xmlns.processName (n1, uri, lName, 0) != 0)
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("Fail to resolve namespace name %s\n"),
+ n1));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Namespace URI: %s\nLocal name: %s\nRaw name: %s\n"),
+ uri, lName, n1));
+
+ const ACEXML_Char *n2 = ACE_TEXT ("dc:title");
+ if (xmlns.processName(n2, uri, lName, 0) != 0)
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("Fail to resolve namespace name %S\n"),
+ n2));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Namespace URI: %s\nLocal name: %s\nRaw name: %s\n"),
+ uri, lName, n2));
+
+ const ACEXML_Char *n3 = ACE_TEXT ("xml:title");
+ if (xmlns.processName(n3, uri, lName, 0) != 0)
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("Fail to resolve namespace name %S\n"),
+ n3));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Namespace URI: %s\nLocal name: %s\nRaw name: %s\n"),
+ uri, lName, n3));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\n*** Checking getDeclaredPrefixes\n")));
+
+ ACEXML_STR_LIST prefixes;
+ if (xmlns.getDeclaredPrefixes (prefixes) != 0)
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("Fail to get a list of declared prefixes\n")));
+ else
+ {
+ ACEXML_STR_LIST::ITERATOR iter = prefixes.begin ();
+ const ACEXML_Char **prefix = 0;
+
+ for (; iter.next (prefix);iter.advance ())
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prefix: \"%s\"\n"), *prefix));
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getPrefix\n")));
+ const ACEXML_Char *prefix = 0;
+
+ if ((prefix = xmlns.getPrefix (ACE_TEXT ("http://www.purl.org/dc#"))) == 0)
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("Fail to get prefix of http://www.purl.org/dc#\n")));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Prefix of http://www.purl.org/dc# is %s\n"),
+ prefix));
+
+ if ((prefix = xmlns.getPrefix (ACE_TEXT ("http://www.w3.org/1999/xhtml"))) == 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Fail to get prefix of http://www.w3.org/1999/xhtml which is okay\n")));
+ else
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("ERROR: Prefix of http://www.w3.org/1999/xhtml is %s\n"),
+ prefix));
+
+ if ((prefix = xmlns.getPrefix (ACE_TEXT ("http://www.w3.org/XML/1998/namespace"))) == 0)
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("Fail to get prefix of http://www.w3.org/XML/1998/namespace\n")));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Prefix of http://www.w3.org/XML/1998/namespace is %s\n"),
+ prefix));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getPrefixes with known URI\n")));
+ prefixes.reset ();
+
+ if (xmlns.getPrefixes (ACE_TEXT ("http://www.purl.org/dc#"), prefixes) != 0)
+ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to getPrefixes based on known URI\n")));
+ else
+ {
+ ACEXML_STR_LIST::ITERATOR iter = prefixes.begin ();
+ const ACEXML_Char **prefix = 0;
+
+ for (; iter.next (prefix);iter.advance ())
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prefix: \"%s\"\n"), *prefix));
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getPrefixes\n")));
+ prefixes.reset ();
+
+ if (xmlns.getPrefixes (prefixes) != 0)
+ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to getPrefixes\n")));
+ else
+ {
+ ACEXML_STR_LIST::ITERATOR iter = prefixes.begin ();
+ const ACEXML_Char **prefix = 0;
+
+ for (; iter.next (prefix);iter.advance ())
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prefix: \"%s\"\n"), *prefix));
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getURI\n")));
+ const ACEXML_Char *URI = 0;
+
+ if ((URI = xmlns.getURI (ACE_TEXT ("dc"))) == 0)
+ ACE_DEBUG((LM_ERROR, ACE_TEXT ("Fail to get URI for \"dc\"\n")));
+ else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("URI for \"dc\" is %s\n"), URI));
+ if ((URI = xmlns.getURI (ACE_TEXT ("xc"))) == 0)
+ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to get URI for \"xc\"\n")));
+ else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("URI for \"xc\" is %s\n"), URI));
+ if ((URI = xmlns.getURI (ACE_TEXT ("xml"))) == 0)
+ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to get URI for \"xml\"\n")));
+ else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("URI for \"xml\" is %s\n"), URI));
+ if ((URI = xmlns.getURI (ACE_TEXT (""))) == 0)
+ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to get default namespace URI\n")));
+ else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("URI for default namespace is %s\n"), URI));
+
+ xmlns.popContext();
+
+ return 0;
+}
diff --git a/ACE/ACEXML/tests/Transcoder_Test.cpp b/ACE/ACEXML/tests/Transcoder_Test.cpp
new file mode 100644
index 00000000000..f5dc289e5e0
--- /dev/null
+++ b/ACE/ACEXML/tests/Transcoder_Test.cpp
@@ -0,0 +1,71 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/Transcode.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_main.h"
+
+void dump_utf16 (const ACEXML_UTF16 *data,
+ size_t len)
+{
+ size_t ptr = 0;
+
+ while (1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "%04x", data[ptr]));
+
+ if (++ptr >= len)
+ break;
+
+ if (ptr % 4 == 0)
+ ACE_DEBUG ((LM_DEBUG, "\n"));
+ else
+ ACE_DEBUG ((LM_DEBUG, " "));
+ }
+ ACE_DEBUG ((LM_DEBUG, "\n"));
+ return;
+}
+
+int
+ACE_TMAIN (int, ACE_TCHAR*[])
+{
+ ACEXML_UTF16 org [18];
+// = { 1, 2, 4, 8, 0x10, 0x20, 0x40,
+// 0x80,
+// 0x100, 0x200, 0x400,
+// 0x800, 0x801, 0x802, 0x804, 0x808, 0x810, 0x820,
+// 0x840, 0x880, 0x900, 0xa00, 0xc00,
+// 0x1000, 0x2000, 0x4000, 0x8000, 0 }
+ ACEXML_UCS4 temp = 1;
+
+ ACE_OS::memset (org, 0, sizeof org);
+ size_t x;
+
+ for (x = 0; temp < 0x10000; x++, temp <<= 1)
+ {
+ org[x] = static_cast<ACEXML_UTF16> (temp);
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "Original UTF16 string:\n"));
+ dump_utf16 (org, x);
+ ACE_DEBUG ((LM_DEBUG, "\n\n"));
+
+ ACEXML_UTF8 decoded [MAXPATHLEN];
+ ACE_OS::memset (decoded, 0, sizeof decoded);
+
+ ACEXML_Transcoder::utf16s2utf8s (org, decoded, MAXPATHLEN);
+
+ ACE_DEBUG ((LM_DEBUG, "Transcoded UTF8 string:\n"));
+ ACE_HEX_DUMP ((LM_DEBUG, decoded, ACE_OS::strlen (decoded) + 1));
+ ACE_DEBUG ((LM_DEBUG, "\n\n"));
+
+ ACEXML_UTF16 after [18];
+ ACE_OS::memset (after, 0, sizeof after);
+ ACEXML_Transcoder::utf8s2utf16s (decoded, after, 18);
+
+ ACE_DEBUG ((LM_DEBUG, "Restored UTF16 string:\n"));
+ dump_utf16 (after, x);
+ ACE_DEBUG ((LM_DEBUG, "\n\n"));
+
+ return 0;
+}
diff --git a/ACE/ACEXML/tests/tests.mpc b/ACE/ACEXML/tests/tests.mpc
new file mode 100644
index 00000000000..e0a2365e689
--- /dev/null
+++ b/ACE/ACEXML/tests/tests.mpc
@@ -0,0 +1,30 @@
+// -*- MPC -*-
+// $Id$
+
+project(Transcoder_Test): aceexe, acexml {
+ exename = Transcoder_Test
+ Source_Files {
+ Transcoder_Test.cpp
+ }
+}
+
+project(NamespaceSupport_Test): aceexe, acexml {
+ exename = NamespaceSupport_Test
+ Source_Files {
+ NamespaceSupport_Test.cpp
+ }
+}
+
+project(HttpCharStream_Test): aceexe, acexml {
+ exename = HttpCharStream_Test
+ Source_Files {
+ HttpCharStream_Test.cpp
+ }
+}
+
+project(ContentHandler_Test): aceexe, acexml {
+ exename = ContentHandler_Test
+ Source_Files {
+ ContentHandler_Test.cpp
+ }
+}
diff --git a/ACE/ACEXML/tests/util/Makefile.am b/ACE/ACEXML/tests/util/Makefile.am
new file mode 100644
index 00000000000..486d37c1902
--- /dev/null
+++ b/ACE/ACEXML/tests/util/Makefile.am
@@ -0,0 +1,43 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+ACE_BUILDDIR = $(top_builddir)
+ACE_ROOT = $(top_srcdir)
+
+
+## Makefile.util.am
+
+if BUILD_ACEXML
+if !BUILD_ACE_FOR_TAO
+noinst_PROGRAMS = test
+
+test_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(ACE_ROOT)/ACEXML/common
+
+test_SOURCES = \
+ test.cpp
+
+test_LDADD = \
+ $(ACE_BUILDDIR)/ACEXML/parser/parser/libACEXML_Parser.la \
+ $(ACE_BUILDDIR)/ACEXML/common/libACEXML.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif !BUILD_ACE_FOR_TAO
+endif BUILD_ACEXML
+
+## Clean up template repositories, etc.
+clean-local:
+ -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.*
+ -rm -f gcctemp.c gcctemp so_locations *.ics
+ -rm -rf cxx_repository ptrepository ti_files
+ -rm -rf templateregistry ir.out
+ -rm -rf ptrepository SunWS_cache Templates.DB
diff --git a/ACE/ACEXML/tests/util/test.cpp b/ACE/ACEXML/tests/util/test.cpp
new file mode 100644
index 00000000000..40f0eb41001
--- /dev/null
+++ b/ACE/ACEXML/tests/util/test.cpp
@@ -0,0 +1,111 @@
+// $Id$
+// A simple test for performance of the ACEXML_escape_string() function
+
+#include "ACEXML/common/XML_Util.h"
+
+#include "ace/OS_main.h"
+#include "ace/Time_Value.h"
+#include "ace/OS_NS_sys_time.h"
+#include "ace/Log_Msg.h"
+
+const int MAX_ITERATIONS = 100 * 1000;
+const int NUM_TEST_STRS = 6;
+
+static bool is_escaped(const ACEXML_String& s)
+{
+ if (s[0] != ACE_TEXT('&'))
+ return false;
+ if (s[s.length() - 1] != ACE_TEXT(';'))
+ return false;
+ return true;
+}
+
+static int run_tests(ACEXML_String test_strings[NUM_TEST_STRS], int iterations)
+{
+ // Test 1 - Escape the strings using a new temporary string each iteration.
+ ACE_Time_Value start = ACE_OS::gettimeofday();
+ int i = 0;
+ for (i = 0; i < iterations; ++i)
+ {
+ ACEXML_String tmp = ACEXML_escape_string(test_strings[i % NUM_TEST_STRS]);
+ if (! is_escaped(tmp))
+ {
+ ACE_ERROR((LM_ERROR, "Error: Failed to escape string\n"));
+ return 1;
+ }
+ }
+ ACE_DEBUG((LM_DEBUG, "Test1 took %dms\n", (ACE_OS::gettimeofday() - start).msec()));
+
+ // Test 2 - Escape the strings using a shared temporary string. This shouldn't
+ // be any faster than Test 1 as long as the compiler has return value optimization.
+ ACEXML_String tmp;
+ start = ACE_OS::gettimeofday();
+ for (i = 0; i < iterations; ++i)
+ {
+ tmp = ACEXML_escape_string(test_strings[i % NUM_TEST_STRS]);
+ if (! is_escaped(tmp))
+ {
+ ACE_ERROR((LM_ERROR, "Error: Failed to escape string\n"));
+ return 1;
+ }
+ }
+ ACE_DEBUG((LM_DEBUG, "Test2 took %dms\n", (ACE_OS::gettimeofday() - start).msec()));
+
+ // Test 3 - Escape the strings using a shared temporary string. This time, we use
+ // the alternate form of ACEXML_escape_string() so that our temporary buffer is reused.
+ tmp.clear(1);
+ start = ACE_OS::gettimeofday();
+ for (i = 0; i < iterations; ++i)
+ {
+ ACEXML_escape_string(test_strings[i % NUM_TEST_STRS], tmp);
+ if (! is_escaped(tmp))
+ {
+ ACE_ERROR((LM_ERROR, "Error: Failed to escape string\n"));
+ return 1;
+ }
+ }
+ ACE_DEBUG((LM_DEBUG, "Test3 took %dms\n", (ACE_OS::gettimeofday() - start).msec()));
+
+ // Test 4 - Same as Test 3, except that the tmp buffer shouldn't have to resize.
+ start = ACE_OS::gettimeofday();
+ for (i = 0; i < iterations; ++i)
+ {
+ ACEXML_escape_string(test_strings[i % NUM_TEST_STRS], tmp);
+ if (! is_escaped(tmp))
+ {
+ ACE_ERROR((LM_ERROR, "Error: Failed to escape string\n"));
+ return 1;
+ }
+ }
+ ACE_DEBUG((LM_DEBUG, "Test4 took %dms\n", (ACE_OS::gettimeofday() - start).msec()));
+ return 0;
+}
+
+int ACE_TMAIN (int, ACE_TCHAR *[])
+{
+ ACEXML_String test_strings[NUM_TEST_STRS] = {
+ ACE_TEXT("\"xxxxx\"xxxxxxxx xx\"xxxxxx xxxxxx\"xxxxxxxxxx xxxxxxxx\"xxxxxx\""),
+ ACE_TEXT("'xxxxx\'xxxxxxxx' xxxxxxxx xx'xxxxxxxx'xxxxxx xxxxxxx'xxxxxxx'"),
+ ACE_TEXT("&xxxx&xxxxxxxxx &xxxxxxxx xxxxx&xxxxxxxxxxx xxxx&xxxxxxxxxx&"),
+ ACE_TEXT(">xx>xxxxxxxxxxx >xxxxxxxx xxxxx>xxxxxxxxxxx xxxxx>xxxxxxxxx>"),
+ ACE_TEXT("<xxxxx<xxxxxxxx xxxxxxxx <xxxxxxxxxxxxxxx<x xxxxxxxxxxxxxx<"),
+ ACE_TEXT("&xxxx\"xxxxxxx&xx xxx'xxxxx xx<xxxxxxx>xxxxxxx xx\"xxxxxxxxxxxx>"),
+ };
+
+ if (run_tests(test_strings, MAX_ITERATIONS) != 0)
+ return 1;
+
+ ACE_DEBUG((LM_DEBUG, "Rerun tests with larger strings\n"));
+ for (int i = 0; i < NUM_TEST_STRS; ++i)
+ {
+ for (int j = 0; j < 5; ++j)
+ {
+ test_strings[i] += test_strings[i];
+ }
+ }
+
+ if (run_tests(test_strings, MAX_ITERATIONS / 10) != 0)
+ return 1;
+
+ return 0;
+}
diff --git a/ACE/ACEXML/tests/util/util.mpc b/ACE/ACEXML/tests/util/util.mpc
new file mode 100644
index 00000000000..4deaa3719c4
--- /dev/null
+++ b/ACE/ACEXML/tests/util/util.mpc
@@ -0,0 +1,4 @@
+// $Id$
+project: aceexe, acexml {
+ exename = test
+}