How to achieve dynamic binding
Assuming we have an xml document like the one below.
<data>
<node1 null="true" type="integer" />
<node2 null="true" type="date" />
<node3 null="false" type="string" />
</data>
we need to transform this doc into XForms doc. The behaviour task in XForms is placed inside <model> </model> node.
If we write this part by hand, it looks like
<model>
<xforms:bind nodeset="node1" required="true()" type="xs:integer"/>
<xforms:bind nodeset="node2" required="true()" type="xs:date"/>
<xforms:bind nodeset="node3" required="false()" type="xs:string"/>
</model>
But I need to call a template which builds up this part dynamically. i.e. Xslt processor will visit each node in xml document, read its name as well as its attributes values (null, type), then construct the desired <model> node.
The main structure of this template could be like this
<xsl:template match="data">
<xsl:for-each select="data/*">
<xsl:value-of select="local-name()"/>
<xsl:value-of select="@null" />
<xsl:value-of select="@type" />
</xsl:for-each>
</xsl:template>
My question is how to build up a generic statement that generates the binding part?
Any help is much appreciated
|