Help on XSLT transformation
Hi. Guys
I am trying to transform the below xml doc into XForms. The stylesheet contains of two templates. The first is to read the xml doc and copy the instance data. The second is to built up the binding part. Although the binding part is contrasted well (i.e. the instance data has successfully initiated), but it is not functioned as it suppose as to be. in addition, the UI is rendered just fine.
I diagnostic the problem as to do with copying the instance data, this is because if I eliminate the first template and place the instance data by hand, every thing is running just perfect.
Any clue?
Your help is much appreciated
Here is the xml doc.
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="bind.xsl"?>
<data>
<node1 null="true" type="integer"> First Node </node1>
<node2 null="true" type="date" > Second Node </node2>
<node3 null="false" type="string" > Third Node </node3>
</data>
And here is the stylesheet.
<?xml version='1.0'?>
<xsl:stylesheet version="2.0" xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xforms="http://www.w3.org/2002/xforms/cr"
xmlns:xmml="http://www.xmml.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output method="xhtml" indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
<xsl:template match="/">
<html >
<head> <title>Title comes here </title>
<xforms:model>
<xforms:submission action="URL" method="post" />
<xforms:instance xmlns="">
<xsl:apply-templates select="data" />
</xforms:instance>
<xsl:for-each select="data/*">
<xsl:call-template name="templatename" />
<xforms:bind nodeset="{local-name()}"
required="{concat(@null,'()')}"
type="{concat('xs:', @type)}"/>
</xsl:for-each>
</xforms:model>
</head>
<body>
<p>
<xforms:input ref="node1" > <xforms:label> <xsl:value-of select="data/node1" /> </xforms:label> </xforms:input>
</p>
<p>
<xforms:input ref="node2" > <xforms:label> <xsl:value-of select="data/node2" /> </xforms:label> </xforms:input>
</p>
<p>
<xforms:input ref="node3" > <xforms:label> <xsl:value-of select="data/node3" /> </xforms:label> </xforms:input>
</p>
<p> <xforms:submit> <xforms:label> Click here to submit </xforms:label> </xforms:submit> </p>
</body>
</html>
</xsl:template>
<xsl:template match="data" >
<xsl:copy>
<xsl:copy-of select="data/*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="data" name="templatename">
<xforms:bind>
<xsl:for-each select="data/*">
<xsl:attribute name="nodeset"><xsl:value-of select="local-name()"/></xsl:attribute>
<xsl:attribute name="required"><xsl:value-of select="@null"/>()</xsl:attribute>
<xsl:attribute name="type">xs:<xsl:value-of select="@type"/></xsl:attribute>
</xsl:for-each>
</xforms:bind>
</xsl:template>
</xsl:stylesheet>
|