00001 #ifndef XML_PARSER_IMPLEMENTATION_FILE 00002 #define XML_PARSER_IMPLEMENTATION_FILE 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : xml_parser * 00007 * Author : Chris Koeritz * 00008 * * 00009 ******************************************************************************* 00010 * Copyright (c) 2007-$now By Author. This program is free software; you can * 00011 * redistribute it and/or modify it under the terms of the GNU General Public * 00012 * License as published by the Free Software Foundation; either version 2 of * 00013 * the License or (at your option) any later version. This is online at: * 00014 * http://www.fsf.org/copyleft/gpl.html * 00015 * Please send any updates to: fred@gruntose.com * 00016 \*****************************************************************************/ 00017 00018 #include "xml_parser.h" 00019 00020 #include <basis/istring.h> 00021 #include <data_struct/string_table.h> 00022 00023 xml_parser::xml_parser(const istring &to_parse) 00024 { 00025 if (!to_parse) {} 00026 } 00027 00028 xml_parser::~xml_parser() 00029 { 00030 } 00031 00032 const char *xml_parser::outcome_name(const outcome &to_name) 00033 { 00034 return common::outcome_name(to_name); 00035 } 00036 00037 void xml_parser::reset(const istring &to_parse) 00038 { 00039 if (!to_parse) {} 00040 } 00041 00042 outcome xml_parser::header_callback(istring &header_name, 00043 string_table &attributes) 00044 { 00045 if (!header_name || !attributes.symbols()) {} 00046 return common::OKAY; 00047 } 00048 00049 00050 outcome xml_parser::tag_open_callback(istring &tag_name, 00051 string_table &attributes) 00052 { 00053 if (!tag_name || !attributes.symbols()) {} 00054 return OKAY; 00055 } 00056 00057 outcome xml_parser::tag_close_callback(istring &tag_name) 00058 { 00059 if (!tag_name) {} 00060 return OKAY; 00061 } 00062 00063 outcome xml_parser::content_callback(istring &content) 00064 { 00065 if (!content) {} 00066 return OKAY; 00067 } 00068 00069 outcome xml_parser::parse() 00070 { 00071 00072 //phases: we are initially always seeking a bracket bounded tag of some sort. 00073 00074 // the first few constructs must be headers, especially the xml header. 00075 00076 // is it true that headers are the only valid thing to see before real tags 00077 // start, or can there be raw content embedded in there? 00078 // yes, it seems to be true in mozilla. you can't have bare content in 00079 // between the headers and the real tags. 00080 00081 // actually, if we allow the file to not start with the xml header and 00082 // version, then that's a bug. 00083 00084 // need function to accumulate the tag based on structure. do headers 00085 // have to have a ? as part of the inner and outer structure? 00086 00087 // test against mozilla to ensure we are seeing the same things; get 00088 // together some tasty sample files. 00089 00090 // count lines and chars so we can report where it tanked. 00091 00092 // back to phases, (not a precise grammar below) 00093 // white_space ::= [ ' ' '\n' '\r' '\t' ] * 00094 // ws ::= white_space 00095 // text_phrase ::= not_white_space_nor_reserved not_reserved* 00096 // name ::= text_phrase 00097 // value ::= not_reserved * 00098 // lt_char ::= '<' 00099 // quote ::= '"' 00100 00101 // xml_file ::= header+ ws tagged_unit+ ws 00102 // header ::= '<' '?' name ws attrib_list ws '?' '>' ws 00103 // tagged_unit ::= open_tag content* close_tag ws 00104 // content ::= [ tagged_unit | text_phrase ] + ws 00105 // open_tag ::= '<' name ws attrib_list ws '>' ws 00106 // attrib_list ::= ( attribute ws ) * ws 00107 // attribute ::= name ws '=' ws quoted_string ws 00108 // quoted_string ::= '"' not_lt_char_nor_quote '"' ws 00109 // close_tag :: '<' '/' name ws '>' ws 00110 00111 //write a recursive descent parser on this grammar and spit out the 00112 // productions as callbacks, at least for the major ones already listed. 00113 00114 return common::NOT_IMPLEMENTED; 00115 } 00116 00117 /* callbacks to invoke. 00118 outcome header_callback(istring &header_name, string_table &attributes) 00119 outcome tag_open_callback(istring &tag_name, string_table &attributes) 00120 outcome tag_close_callback(istring &tag_name) 00121 outcome content_callback(istring &content) 00122 */ 00123 00124 00125 00126 #endif //XML_PARSER_IMPLEMENTATION_FILE 00127
1.5.1