it_bus_pdk/xml_node.h

00001 #ifndef _IT_BUS_PDK_XML_NODE_H_
00002 #define _IT_BUS_PDK_XML_NODE_H_
00003 
00004 // @Copyright 2004 IONA Technologies, Plc. All Rights Reserved.
00005 //
00006 #include <it_bus/string_map.h>
00007 #include <it_bus/api_defines.h>
00008 #include <it_bus/io_exception.h>
00009 #include <it_bus/prefix_resolver.h>
00010 #include <it_bus_pdk/xml_helper.h>
00011 #include <it_bus_pdk/xml_sax_handler.h>
00012 #include <it_cal/auto_ptr.h>
00013 
00014 namespace IT_Bus
00015 {
00016     class NSScope;
00017     class NamespaceURIPrefixMap;
00018     class XMLOutputStream;
00019 
00020     class IT_BUS_XML_API XMLNode : 
00021         public PrefixResolver, 
00022         public XMLSaxHandler
00023     {
00024       public:
00025 
00026         XMLNode();
00027 
00028         XMLNode(
00029             const XMLNode&      rhs
00030         );
00031 
00032         virtual ~XMLNode();
00033 
00034         XMLNode&
00035         operator=(
00036             const XMLNode&      rhs
00037         );
00038 
00039         /*
00040          *  PrefixResolver methods
00041          */
00042         virtual void
00043         add_namespace_declaration(
00044             const String&       prefix,
00045             const String&       uri
00046         );
00047 
00048         virtual bool
00049         resolve_uri(
00050             const String&       prefix,
00051             String&             uri
00052         ) const;
00053 
00054         virtual bool
00055         resolve_prefix(
00056             const String&       uri,
00057             String&             prefix
00058         ) const;
00059 
00060         /*
00061          *  XMLSaxHandler methods
00062          */
00063         virtual void
00064         sax_accept_namespace_declaration(
00065             char*               prefix,
00066             char*               namespace_uri
00067         );
00068 
00069         virtual bool
00070         sax_accept_attribute(
00071             char*               raw_name,
00072             char*               namespace_uri,
00073             const String&       value
00074         );
00075 
00076         virtual XMLSaxHandler*
00077         sax_start_element(
00078             const char*         raw_name,
00079             const char*         namespace_uri,
00080             const char*         target_namespace
00081         );
00082 
00083         virtual XMLSaxHandler*
00084         sax_end_element();
00085 
00086         virtual void
00087         sax_accept_characters(
00088             const String::UChar* uchars,
00089             size_t               n = String::npos
00090         );
00091 
00092         virtual void
00093         set_encoding(
00094             const String&       encoding_name
00095         );
00096 
00097         virtual const String&
00098         get_xml_encoding();
00099 
00100         /*
00101          *  XMLNode methods
00102          */
00103         void
00104         parse_element_tag(
00105             const XMLIterator&  xml_iterator
00106         );
00107 
00108         bool
00109         parse_attributes(
00110             const XMLIterator&  xml_iterator
00111         );
00112 
00113         bool
00114         parse_elements(
00115             const XMLIterator&  xml_iterator
00116         );
00117 
00118         const QName&
00119         get_tag_name() const;
00120 
00121         const String&
00122         get_target_namespace() const;
00123 
00124         virtual bool
00125         accept_attribute(
00126             const char*         raw_name,
00127             const char*         namespace_uri,
00128             const char*         value
00129         );
00130 
00131         virtual bool
00132         accept_element(
00133             const XMLIterator&  element_iterator,
00134             const XMLNode&      element
00135         );
00136 
00137         void
00138         set_tag_name(
00139             const QName&        element_name,
00140             const String&       target_namespace
00141         );
00142 
00143         void
00144         set_tag_name(
00145             const char*         raw_name,
00146             const char*         namespace_uri,
00147             const char*         target_namespace
00148         );
00149 
00150         void
00151         set_parent(
00152             XMLNode*            parent
00153         );
00154 
00155         XMLNode*
00156         get_parent() const;
00157 
00162         virtual void
00163         write_start_tag(
00164             IT_Bus::XMLOutputStream& stream
00165         ) const IT_THROW_DECL((IOException));
00166 
00167         void
00168         write_start_tag_without_close(
00169             IT_Bus::XMLOutputStream& stream,
00170             NamespaceURIPrefixMap*   current_serialized_prefixes = 0
00171         ) const IT_THROW_DECL((IOException));
00172 
00179         virtual void
00180         write_attributes(
00181             IT_Bus::XMLOutputStream& stream
00182         ) const IT_THROW_DECL((IOException));
00183 
00193         virtual void
00194         write_attributes_with_prefix_map(
00195             IT_Bus::XMLOutputStream& stream,
00196             NamespaceURIPrefixMap&   current_serialized_prefixes
00197         ) const IT_THROW_DECL((IOException));
00198 
00202         virtual void
00203         write_end_tag(
00204             IT_Bus::XMLOutputStream& stream
00205         ) const IT_THROW_DECL((IOException));
00206 
00207         void
00208         write_end_tag_without_close(
00209             IT_Bus::XMLOutputStream& stream,
00210             NamespaceURIPrefixMap*   current_serialized_prefixes = 0
00211         ) const IT_THROW_DECL((IOException));
00212 
00213       protected:
00214 
00215         const NSScope*
00216         get_nsscope() const;
00217 
00218         void
00219         clear();
00220 
00221       private:
00222 
00223         void
00224         process_namespace_definitions(
00225             const XMLIterator& xml_iterator
00226         );
00227 
00228         XMLNode*            m_parent;
00229         IT_AutoPtr<NSScope> m_scope;
00230         QName               m_qname;
00231         String              m_target_namespace;
00232     };
00233 }
00234 
00235 #endif  

Generated on Thu Sep 7 11:39:37 2006 for Artix by  doxygen 1.4.7