S
Scott Zabolotzky
I've got an XML file that contains both a data section and a
custom schema section. The data may represent only a subset of
the parameters defined by the schema.
I'm new to XSLT and I'm trying to figure out how to generate a
tranform that will create an HTML form from the schema section
and populate the controls with the values from the data section
(if present).
I _think_ I'd be able to come up with the transform to generate
the form based on the schema (remember, I'm new to this) but the
conditional "if value present in data section, populate control
with value" is something I that I don't even know how to begin to
implement. If you're walking down the schema nodes how do you
refer back to nodes that may be present in the data and extract
their values?
Any advice would be greatly appreciated.
<?xml version="1.0" encoding="UTF-8"?>
<Model>
<Data>
<Component Name="A">
<Param Name="Param1">True</Param>
<Param Name="Param2">False</Param>
</Component>
<Component Name="B">
<Param Name="Param1">John Doe</Param>
<Group Name="Group1" Type="Common">
<Param Name="SubParam1">True</Param>
<Param Name="SubParam2">5</Param>
</Group>
</Component>
</Data>
<Schema>
<Component Name="A">
<Param Name="Param1" DataType="Bool" />
<Param Name="Param2" DataType="Bool" />
</Component>
<Component Name="B">
<Param Name="Param1" DataType="String" />
<Group Name="Common">
<Param Name="SubParam1" DataType="Bool" />
<Param Name="SubParam3" DataType="PosInt" Units="KB" />
</Group>
</Component>
<Component Name="C">
<Param Name="Param1" DataType="Bool" />
<Param Name="Param2" DataType="String" />
</Component>
</Schema>
</Model>
custom schema section. The data may represent only a subset of
the parameters defined by the schema.
I'm new to XSLT and I'm trying to figure out how to generate a
tranform that will create an HTML form from the schema section
and populate the controls with the values from the data section
(if present).
I _think_ I'd be able to come up with the transform to generate
the form based on the schema (remember, I'm new to this) but the
conditional "if value present in data section, populate control
with value" is something I that I don't even know how to begin to
implement. If you're walking down the schema nodes how do you
refer back to nodes that may be present in the data and extract
their values?
Any advice would be greatly appreciated.
<?xml version="1.0" encoding="UTF-8"?>
<Model>
<Data>
<Component Name="A">
<Param Name="Param1">True</Param>
<Param Name="Param2">False</Param>
</Component>
<Component Name="B">
<Param Name="Param1">John Doe</Param>
<Group Name="Group1" Type="Common">
<Param Name="SubParam1">True</Param>
<Param Name="SubParam2">5</Param>
</Group>
</Component>
</Data>
<Schema>
<Component Name="A">
<Param Name="Param1" DataType="Bool" />
<Param Name="Param2" DataType="Bool" />
</Component>
<Component Name="B">
<Param Name="Param1" DataType="String" />
<Group Name="Common">
<Param Name="SubParam1" DataType="Bool" />
<Param Name="SubParam3" DataType="PosInt" Units="KB" />
</Group>
</Component>
<Component Name="C">
<Param Name="Param1" DataType="Bool" />
<Param Name="Param2" DataType="String" />
</Component>
</Schema>
</Model>