diff options
Diffstat (limited to 'ACEXML/examples/SAXPrint')
-rw-r--r-- | ACEXML/examples/SAXPrint/Makefile | 49 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/Print_Handler.cpp | 209 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/Print_Handler.h | 179 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/Print_Handler.i | 1 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/SAXPrint.dsp | 130 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/SAXPrint.dsw | 29 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp | 222 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/SAXPrint_Handler.h | 190 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/SAXPrint_Handler.i | 13 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/main.cpp | 49 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/ns.svc.conf.xml | 46 | ||||
-rw-r--r-- | ACEXML/examples/SAXPrint/svc.conf.xml | 47 |
12 files changed, 1164 insertions, 0 deletions
diff --git a/ACEXML/examples/SAXPrint/Makefile b/ACEXML/examples/SAXPrint/Makefile new file mode 100644 index 00000000000..4dfd9239bc0 --- /dev/null +++ b/ACEXML/examples/SAXPrint/Makefile @@ -0,0 +1,49 @@ +#---------------------------------------------------------------------------- +# $Id$ +# +# Makefile for repeating token client application +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +LDLIBS = -lACEXML_Parser -lACEXML +FILES = Print_Handler \ + SAXPrint_Handler + +SRC = $(addsuffix .cpp,$(FILES)) +OBJ = $(LSRC:%.cpp=$(VDIR)%.o) +CCFLAGS += -I ../.. + +BIN = main + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU +include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + + + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/ACEXML/examples/SAXPrint/Print_Handler.cpp b/ACEXML/examples/SAXPrint/Print_Handler.cpp new file mode 100644 index 00000000000..d1248a7f8ab --- /dev/null +++ b/ACEXML/examples/SAXPrint/Print_Handler.cpp @@ -0,0 +1,209 @@ +// -*- C++ -*- $Id$ + +#include "Print_Handler.h" +#include "ace/ACE.h" +#if !defined (__ACEXML_INLINE__) +# include "Print_Handler.i" +#endif /* __ACEXML_INLINE__ */ + +ACEXML_Print_Handler::ACEXML_Print_Handler (void) +{ + // no-op +} + +ACEXML_Print_Handler::~ACEXML_Print_Handler (void) +{ + // no-op +} + +void +ACEXML_Print_Handler::characters (const ACEXML_Char *cdata, + int start, + int end, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event characters () ** start: " << start + << " end: " << end << " ***************" << endl; + cout << cdata << endl; + cout << "- End event characters () ---------------" << endl; +} + +void +ACEXML_Print_Handler::endDocument (ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event endDocument () ***************" << endl; +} + +void +ACEXML_Print_Handler::endElement (const ACEXML_Char *uri, + const ACEXML_Char *name, + const ACEXML_Char *qName, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event endElement (" << uri << ", " << name << ", " + << qName << ") ***************" << endl; +} + +void +ACEXML_Print_Handler::endPrefixMapping (const ACEXML_Char *prefix, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event endPrefixMapping (" << prefix << ") ***************" << endl; +} + +void +ACEXML_Print_Handler::ignorableWhitespace (const ACEXML_Char *, + int, + int, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event ignorableWhitespace () ***************" << endl; +} + +void +ACEXML_Print_Handler::processingInstruction (const ACEXML_Char *target, + const ACEXML_Char *data, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event processingInstruction (" << target << ", " + << data << ") ***************" << endl; +} + +void +ACEXML_Print_Handler::setDocumentLocator (ACEXML_Locator *, + ACEXML_Env &xmlenv) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event setDocumentLocator () ***************" << endl; +} + +void +ACEXML_Print_Handler::skippedEntity (const ACEXML_Char *name, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event skippedEntity (" << name << ") ***************" << endl; +} + +void +ACEXML_Print_Handler::startDocument (ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event startDocument () ***************" << endl; +} + +void +ACEXML_Print_Handler::startElement (const ACEXML_Char *uri, + const ACEXML_Char *name, + const ACEXML_Char *qName, + ACEXML_Attributes *alist, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event startElement (" << uri << ", " + << name << ", " << qName << ") ***************" << endl; + if (alist != 0) + for (size_t i = 0; i < alist->getLength (); ++i) + { + cout << " " << alist->getQName (i) << " = \"" + << alist->getValue (i) << "\"" << endl; + } +} + +void +ACEXML_Print_Handler::startPrefixMapping (const ACEXML_Char *, + const ACEXML_Char *, + ACEXML_Env &) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} + +// *** Methods inherit from ACEXML_DTDHandler. + +void +ACEXML_Print_Handler::notationDecl (const ACEXML_Char *, + const ACEXML_Char *, + const ACEXML_Char *, + ACEXML_Env &) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} + +void +ACEXML_Print_Handler::unparsedEntityDecl (const ACEXML_Char *, + const ACEXML_Char *, + const ACEXML_Char *, + const ACEXML_Char *, + ACEXML_Env &) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} + +// Methods inherit from ACEXML_EnitityResolver. + +ACEXML_InputSource * +ACEXML_Print_Handler::resolveEntity (const ACEXML_Char *, + const ACEXML_Char *, + ACEXML_Env &) + // 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 &, + ACEXML_Env &) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} + +void +ACEXML_Print_Handler::fatalError (ACEXML_SAXParseException &, + ACEXML_Env &) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} + +void +ACEXML_Print_Handler::warning (ACEXML_SAXParseException &, + ACEXML_Env &) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} diff --git a/ACEXML/examples/SAXPrint/Print_Handler.h b/ACEXML/examples/SAXPrint/Print_Handler.h new file mode 100644 index 00000000000..ff943cdade7 --- /dev/null +++ b/ACEXML/examples/SAXPrint/Print_Handler.h @@ -0,0 +1,179 @@ +// $Id$ + +#ifndef ACEXML_PRINT_HANDLER_H +#define ACEXML_PRINT_HANDLER_H + +#include "Common/DefaultHandler.h" + +class ACEXML_Print_Handler : public ACEXML_DefaultHandler +{ +public: + /* + * Default constructor. + */ + ACEXML_Print_Handler (void); + + /* + * Default destructor. + */ + virtual ~ACEXML_Print_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 &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of the end of a document. + */ + virtual void endDocument (ACEXML_Env &xmlenv) + // 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 &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * End the scope of a prefix-URI mapping. + */ + virtual void endPrefixMapping (const ACEXML_Char *prefix, + ACEXML_Env &xmlenv) + // 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 &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of a processing instruction. + */ + virtual void processingInstruction (const ACEXML_Char *target, + const ACEXML_Char *data, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive an object for locating the origin of SAX document events. + */ + virtual void setDocumentLocator (ACEXML_Locator *locator, + ACEXML_Env &xmlenv) ; + + /* + * Receive notification of a skipped entity. + */ + virtual void skippedEntity (const ACEXML_Char *name, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of the beginning of a document. + */ + virtual void startDocument (ACEXML_Env &xmlenv) + // 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 &xmlenv) + // 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 &xmlenv) + // 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 &xmlenv) + // 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 &xmlenv) + // 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 &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + // Methods inherit from ACEXML_ErrorHandler. + + /* + * Receive notification of a recoverable error. + */ + virtual void error (ACEXML_SAXParseException &exception, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of a non-recoverable error. + */ + virtual void fatalError (ACEXML_SAXParseException &exception, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of a warning. + */ + virtual void warning (ACEXML_SAXParseException &exception, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; +}; + +#endif /* ACEXML_PRINT_HANDLER_H */ diff --git a/ACEXML/examples/SAXPrint/Print_Handler.i b/ACEXML/examples/SAXPrint/Print_Handler.i new file mode 100644 index 00000000000..77b4466a3cb --- /dev/null +++ b/ACEXML/examples/SAXPrint/Print_Handler.i @@ -0,0 +1 @@ +// -*- C++ -*- $Id$ diff --git a/ACEXML/examples/SAXPrint/SAXPrint.dsp b/ACEXML/examples/SAXPrint/SAXPrint.dsp new file mode 100644 index 00000000000..06c3cc09b48 --- /dev/null +++ b/ACEXML/examples/SAXPrint/SAXPrint.dsp @@ -0,0 +1,130 @@ +# Microsoft Developer Studio Project File - Name="SAXPrint" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=SAXPrint - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "SAXPrint.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "SAXPrint.mak" CFG="SAXPrint - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "SAXPrint - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "SAXPrint - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "SAXPrint - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../.." /I "..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ace.lib ACEXML.lib ACEXML_Parser.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\ace" /libpath:"..\..\Common" /libpath:"..\..\parser\parser"
+
+!ELSEIF "$(CFG)" == "SAXPrint - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "../../.." /I "..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib ACEXMLd.lib ACEXML_Parserd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\ace" /libpath:"..\..\Common" /libpath:"..\..\parser\parser"
+
+!ENDIF
+
+# Begin Target
+
+# Name "SAXPrint - Win32 Release"
+# Name "SAXPrint - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\main.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Print_Handler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SAXPrint_Handler.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\Print_Handler.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\SAXPrint_Handler.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Group "Inline Files"
+
+# PROP Default_Filter "i"
+# Begin Source File
+
+SOURCE=.\Print_Handler.i
+# End Source File
+# Begin Source File
+
+SOURCE=.\SAXPrint_Handler.i
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/ACEXML/examples/SAXPrint/SAXPrint.dsw b/ACEXML/examples/SAXPrint/SAXPrint.dsw new file mode 100644 index 00000000000..3ec5cb65624 --- /dev/null +++ b/ACEXML/examples/SAXPrint/SAXPrint.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "SAXPrint"=.\SAXPrint.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp b/ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp new file mode 100644 index 00000000000..1cc30a5e958 --- /dev/null +++ b/ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp @@ -0,0 +1,222 @@ +// -*- C++ -*- $Id$ + +#include "SAXPrint_Handler.h" +#include "ace/ACE.h" +#if !defined (__ACEXML_INLINE__) +# include "SAXPrint_Handler.i" +#endif /* __ACEXML_INLINE__ */ + +ACEXML_SAXPrint_Handler::ACEXML_SAXPrint_Handler (void) + : indent_ (0) +{ + // no-op +} + +ACEXML_SAXPrint_Handler::~ACEXML_SAXPrint_Handler (void) +{ + // no-op +} + +void +ACEXML_SAXPrint_Handler::characters (const ACEXML_Char *cdata, + int start, + int end, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + ACE_UNUSED_ARG (start); + ACE_UNUSED_ARG (end); + + cout << cdata; +} + +void +ACEXML_SAXPrint_Handler::endDocument (ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << endl; +} + +void +ACEXML_SAXPrint_Handler::endElement (const ACEXML_Char *, + const ACEXML_Char *, + const ACEXML_Char *qName, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + this->dec_indent (); + this->print_indent (); + cout << "</" << qName << ">"; +} + +void +ACEXML_SAXPrint_Handler::endPrefixMapping (const ACEXML_Char *prefix, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event endPrefixMapping (" << prefix << ") ***************" << endl; +} + +void +ACEXML_SAXPrint_Handler::ignorableWhitespace (const ACEXML_Char *, + int, + int, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event ignorableWhitespace () ***************" << endl; +} + +void +ACEXML_SAXPrint_Handler::processingInstruction (const ACEXML_Char *target, + const ACEXML_Char *data, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + this->print_indent (); + cout << "<?" << target << " " + << data << "?>" << endl; +} + +void +ACEXML_SAXPrint_Handler::setDocumentLocator (ACEXML_Locator *, + ACEXML_Env &xmlenv) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event setDocumentLocator () ***************" << endl; +} + +void +ACEXML_SAXPrint_Handler::skippedEntity (const ACEXML_Char *name, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event skippedEntity (" << name << ") ***************" << endl; +} + +void +ACEXML_SAXPrint_Handler::startDocument (ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + cout << "* Event startDocument () ***************" << endl; +} + +void +ACEXML_SAXPrint_Handler::startElement (const ACEXML_Char *, + const ACEXML_Char *, + const ACEXML_Char *qName, + ACEXML_Attributes *alist, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + ACE_UNUSED_ARG (xmlenv); + + this->print_indent (); + + cout << "<" << qName; + if (alist != 0) + for (size_t i = 0; i < alist->getLength (); ++i) + { + cout << " " << alist->getQName (i) << " = \"" + << alist->getValue (i) << "\""; + } + cout << ">"; + this->inc_indent (); +} + +void +ACEXML_SAXPrint_Handler::startPrefixMapping (const ACEXML_Char *, + const ACEXML_Char *, + ACEXML_Env &) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} + +// *** Methods inherit from ACEXML_DTDHandler. + +void +ACEXML_SAXPrint_Handler::notationDecl (const ACEXML_Char *, + const ACEXML_Char *, + const ACEXML_Char *, + ACEXML_Env &) + // 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 &) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} + +// Methods inherit from ACEXML_EnitityResolver. + +ACEXML_InputSource * +ACEXML_SAXPrint_Handler::resolveEntity (const ACEXML_Char *, + const ACEXML_Char *, + ACEXML_Env &) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. + return 0; +} + +// Methods inherit from ACEXML_ErrorHandler. + + /* + * Receive notification of a recoverable error. + */ +void +ACEXML_SAXPrint_Handler::error (ACEXML_SAXParseException &, + ACEXML_Env &) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} + +void +ACEXML_SAXPrint_Handler::fatalError (ACEXML_SAXParseException &, + ACEXML_Env &) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} + +void +ACEXML_SAXPrint_Handler::warning (ACEXML_SAXParseException &, + ACEXML_Env &) + // ACE_THROW_SPEC ((ACEXML_SAXException)) +{ + // No-op. +} + +void +ACEXML_SAXPrint_Handler::print_indent (void) +{ + cout << endl; + for (size_t i = 0; i < this->indent_; ++i) + cout << " "; +} diff --git a/ACEXML/examples/SAXPrint/SAXPrint_Handler.h b/ACEXML/examples/SAXPrint/SAXPrint_Handler.h new file mode 100644 index 00000000000..e28ee471799 --- /dev/null +++ b/ACEXML/examples/SAXPrint/SAXPrint_Handler.h @@ -0,0 +1,190 @@ +// $Id$ + +#ifndef ACEXML_SAXPRINT_HANDLER_H +#define ACEXML_SAXPRINT_HANDLER_H + +#include "Common/DefaultHandler.h" + +class ACEXML_SAXPrint_Handler : public ACEXML_DefaultHandler +{ +public: + /* + * Default constructor. + */ + ACEXML_SAXPrint_Handler (void); + + /* + * 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 &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of the end of a document. + */ + virtual void endDocument (ACEXML_Env &xmlenv) + // 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 &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * End the scope of a prefix-URI mapping. + */ + virtual void endPrefixMapping (const ACEXML_Char *prefix, + ACEXML_Env &xmlenv) + // 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 &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of a processing instruction. + */ + virtual void processingInstruction (const ACEXML_Char *target, + const ACEXML_Char *data, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive an object for locating the origin of SAX document events. + */ + virtual void setDocumentLocator (ACEXML_Locator *locator, + ACEXML_Env &xmlenv) ; + + /* + * Receive notification of a skipped entity. + */ + virtual void skippedEntity (const ACEXML_Char *name, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of the beginning of a document. + */ + virtual void startDocument (ACEXML_Env &xmlenv) + // 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 &xmlenv) + // 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 &xmlenv) + // 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 &xmlenv) + // 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 &xmlenv) + // 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 &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + // Methods inherit from ACEXML_ErrorHandler. + + /* + * Receive notification of a recoverable error. + */ + virtual void error (ACEXML_SAXParseException &exception, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of a non-recoverable error. + */ + virtual void fatalError (ACEXML_SAXParseException &exception, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + /* + * Receive notification of a warning. + */ + virtual void warning (ACEXML_SAXParseException &exception, + ACEXML_Env &xmlenv) + // ACE_THROW_SPEC ((ACEXML_SAXException)) + ; + + void inc_indent (); + void dec_indent (); + void print_indent (); + +private: + size_t indent_; + +}; + +#if defined (__ACEXML_INLINE__) +# include "SAXPrint_Handler.i" +#endif /* __ACEXML_INLINE__ */ +#endif /* ACEXML_SAXPRINT_HANDLER_H */ diff --git a/ACEXML/examples/SAXPrint/SAXPrint_Handler.i b/ACEXML/examples/SAXPrint/SAXPrint_Handler.i new file mode 100644 index 00000000000..2102291ea68 --- /dev/null +++ b/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/ACEXML/examples/SAXPrint/main.cpp b/ACEXML/examples/SAXPrint/main.cpp new file mode 100644 index 00000000000..97f74cf32b6 --- /dev/null +++ b/ACEXML/examples/SAXPrint/main.cpp @@ -0,0 +1,49 @@ +// $Id$ + +#include "Common/FileCharStream.h" +#include "Basic_Parser/Basic_Parser.h" +#include "Print_Handler.h" +#include "SAXPrint_Handler.h" + + +int +main (int argc, char *argv[]) +{ + { + if (argc != 2) + { + cerr << "Usage: SAXPrint <XML filename>" << endl; + return 1; + } + + ACEXML_FileCharStream *fstm = 0; + ACE_NEW_RETURN (fstm, + ACEXML_FileCharStream (), + 1); + + if (fstm->open (argv [1]) != 0) + { + cerr << "Fail to open XML file: " << argv[1] << endl; + return 1; + } + + ACEXML_Basic_Parser parser; + ACEXML_Print_Handler handler; + ACEXML_InputSource input(fstm); + + parser.setContentHandler (&handler); + parser.setDTDHandler (&handler); + parser.setErrorHandler (&handler); + parser.setEntityResolver (&handler); + + ACEXML_Env xmlenv; + + parser.parse (&input, xmlenv); + if (xmlenv.exception ()) + xmlenv.exception ()->print (); + + cout << "\r\r\r"; + + } + return 0; +} diff --git a/ACEXML/examples/SAXPrint/ns.svc.conf.xml b/ACEXML/examples/SAXPrint/ns.svc.conf.xml new file mode 100644 index 00000000000..a7487dc360f --- /dev/null +++ b/ACEXML/examples/SAXPrint/ns.svc.conf.xml @@ -0,0 +1,46 @@ +<?xml version="1.0"?> +<ace:ACE_Svc_Conf 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"> A & + <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 &expect something more?]]> + </module> +</stream> + +<!-- remove CCM_App --> +<remove id="Test_&Taskebc"/> +</ace:ACE_Svc_Conf>
\ No newline at end of file diff --git a/ACEXML/examples/SAXPrint/svc.conf.xml b/ACEXML/examples/SAXPrint/svc.conf.xml new file mode 100644 index 00000000000..356dbb5e654 --- /dev/null +++ b/ACEXML/examples/SAXPrint/svc.conf.xml @@ -0,0 +1,47 @@ +<?xml version="1.0"?> +<!-- <!DOCTYPE ACE_Svc_Conf> --> +<ACE_Svc_Conf> +<static id="ACE_Service_Manager"> + <params>-d</params> + <params>-p 4911</params> +</static> + +<dynamic id="Test_Task" type="service_object"> A & + <initializer path="CCM_App" init="_make_Test_Task"> + <params>-p 3000</params> + </initializer> +</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</params> + <params>3001</params> + </initializer> + </dynamic> + </module> +</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 &expect something more?]]> + </module> +</stream> + +<!-- remove CCM_App --> +<remove id="Test_&Taskebc"/> +</ACE_Svc_Conf>
\ No newline at end of file |