diff options
author | Thomas BrĂ¼derli | 2007-04-19 12:35:11 +0000 |
---|---|---|
committer | Thomas BrĂ¼derli | 2007-04-19 12:35:11 +0000 |
commit | d35165fea764bc2a1b32b979b1797a4ea4da249f (patch) | |
tree | 3804b9854bb6d25f5da65d7fca846d1ef0f0cf99 | |
parent | 1f3400c8c2896fe217f085f0fc5341656170d273 (diff) | |
download | itools-d35165fea764bc2a1b32b979b1797a4ea4da249f.tar.gz itools-d35165fea764bc2a1b32b979b1797a4ea4da249f.tar.bz2 itools-d35165fea764bc2a1b32b979b1797a4ea4da249f.zip |
it_xml: new option to lowercase all tag and attribute names
-rw-r--r-- | xml.class | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -22,7 +22,8 @@ class it_xml * forcearray xml tags to ALWAYS return as array * safety value 2 causes program abort with invalid xml, 1 causes error report * encoding Output character encoding (e.g. UTF-8, default: ISO-8859-1) - * prefix Optional prefix for class names + * prefix Optional prefix for class names + * lowercase Lowercase all tag and attribute names * @return XML object tree or null on failure */ @@ -132,13 +133,13 @@ function flatten($with_attr = false) # Strip namespace and convert extra characters to _ function _make_identifier($name) { - return preg_replace(array('/^.*:/', '/\W/'), array('', '_'), $name); + $id = preg_replace(array('/^.*:/', '/\W/'), array('', '_'), $name); + return $this->_p['lowercase'] ? strtolower($id) : $id; } function start_element($parser, $name, $attrs) { - $name = it_xml::_make_identifier($name); - $name = $this->_p['prefix'] . $name; + $name = $this->_p['prefix'] . $this->_make_identifier($name); if (!class_exists($name)) eval("class $name extends it_xml {}"); # Extending the base class caused problems with tel_xmlentry @@ -154,13 +155,13 @@ function start_element($parser, $name, $attrs) if ($attrs) { foreach ($attrs as $key => $val) - $this->_stack[0]->attr[it_xml::_make_identifier($key)] = $val; + $this->_stack[0]->attr[$this->_make_identifier($key)] = $val; } } function end_element($parser, $name) { - $name = it_xml::_make_identifier($name); + $name = $this->_make_identifier($name); if (!$this->_stack[0]->consume($this->_p)) { |