summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas BrĂ¼derli2007-04-19 12:35:11 +0000
committerThomas BrĂ¼derli2007-04-19 12:35:11 +0000
commitd35165fea764bc2a1b32b979b1797a4ea4da249f (patch)
tree3804b9854bb6d25f5da65d7fca846d1ef0f0cf99
parent1f3400c8c2896fe217f085f0fc5341656170d273 (diff)
downloaditools-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.class13
1 files changed, 7 insertions, 6 deletions
diff --git a/xml.class b/xml.class
index 36aa165..24a9f23 100644
--- a/xml.class
+++ b/xml.class
@@ -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))
{