示例#1
0
文件: xml.py 项目: LombeC/program-r
 def to_xml(self, client_context):
     xml = "<%s" % self._name
     for attrib_name in self._attribs:
         if isinstance(self._attribs[attrib_name], str):
             attrib_value = self._attribs[attrib_name]
         else:
             attrib_value = self._attribs[attrib_name].resolve(
                 client_context)
         escaped = TextUtils.html_escape(attrib_value)
         xml += ' %s="%s"' % (attrib_name, escaped)
     xml += ">"
     child_xml = self.children_to_xml(client_context)
     xml += child_xml
     xml += "</%s>" % self._name
     return xml
示例#2
0
文件: xml.py 项目: LombeC/program-r
 def resolve_to_string(self, client_context):
     xml = "<%s" % self._name
     for attrib_name in self._attribs:
         if isinstance(self._attribs[attrib_name], str):
             attrib_value = self._attribs[attrib_name]
         else:
             attrib_value = self._attribs[attrib_name].resolve(
                 client_context)
         escaped = TextUtils.html_escape(attrib_value)
         escaped = escaped.replace(" ", "")
         xml += ' %s="%s"' % (attrib_name, escaped)
     xml += ">"
     xml += self.resolve_children_to_string(client_context)
     xml += "</%s>" % self._name
     return xml
示例#3
0
 def to_xml(self, client_context):
     return TextUtils.html_escape(self.word)
示例#4
0
 def test_html_escape(self):
     self.assertEquals("", TextUtils.html_escape(""))
     self.assertEquals(" ", TextUtils.html_escape(" "))
     self.assertEquals("&lt;&gt;", TextUtils.html_escape("<>"))
     self.assertEquals("&lt;regex/&gt;", TextUtils.html_escape("<regex/>"))