lib/openwfe/expressions/simplerep.rb in openwferu-0.9.15 vs lib/openwfe/expressions/simplerep.rb in openwferu-0.9.16
- old
+ new
@@ -46,10 +46,12 @@
#
# A raw representation for a process definition, programmatic
# process definitions are turned into trees of instances of this class.
#
+ # It's just an s-expression somehow.
+ #
class SimpleExpRepresentation
attr_reader \
:name,
:attributes
@@ -79,10 +81,28 @@
ProgRawExpression
end
#
+ # Finds the first child named 'description' and returns its
+ # first child as a String.
+ #
+ # TODO : manage languages, as specified in OpenWFE.
+ #
+ def get_description
+
+ return @children.first.to_s if @name == 'description'
+
+ @children.each do |child|
+ d = child.get_description
+ return d if d
+ end
+
+ nil
+ end
+
+ #
# Returns an XML string, containing the equivalent process definition
# in the classical OpenWFE process definition language.
#
def to_s
@@ -123,17 +143,19 @@
# CDATA is perhaps sufficient).
#
def self.from_xml (xml)
xml = REXML::Document.new(xml) \
- if xml.is_a? String
+ if xml.is_a?(String)
xml = xml.root \
- if xml.is_a? REXML::Document
+ if xml.is_a?(REXML::Document)
- if xml.is_a? REXML::Text
- s = xml.to_s
- return s if s.strip.length > 1
+ if xml.is_a?(REXML::Text)
+ #s = xml.to_s
+ #return s if s.strip.length > 1
+ s = xml.to_s.strip
+ return s if s.length > 0
return nil
end
# xml element thus...