The "xs:alternative" nodes in XML schema enables specifying different types
for the same node according to the contents of that node. A typical usage
of this construct in the schema of scenario XMLs is to specify different
types for a `vm` node depending on whether it is a pre-launched,
post-launched or service VMs, so that each VM contains only configurations
supported in that kind of VM.
This patch adds support of xs:alternative nodes to the schema transformer
so that default values can be populated appropriately after we add
xs:alternative nodes to the schema.
Tracked-On: #6690
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Today the script default_populator.py fills in default values by visiting
an XML schema and an XML tree simultaneously and add a node to the latter
whenever one satisfying the schema does not exist. This visiting logic is
not only useful for filling in default values, but also for upgrading
XMLs to new schemas.
This patch abstracts the flow of the visiting above as a separate class,
just like tree visitors or transformers. The current default value
populator is then refactored to extend that class by inheritance.
Tracked-On: #6690
Signed-off-by: Junjie Mao <junjie.mao@intel.com>