There is nothing wrong with using XML. If someone else has already created a template you want to use then it's a waste of effort duplicating it in any fashion. Once the widget has been created, it all ends up being the same in-game no matter the method used "read its parts and glue it together".
That said, you can use lua functions to build up widgets just as you would in XML. The "virtual" attribute means "Don't create unless specifically used" just like a function does nothing unless called.
Lua Code:
local function DPBAuraTemplate(base, parent, name)
local f = CreateFrame(base, "$parent"..name, parent)
f.Icon = f:CreateTexture("parentIcon", "ARTWORK")
f.Duration = f:CreateFontstring("$parentDuration")
--- add the rest of the elements, position, size etc.
return f -- return the frame
end
local HelpAura1 = DPBAuraTemplate("Button", MyUnitFrame, "Aura1")
local HarmAura1 = DPBAuraTemplate("Frame", MyUnitFrame, "Aura21")