[Xsltforms-support] A couple of questions about subforms
Brought to you by:
alain-couthures
From: Eric v. d. V. <vd...@dy...> - 2013-05-18 16:50:01
|
Hi, I am testing the subforms feature and I have a couple of questions. 1) I'd like to include the same subform twice in form (to handle two different instance nodes) and that doesn't seem to be working (the second subform isn't displayed). Is that a known limitation or have I missed something? 2) My subform has a local instance and I need to move data between the current node in the main form and the subform local instance. The context node appears to be available in the XForms controls (I can write <xf:output ref="."/> and the current node in the main form is displayed) but I don't know how to access this node in actions in the subform. Is there a function I can use for that? Thanks, Eric PS: currently my main form is: <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <?xsltforms-options debug="yes"?> <xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events"> <xh:head> <xh:title>Subforms</xh:title> <xf:model> <xf:instance id="main"> <figures> <rectangle height="10in" width="4em"/> </figures> </xf:instance> <xf:action ev:event="xforms-ready"> <xf:load show="embed" targetid="height-control" resource="subform-embedded.xml"/> <!-- <xf:load show="embed" targetid="width-control" resource="subform-embedded.xml"/>--> </xf:action> </xf:model> </xh:head> <xh:body> <xf:group ref="rectangle"> <xf:group ref="@height" id="height-control"/> <xf:group ref="@width" id="width-control"/> </xf:group> </xh:body> </xh:html> and my subform is: <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <?xsltforms-options debug="yes"?> <xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events"> <xh:head> <xh:title>A subform</xh:title> <xf:model> <xf:instance id="global"> <data>20px</data> </xf:instance> <xf:instance id="local"> <height> <value/> <unit/> </height> </xf:instance> <xf:action ev:event="xforms-ready"> <xf:setvalue ref="instance('local')/value" value="translate(instance('global'), '%incmptxe', '')"/> <xf:setvalue ref="instance('local')/unit" value="translate(instance('global'), '0123456789', '')"/> </xf:action> <xf:action ev:event="xforms-value-changed" ev:observer="value-control"> <xf:setvalue ref="instance('global')" value="concat(instance('local')/value, instance('local')/unit)"/> </xf:action> <xf:action ev:event="xforms-value-changed" ev:observer="unit-control"> <xf:setvalue ref="instance('global')" value="concat(instance('local')/value, instance('local')/unit)"/> </xf:action> </xf:model> </xh:head> <xh:body> <xf:output ref="."> <xf:label><xf:output value="name(.)"/>: </xf:label> </xf:output> <br/> <xf:group ref="instance('local')"> <xf:input ref="value" id="value-control"> <xf:label>Height: </xf:label> </xf:input> <xf:select1 ref="unit" id="unit-control"> <xf:label/> <xf:item> <xf:label>pixels</xf:label> <xf:value>px</xf:value> </xf:item> <xf:item> <xf:label>font size</xf:label> <xf:value>em</xf:value> </xf:item> <xf:item> <xf:label>font height</xf:label> <xf:value>ex</xf:value> </xf:item> <xf:item> <xf:label>inches</xf:label> <xf:value>in</xf:value> </xf:item> <xf:item> <xf:label>centimeters</xf:label> <xf:value>cm</xf:value> </xf:item> <xf:item> <xf:label>millimeters</xf:label> <xf:value>mm</xf:value> </xf:item> <xf:item> <xf:label>points</xf:label> <xf:value>pt</xf:value> </xf:item> <xf:item> <xf:label>picas</xf:label> <xf:value>pc</xf:value> </xf:item> <xf:item> <xf:label>%</xf:label> <xf:value>%</xf:value> </xf:item> </xf:select1> </xf:group> </xh:body> </xh:html> and of course I need to replace these "instance('global')" by an accessor to the current node in the main instance. |