Converts a number or string into an XML element
763040
def convert_kv(key, val, attr_type, attr={}, cdata=False):
    """"""
    LOG.info('Inside convert_kv(): key="%s", val="%s", type(val) is: "%s"' % (
        unicode_me(key), unicode_me(val), type(val).__name__)
    )

    key, attr = make_valid_xml_name(key, attr)

    if attr_type:
        attr['type'] = get_xml_type(val)
    attrstring = make_attrstring(attr)
    return '<%s%s>%s</%s>' % (
        key, attrstring, 
        wrap_cdata(val) if cdata == True else escape_xml(val),
        key
    )
246666
def convert_string_to_number(value):
    
    if value is None:
        return 1
    if isinstance(value, int):
        return value
    if value.isdigit():
        return int(value)
    num_list = map(lambda s: NUMBERS[s], re.findall(numbers + '+', value.lower()))
    return sum(num_list)
1117772
def to_xml_string(str = '')
      str << '<?xml version="1.0" encoding="UTF-8"?>'
      str << ('<Types xmlns="' << XML_NS_T << '">')
      each { |type| type.to_xml_string(str) }
      str << '</Types>'
    end
811179
def to_xml_string(str = '')
      str << '<?xml version="1.0" encoding="UTF-8"?>'
      str << ('<table xmlns="' << XML_NS << '" id="' << (index+1).to_s << '" name="' << @name << '" displayName="' << @name.gsub(/\s/,'_') << '" ')
      str << ('ref="' << @ref << '" totalsRowShown="0">')
      str << ('<autoFilter ref="' << @ref << '"/>')
      str << ('<tableColumns count="' << header_cells.length.to_s << '">')
      header_cells.each_with_index do |cell,index|
        str << ('<tableColumn id ="' << (index+1).to_s << '" name="' << cell.value << '"/>')
      end
      str << '</tableColumns>'
      table_style_info.to_xml_string(str)
      str << '</table>'
    end
1186521
def get_xml_str(self, data):
        

        responses = []
        for tag, value in data.items():
            elem = Element(tag)
            if isinstance(value, dict):
                for value in self.get_xml_str(value):
                    elem.append(value)
            elif isinstance(value, list):
                value = ', '.join([m for m in value])
                elem.text = value
            else:
                elem.text = value
            responses.append(elem)
        return responses
581275
def serialize_numeric(self, tag):
        """"""
        str_func = int.__str__ if isinstance(tag, int) else float.__str__
        return str_func(tag) + tag.suffix
5152
def to_xml_string(str = '')
      super(str) do
        # needs to override the super color here to push in ln/and something else!
        if color
          str << '<c:spPr><a:solidFill>'
          str << ('<a:srgbClr val="' << color << '"/>')
          str << '</a:solidFill>'
          str << '<a:ln><a:solidFill>'
          str << ('<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>')
          str << '</c:spPr>'
          str << '<c:marker>'
          str << '<c:spPr><a:solidFill>'
          str << ('<a:srgbClr val="' << color << '"/>')
          str << '</a:solidFill>'
          str << '<a:ln><a:solidFill>'
          str << ('<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>')
          str << '</c:spPr>'
          str << '</c:marker>'
        end
        if ln_width
          str << '<c:spPr>'
          str << '<a:ln w="' << ln_width.to_s << '"/>'
          str << '</c:spPr>'
        end
        @xData.to_xml_string(str) unless @xData.nil?
        @yData.to_xml_string(str) unless @yData.nil?
        str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>')
      end
      str
    end
1069269
private Integer toNumber(final Object src) {

		if (src instanceof Number) {

			return ((Number)src).intValue();
		}

		if (src instanceof String) {

			try {

				return Integer.valueOf(src.toString());

			} catch (NumberFormatException nfex) {
				logger.warn("Error in slice(): Cannot parse number {}.", src);
			}
		}

		return null;
	}
192191
public static org.w3c.dom.Element domElement(String xmlString) {
    org.w3c.dom.Element element = null;
    try {
      ByteArrayInputStream bais = new ByteArrayInputStream(
        xmlString.getBytes(Charset.forName("UTF-8")));
      element = getFactory().newDocumentBuilder().parse(bais)
        .getDocumentElement();
    } catch (SAXException e) {
      throw new MarkLogicIOException(
        "Could not make Element from xmlString" + xmlString, e);
    } catch (IOException e) {
      throw new MarkLogicIOException(
        "Could not make Element from xmlString" + xmlString, e);
    } catch (ParserConfigurationException e) {
      throw new MarkLogicIOException(
        "Could not make Element from xmlString" + xmlString, e);
    }
    return element;
  }
1297983
def get_xml_type(val):
    """"""
    if type(val).__name__ in ('str', 'unicode'):
        return 'str'
    if type(val).__name__ in ('int', 'long'):
        return 'int'
    if type(val).__name__ == 'float':
        return 'float'
    if type(val).__name__ == 'bool':
        return 'bool'
    if isinstance(val, numbers.Number):
        return 'number'
    if type(val).__name__ == 'NoneType':
        return 'null'
    if isinstance(val, dict):
        return 'dict'
    if isinstance(val, collections.Iterable):
        return 'list'
    return type(val).__name__
85543
function numberArrayToString(a) {
  var s = '';
  for (var i in a) {
    s += String.fromCharCode(a[i]);
  }
  return s;
}
384054
private Object parseXmlElement(Element element) {
        if(element.getFirstChild() instanceof Text) {
            Text text = (Text) element.getFirstChild();
            return text.getData();
        }
        return element;
    }
455777
def _fromstring(value):
        ''''''
        # NOTE: Is this even possible ?
        if value is None:
            return None

        # FIXME: In XML, booleans are either 0/false or 1/true (lower-case !)
        if value.lower() == 'true':
            return True
        elif value.lower() == 'false':
            return False

        # FIXME: Using int() or float() is eating whitespaces unintendedly here
        try:
            return int(value)
        except ValueError:
            pass

        try:
            # Test for infinity and NaN values
            if float('-inf') < float(value) < float('inf'):
                return float(value)
        except ValueError:
            pass

        return value
507233
def to_string(self, indent="", newl="", addindent=""):
        '''
        
        '''
        buf = StringIO()
        self.to_xml().writexml(buf, indent=indent, addindent=addindent,
                               newl=newl)
        return buf.getvalue()
500315
def xml(self, indent=4, **kwargs):
        
        writer = StringIO()
        self.write(writer, indent=indent, **kwargs)
        return writer.getvalue()
954273
def to_xml_string(str = '')
      super(str) do
        str << '<c:scatterChart>'
        str << ('<c:scatterStyle val="' << scatter_style.to_s << '"/>')
        str << ('<c:varyColors val="' << vary_colors.to_s << '"/>')
        @series.each { |ser| ser.to_xml_string(str) }
        d_lbls.to_xml_string(str) if @d_lbls
        axes.to_xml_string(str, :ids => true)
        str << '</c:scatterChart>'
        axes.to_xml_string(str)
      end
      str
    end
997212
def to_xml_string(str = '')
      str << ('<styleSheet xmlns="' << XML_NS << '">')
      [:numFmts, :fonts, :fills, :borders, :cellStyleXfs, :cellXfs, :cellStyles, :dxfs, :tableStyles].each do |key|
        self.instance_values[key.to_s].to_xml_string(str) unless self.instance_values[key.to_s].nil?
      end
      str << '</styleSheet>'
    end