17 #ifndef VCSN_XML_XML_EXP_VISITOR_HXX
18 # define VCSN_XML_XML_EXP_VISITOR_HXX
24 # include <vaucanson/xml/strings.hh>
33 template<
typename M_,
typename W_>
34 XmlExpVisitor<M_,W_>::XmlExpVisitor(xercesc::DOMDocument* doc,
const char* node_name) :
36 label_(xml::tools::create_element(doc_, node_name)),
41 template<
typename M_,
typename W_>
43 XmlExpVisitor<M_,W_>::sum_or_product(
const Node<M_, W_>* left_,
44 const Node<M_, W_>* right_)
47 right_->accept(*
this);
50 template<
typename M_,
typename W_>
52 XmlExpVisitor<M_, W_>::weight_or_star(
const Node<M_, W_>* node)
57 template<
typename M_,
typename W_>
59 XmlExpVisitor<M_, W_>::product(
const Node<M_, W_>* left_,
60 const Node<M_, W_>* right_)
62 xercesc::DOMElement* tmp = current_;
63 current_ = xml::tools::create_element(doc_,
"product");
64 sum_or_product(left_, right_);
65 tmp->appendChild(current_);
69 template<
typename M_,
typename W_>
71 XmlExpVisitor<M_, W_>::sum(
const Node<M_, W_>* left_,
72 const Node<M_, W_>* right_)
74 xercesc::DOMElement* tmp = current_;
75 current_ = xml::tools::create_element(doc_,
"sum");
76 sum_or_product(left_, right_);
77 tmp->appendChild(current_);
81 template<
typename M_,
typename W_>
85 xercesc::DOMElement* tmp = current_;
86 current_ = xml::tools::create_element(doc_,
"star");
88 tmp->appendChild(current_);
92 template <
typename M_,
typename W_>
95 XmlExpVisitor<M_, W_>::set_weight(
const T& w, xercesc::DOMElement* node)
97 xercesc::DOMElement* weight = xml::tools::create_element(doc_,
"weight");
100 weight->setAttribute(transcode(
"value"), transcode(ss.str()));
101 node->appendChild(weight);
104 template <
typename M_,
typename W_>
105 template <
typename S,
typename T>
107 XmlExpVisitor<M_, W_>::set_weight(
const rat::exp<S, T>& w, xercesc::DOMElement* node)
109 XmlExpVisitor<S, T> v(doc_,
"weight");
111 node->appendChild(v.get());
114 template<
typename M_,
typename W_>
116 XmlExpVisitor<M_, W_>::left_weight(
const W_& w,
const Node<M_, W_>* node)
118 xercesc::DOMElement* tmp = current_;
119 current_ = xml::tools::create_element(doc_,
"leftExtMul");
120 set_weight(w, current_);
121 weight_or_star(node);
122 tmp->appendChild(current_);
126 template<
typename M_,
typename W_>
128 XmlExpVisitor<M_, W_>::right_weight(
const W_& w,
const Node<M_, W_>* node)
130 xercesc::DOMElement* tmp = current_;
131 current_ = xml::tools::create_element(doc_,
"rightExtMul");
132 set_weight(w, current_);
133 weight_or_star(node);
134 tmp->appendChild(current_);
138 template<
typename M_,
typename W_>
140 XmlExpVisitor<M_, W_>::constant(
const M_& m)
142 xml::builders::create_monElmt_node(m, doc_, current_);
145 template<
typename M_,
typename W_>
146 void XmlExpVisitor<M_, W_>::zero()
148 xercesc::DOMElement* zero = xml::tools::create_element(doc_,
"zero");
149 current_->appendChild(zero);
152 template<
typename M_,
typename W_>
153 void XmlExpVisitor<M_, W_>::one()
155 xercesc::DOMElement*
identity = xml::tools::create_element(doc_,
"one");
156 current_->appendChild(identity);
159 template<
typename M_,
typename W_>
166 template<
typename M_,
typename W_>
167 xercesc::DOMDocument*
168 XmlExpVisitor<M_, W_>::set(xercesc::DOMDocument* v)
179 #endif // ! VCSN_XML_XML_EXP_VISITOR_HXX