7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/decision_agent/web/dmn_editor/xml_builder.rb', line 7
def generate_dmn_xml(model)
require "nokogiri"
builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
xml.definitions(
"xmlns" => "https://www.omg.org/spec/DMN/20191111/MODEL/",
"xmlns:dmndi" => "https://www.omg.org/spec/DMN/20191111/DMNDI/",
"xmlns:dc" => "http://www.omg.org/spec/DMN/20180521/DC/",
"id" => "definitions_#{model.id}",
"name" => model.name,
"namespace" => model.namespace || "http://decision_agent.local"
) do
model.decisions.each do |decision|
xml.decision(id: decision.id, name: decision.name) do
if decision.decision_table
build_decision_table_xml(xml, decision.decision_table)
elsif decision.decision_tree
xml. "Decision Tree (not fully supported in DMN XML export yet)"
elsif decision.instance_variable_get(:@literal_expression)
xml.literalExpression do
xml.text decision.instance_variable_get(:@literal_expression)
end
end
end
end
end
end
builder.to_xml
end
|