lib/openwfe/orest/xmlcodec.rb in openwferu-0.9.16 vs lib/openwfe/orest/xmlcodec.rb in openwferu-0.9.17
- old
+ new
@@ -1,8 +1,8 @@
#
#--
-# Copyright (c) 2005-2007, John Mettraux, OpenWFE.org
+# Copyright (c) 2005-2008, John Mettraux, OpenWFE.org
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
@@ -30,11 +30,11 @@
# POSSIBILITY OF SUCH DAMAGE.
#++
#
#
-# "hecho en Costa Rica"
+# "hecho en Costa Rica" (with just the PickAxe at hand)
#
require 'base64'
require 'rexml/document'
@@ -241,17 +241,17 @@
#puts "decodeAttribute() '#{xmlElt.name}' --> '#{xmlElt.text}'"
#
# atomic types
- return xmlElt.text \
+ return xmlElt.text.strip \
if xmlElt.name == E_STRING
- return Integer(xmlElt.text) \
+ return Integer(xmlElt.text.strip) \
if xmlElt.name == E_INTEGER
- return Integer(xmlElt.text) \
+ return Integer(xmlElt.text.strip) \
if xmlElt.name == E_LONG
- return Float(xmlElt.text) \
+ return Float(xmlElt.text.strip) \
if xmlElt.name == E_DOUBLE
return parse_boolean(xmlElt.text) \
if xmlElt.name == E_BOOLEAN
return decode_xmldocument(xmlElt) \
@@ -313,10 +313,13 @@
val = decode(val)
#puts "decodeEntry() k >#{key}< v >#{val}<"
#puts "decodeEntry() subject '#{val}'" if key == '__subject__'
+ key = key.strip if key.is_a?(String)
+ val = val.strip if val.is_a?(String)
+
map[key] = val
end
def XmlCodec.parse_boolean (string)
@@ -629,22 +632,23 @@
#
def OpenWFE.xmldoc_to_string (xml, decl=true)
#return xml if xml.is_a?(String)
- if decl and (not xml[0].is_a?(REXML::XMLDecl))
- xml << REXML::XMLDecl.new()
- end
+ xml << REXML::XMLDecl.new \
+ if decl and (not xml[0].is_a?(REXML::XMLDecl))
- s = ""
- xml.write(s, 0)
- return s
+ #s = ""
+ #xml.write(s, 0)
+ #return s
+ xml.to_s
end
#
# An alias for OpenWFE::xmldoc_to_string()
#
def OpenWFE.xml_to_s (xml, decl=true)
+
OpenWFE::xmldoc_to_string(xml, decl)
end
end