1 /*------------------------------------------------------------------------------
2 Name: MsgKeyFactory.h
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 ------------------------------------------------------------------------------*/
6
7 /**
8 * Parsing xml Key (quality of service) of publish() and update().
9 * <p />
10 * All XmlKey's have the same XML minimal structure:<p>
11 * <pre>
12 * <key oid="12345"/>
13 * </pre>
14 * or
15 * <pre>
16 * <key oid="12345">
17 * <!-- application specific tags -->
18 * </key>
19 * </pre>
20 *
21 * where oid is a unique key.
22 * <p />
23 * A typical <b>publish</b> key could look like this:<br />
24 * <pre>
25 * <key oid='4711' contentMime='text/xml'>
26 * <AGENT id='192.168.124.20' subId='1' type='generic'>
27 * <DRIVER id='FileProof' pollingFreq='10'>
28 * </DRIVER>
29 * </AGENT>
30 * </key>
31 * </pre>
32 * <br />
33 * Note that the AGENT and DRIVER tags are application know how, which you have to supply.<br />
34 * A well designed xml hierarchy of your problem domain is essential for a proper working xmlBlaster
35 * <p />
36 * <p>
37 * NOTE: <![CDATA[ ... ]]> sections in the key are not supported
38 * </p>
39 * <p>
40 * NOTE: Using tags like '<<c/>' will be transformed to '<c></c>' on toXml()
41 * </p>
42 * @see org.xmlBlaster.util.key.MsgKeyData
43 * @see org.xmlBlaster.test.classtest.key.MsgKeyFactoryTest
44 * @author xmlBlaster@marcelruff.info
45 */
46
47 #ifndef _UTIL_KEY_MSGKEYFACTORY_H
48 #define _UTIL_KEY_MSGKEYFACTORY_H
49
50 #include <util/xmlBlasterDef.h>
51 // #include <util/SaxHandlerBase.h>
52 #include <util/parser/XmlHandlerBase.h>
53 #include <util/key/MsgKeyData.h>
54
55
56
57
58 namespace org { namespace xmlBlaster { namespace util { namespace key {
59
60 class Dll_Export MsgKeyFactory : public parser::XmlHandlerBase
61 {
62 private:
63 std::string ME;
64 org::xmlBlaster::util::key::MsgKeyData msgKeyData_;
65
66 std::string OID; // = "oid";
67 std::string CONTENT_MIME; // = "contentMime";
68 std::string CONTENT_MIME_EXTENDED; // = "contentMimeExtended";
69 std::string D_O_M_A_I_N; // = "domain";
70
71 /** helper flag for SAX parsing: parsing inside <state> ? */
72 int inKey_; // = 0;
73 std::string clientTags_;
74 std::string clientTagsOffset_;
75 int clientTagsDepth_;
76
77 public:
78 /**
79 * Can be used as singleton.
80 */
81 MsgKeyFactory(org::xmlBlaster::util::Global& global);
82
83 ~MsgKeyFactory();
84
85 /**
86 * Parses the given xml Key and returns a org::xmlBlaster::util::key::MsgKeyData holding the data.
87 * Parsing of update() and publish() key is supported here.
88 * @param the XML based ASCII std::string
89 */
90 org::xmlBlaster::util::key::MsgKeyData readObject(const std::string& xmlKey);
91
92 /**
93 * Start element, event from SAX parser.
94 * <p />
95 * @param name Tag name
96 * @param attrs the attributes of the tag
97 */
98 void startElement(const std::string &name, const parser::AttributeMap &attrs);
99
100 /**
101 * End element, event from SAX parser.
102 * <p />
103 * @param name Tag name
104 */
105 void endElement(const std::string &name);
106 };
107
108 }}}} // namespace
109
110 #endif
syntax highlighted by Code2HTML, v. 0.9.1