3 #include "ACEXML/common/FileCharStream.h"
4 #include "ACEXML/common/StrCharStream.h"
5 #include "ACEXML/parser/parser/Parser.h"
7 #if (ACE_USES_CLASSIC_SVC_CONF == 0)
9 extern "C" ACE_Proper_Export_Flag ACE_XML_Svc_Conf
*
10 _ACEXML_create_XML_Svc_Conf_Object ()
12 ACE_XML_Svc_Conf
*retp
= 0;
15 ACEXML_Svcconf_Parser (),
21 ACEXML_Svcconf_Parser::ACEXML_Svcconf_Parser ()
23 this->parser_
.setContentHandler (&this->svcconf_handler_
);
24 this->parser_
.setDTDHandler (&this->svcconf_handler_
);
25 this->parser_
.setErrorHandler (&this->svcconf_handler_
);
26 this->parser_
.setEntityResolver (&this->svcconf_handler_
);
29 this->parser_
.setFeature (ACE_TEXT ("http://xml.org/sax/features/validation"),
32 catch (const ACEXML_SAXException
& ex
)
34 ex
.print (); // Can't do much except printing the error.
38 ACEXML_Svcconf_Parser::~ACEXML_Svcconf_Parser ()
43 ACEXML_Svcconf_Parser::parse_file (const ACE_TCHAR file
[])
46 ACE_ERROR_RETURN ((LM_ERROR
, "ACEXML_Svcconf_Parser: No filename specified\n"), -1);
48 ACEXML_FileCharStream
*fstm
= 0;
50 ACEXML_FileCharStream (),
53 if (fstm
->open (file
) != 0)
54 ACE_ERROR_RETURN ((LM_ERROR
,
55 ACE_TEXT ("ACEXML_Svcconf_Parser: Fail to open XML file: %s\n"),
59 this->input_stream_
.setCharStream (fstm
);
63 this->parser_
.parse (&this->input_stream_
);
65 catch (const ACEXML_SAXException
& ex
)
75 ACEXML_Svcconf_Parser::parse_string (const ACE_TCHAR str
[])
78 ACE_ERROR_RETURN ((LM_ERROR
, "ACEXML_Svcconf_Parser: Can't parse a null string\n"), -1);
80 ACEXML_StrCharStream
*stm
= 0;
81 ACE_NEW_RETURN (stm
, ACEXML_StrCharStream
, -1);
82 if (stm
->open (str
, ACE_TEXT ("Svcconf")) < 0)
83 ACE_ERROR_RETURN ((LM_ERROR
, "ACEXML_Svcconf_Parser: Unable to create "
84 "input stream.\n"), -1);
86 this->input_stream_
.setCharStream (stm
);
89 this->parser_
.parse (&this->input_stream_
);
91 catch (const ACEXML_SAXException
& ex
)
93 // If there was a problem parsing the stream, set the errno
94 // to EINVAL to indicate to upper levels that the stream was
96 ACE_OS::last_error (EINVAL
);
103 #endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */