Skip to content

Commit c2621bb

Browse files
committed
XML added attribute version for states
1 parent bf8c6d6 commit c2621bb

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/plugins/xml.lua

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,26 @@ function BaseElement:fromXML(node, scope)
273273
if child.children then
274274
for _, stateChild in ipairs(child.children) do
275275
local propName = stateChild.tag
276-
local value = convertValue(stateChild.value, scope)
277-
local capitalizedName = propName:sub(1,1):upper() .. propName:sub(2)
278-
local methodName = "set"..capitalizedName.."State"
276+
local value
279277

280-
if self[methodName] then
281-
self[methodName](self, stateName, value)
278+
if stateChild.attributes and stateChild.attributes.value then
279+
value = convertValue(stateChild.attributes.value, scope)
280+
elseif stateChild.value then
281+
value = convertValue(stateChild.value, scope)
282282
else
283-
log.warn("XMLParser: State method '" .. methodName .. "' not found for element '" .. self:getType() .. "'")
283+
log.warn("XMLParser: State property '" .. propName .. "' has no value")
284+
value = nil
285+
end
286+
287+
if value ~= nil then
288+
local capitalizedName = propName:sub(1,1):upper() .. propName:sub(2)
289+
local methodName = "set"..capitalizedName.."State"
290+
291+
if self[methodName] then
292+
self[methodName](self, stateName, value)
293+
else
294+
log.warn("XMLParser: State method '" .. methodName .. "' not found for element '" .. self:getType() .. "'")
295+
end
284296
end
285297
end
286298
end

0 commit comments

Comments
 (0)