lib/openwfe/expressions/raw_xml.rb in openwferu-0.9.6 vs lib/openwfe/expressions/raw_xml.rb in openwferu-0.9.7

- old
+ new

@@ -64,17 +64,18 @@ @raw_representation_s = raw_representation.to_s end def raw_representation - #synchronize do - if not @raw_representation + + unless @raw_representation + @raw_representation = \ REXML::Document.new(@raw_representation_s).root end - return @raw_representation - #end + + @raw_representation end protected def extract_attributes () @@ -83,19 +84,42 @@ result[a.name] = a.value end return result end + def extract_descriptions () + + result = [] + raw_representation.each_child do |child| + + next unless child.is_a?(REXML::Element) + next if child.name.intern != :description + + lang = child.attributes["language"] + lang = child.attributes["lang"] unless lang + lang = "default" unless lang + + result << [ lang, child.children[0] ] + end + result + end + def extract_children () c = [] i = 0 raw_representation.each_child do |elt| if elt.kind_of?(REXML::Element) + ename = elt.name.intern + + next if ename == :param + next if ename == :parameter + next if ename == :description + cfei = @fei.dup efei = @environment_id cfei.expression_name = elt.name @@ -119,20 +143,41 @@ c << s if s.length > 0 end end - return c + c end def extract_text_children () + raw_representation.children.collect do |elt| + next if elt.is_a? REXML::Element next if elt.is_a? REXML::Comment s = elt.to_s.strip next if s.length < 1 s end + end + + def extract_parameters () + + r = [] + raw_representation.children.each do |child| + + next unless child.is_a? REXML::Element + + cname = child.name.intern + next unless (cname == :param or cname == :parameter) + + r << Parameter.new( + child.attributes["field"], + child.attributes["match"], + child.attributes["default"], + child.attributes["type"]) + end + r end end end