Thread: [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. |
From: Alain C. <ala...@ag...> - 2013-05-20 21:11:53
|
Hello Eric, > 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? This is possible with XSLTForms only when there is no id conflict which means no id in the subform. There is an example of this at http://www.agencexml.com/xsltforms/books.xml for http://www.agencexml.com/xsltforms/writers.xml. > > 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? > > I have to modify XSLTForms so that a local instance without an id will be distinct for each subform. One extra function to access this instance is to be added and probably another one to allow access to the current context in bindings. Instead of having to launch a load action for each subform, it would be more convenient to add another control type, such as xf:component with a @ref attribute and a @resource attribute. This does not seem difficult to do so I will tell you more soon! What do you think? -Alain |
From: Eric v. d. V. <vd...@dy...> - 2013-05-21 16:04:48
|
Hi Alain, Le lundi 20 mai 2013 à 23:11 +0200, Alain Couthures a écrit : > Hello Eric, > > > 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? > This is possible with XSLTForms only when there is no id conflict which > means no id in the subform. There is an example of this at > http://www.agencexml.com/xsltforms/books.xml for > http://www.agencexml.com/xsltforms/writers.xml. Yes, I had seen this example but I had thought that the reason why we had no conflict was because the form was called multiple times but from within a repeat! > > 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? > > > > > I have to modify XSLTForms so that a local instance without an id will > be distinct for each subform. One extra function to access this instance > is to be added and probably another one to allow access to the current > context in bindings. > > Instead of having to launch a load action for each subform, it would be > more convenient to add another control type, such as xf:component with a > @ref attribute and a @resource attribute. > > This does not seem difficult to do so I will tell you more soon! > > What do you think? For this use case we need: * A way to access the context node to which the "component" is bound in the caller form. An extension function would be fine for that. * A way to define and access a local instance "private" to the component. In this specific case the component needs only one instance but I am sure we can find more complex cases where several instances would be more convenient in which case anonymous instances wouldn't work. * We also need to receive events such as xforms-ready in the component. In don't know if you're familiar with Orbeon's XBL implementation [1] but this component would be defined as: [1] http://wiki.orbeon.com/forms/doc/developer-guide/xbl-components-guide <xbl:xbl script-type="application/xhtml+xml"> <xbl:binding id="my-dimension" element="my|dimension" xxbl:mode="lhha binding value"> <xbl:handlers> <xbl:handler event="xforms-enabled xforms-value-changed"> <xf:setvalue ref="instance('my-dimension-instance')/value" value="translate(xxf:binding('my-dimension'), '%incmptxe', '')"/> <xf:setvalue ref="instance('my-dimension-instance')/unit" value="translate(xxf:binding('my-dimension'), '0123456789', '')"/> </xbl:handler> </xbl:handlers> <xbl:implementation> <xf:model id="my-dimension-model"> <xf:instance id="my-dimension-instance"> <dimension> <value/> <unit/> </dimension> </xf:instance> <xf:setvalue ev:event="xforms-value-changed" ev:observer="my-dimension-value-control" ref="xxf:binding('my-dimension')" value="concat(instance('my-dimension-instance')/value, instance('my-dimension-instance')/unit)"/> <xf:setvalue ev:event="xforms-value-changed" ev:observer="my-dimension-unit-control" ref="xxf:binding('my-dimension')" value="concat(instance('my-dimension-instance')/value, instance('my-dimension-instance')/unit)"/> </xf:model> </xbl:implementation> <xbl:template> <xf:input ref="value" id="my-dimension-value-control"/> <xf:select1 ref="unit" id="my-dimension-unit-control"> <xf:label/> <xf:item> <xf:label>pixels</xf:label> <xf:value>px</xf:value> </xf:item> .../... </xf:select1> </xbl:template> </xbl:binding> </xbl:xbl> I won't go into the details, but see how: * The bound node in the caller form instance is accessed through "xxf:binding('my-dimension')" (where "my-dimension" is the component's id) * Local (private) instances can have ids and are accessed through the standard instance() function ("instance('my-dimension-instance')" in our case) * A handler section is used to define event handlers for events coming "from the external". Thanks, Eric > -Alain > |
From: Alain C. <ala...@ag...> - 2013-06-01 21:03:21
|
Hi Eric, I have implemented a new component control in XSLTForms. It is named "xf:component" and has two attributes named "@ref" and "@resource". There are still restrictions within a component: ids cannot be used if the component is to be instantiated more than once. The default instance is local to each instantiated component and the subform-instance() function can be used to get the document element of it. From the main form to the component, a binding with a special mip named "changed" is defined. The subform-context() allows to reference the node bound to the component control in the main form. The corresponding build has been committed to repositories: http://sourceforge.net/p/xsltforms/code/ci/master/tree/build/ Performance can surely be optimized (component source is currently loaded as many time as instantiated...) and this new control has been tested only in this limited test case: figures.xml: <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <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>Figures</xh:title> <xf:model> <xf:instance id="main"> <figures> <rectangle height="10in" width="4em"/> <circle radius="8%"/> </figures> </xf:instance> </xf:model> </xh:head> <xh:body> <xf:repeat ref="*"> <xf:output value="name()"/> <ul> <xf:repeat ref="@*"> <li> <xf:component ref="." resource="size.xml"/> <xf:output value="concat(' = ',.)"/> </li> </xf:repeat> </ul> </xf:repeat> </xh:body> </xh:html> size.xml: <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ev="http://www.w3.org/2001/xml-events"> <xh:head> <xh:title>Size</xh:title> <xf:model> <xf:instance> <size> <value xsi:type="xsd:decimal">2</value> <unit>cm</unit> </size> </xf:instance> <xf:bind ref="subform-instance()/value" changed="translate(subform-context(), '%incmptxe', '')"/> <xf:bind ref="subform-instance()/unit" changed="translate(subform-context(), '0123456789', '')"/> </xf:model> </xh:head> <xh:body> <xf:input ref="subform-instance()/value" incremental="true"> <xf:label><xf:output value="local-name(subform-context())"/>: </xf:label> <xf:setvalue ev:event="xforms-value-changed" ref="subform-context()" value="concat(subform-instance()/value, subform-instance()/unit)"/> </xf:input> <xf:select1 ref="subform-instance()/unit"> <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:setvalue ev:event="xforms-value-changed" ref="subform-context()" value="concat(subform-instance()/value, subform-instance()/unit)"/> </xf:select1> </xh:body> </xh:html> Thank you for your feedbacks! -Alain > 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? > > For this use case we need: > > * A way to access the context node to which the "component" is > bound in the caller form. An extension function would be fine > for that. > * A way to define and access a local instance "private" to the > component. In this specific case the component needs only one > instance but I am sure we can find more complex cases where > several instances would be more convenient in which case > anonymous instances wouldn't work. > * We also need to receive events such as xforms-ready in the > component. > > In don't know if you're familiar with Orbeon's XBL implementation [1] > but this component would be defined as: > > [1] > http://wiki.orbeon.com/forms/doc/developer-guide/xbl-components-guide > > <xbl:xbl script-type="application/xhtml+xml"> > <xbl:binding id="my-dimension" element="my|dimension" xxbl:mode="lhha > binding value"> > <xbl:handlers> > <xbl:handler event="xforms-enabled xforms-value-changed"> > <xf:setvalue ref="instance('my-dimension-instance')/value" > value="translate(xxf:binding('my-dimension'), '%incmptxe', '')"/> > <xf:setvalue ref="instance('my-dimension-instance')/unit" > value="translate(xxf:binding('my-dimension'), '0123456789', '')"/> > </xbl:handler> > </xbl:handlers> > <xbl:implementation> > <xf:model id="my-dimension-model"> > <xf:instance id="my-dimension-instance"> > <dimension> > <value/> > <unit/> > </dimension> > </xf:instance> > <xf:setvalue ev:event="xforms-value-changed" > ev:observer="my-dimension-value-control" > ref="xxf:binding('my-dimension')" > value="concat(instance('my-dimension-instance')/value, > instance('my-dimension-instance')/unit)"/> > <xf:setvalue ev:event="xforms-value-changed" > ev:observer="my-dimension-unit-control" > ref="xxf:binding('my-dimension')" > value="concat(instance('my-dimension-instance')/value, > instance('my-dimension-instance')/unit)"/> > </xf:model> > </xbl:implementation> > <xbl:template> > <xf:input ref="value" id="my-dimension-value-control"/> > <xf:select1 ref="unit" id="my-dimension-unit-control"> > <xf:label/> > <xf:item> > <xf:label>pixels</xf:label> > <xf:value>px</xf:value> > </xf:item> > .../... > </xf:select1> > </xbl:template> > </xbl:binding> > </xbl:xbl> > > I won't go into the details, but see how: > > * The bound node in the caller form instance is accessed through > "xxf:binding('my-dimension')" (where "my-dimension" is the > component's id) > * Local (private) instances can have ids and are accessed through > the standard instance() function > ("instance('my-dimension-instance')" in our case) > * A handler section is used to define event handlers for events > coming "from the external". > > |
From: Eric v. d. V. <vd...@dy...> - 2013-06-05 19:33:41
|
Hi Alain, Your example works perfectly well and does meet my requirements but I have a few questions ;) ... The name of these functions (subform-instance() and subform-context()) made me expect that they would be working not only with <xf:component/> but also with "regular" subforms and that doesn't seem to be the case: I have updated your example to load size.xml as a subform and haven't been able to get it working. Are these functions limited to components? Similarly, is the new MIP (@changed) available only in that context or is it available more generally (as far as I understand it it's a kind of "calculate" except that the field doesn't become read-only)? Thanks, Eric Le samedi 01 juin 2013 à 23:03 +0200, Alain Couthures a écrit : > Hi Eric, > > I have implemented a new component control in XSLTForms. It is named > "xf:component" and has two attributes named "@ref" and "@resource". > > There are still restrictions within a component: ids cannot be used if > the component is to be instantiated more than once. The default instance > is local to each instantiated component and the subform-instance() > function can be used to get the document element of it. > > From the main form to the component, a binding with a special mip named > "changed" is defined. The subform-context() allows to reference the node > bound to the component control in the main form. > > The corresponding build has been committed to repositories: > http://sourceforge.net/p/xsltforms/code/ci/master/tree/build/ > > Performance can surely be optimized (component source is currently > loaded as many time as instantiated...) and this new control has been > tested only in this limited test case: > > figures.xml: > > <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> > <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>Figures</xh:title> > <xf:model> > <xf:instance id="main"> > <figures> > <rectangle height="10in" width="4em"/> > <circle radius="8%"/> > </figures> > </xf:instance> > </xf:model> > </xh:head> > <xh:body> > <xf:repeat ref="*"> > <xf:output value="name()"/> > <ul> > <xf:repeat ref="@*"> > <li> > <xf:component ref="." resource="size.xml"/> > <xf:output value="concat(' = ',.)"/> > </li> > </xf:repeat> > </ul> > </xf:repeat> > </xh:body> > </xh:html> > > size.xml: > > <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> > <xh:html xmlns:xh="http://www.w3.org/1999/xhtml" > xmlns:xf="http://www.w3.org/2002/xforms" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:ev="http://www.w3.org/2001/xml-events"> > <xh:head> > <xh:title>Size</xh:title> > <xf:model> > <xf:instance> > <size> > <value xsi:type="xsd:decimal">2</value> > <unit>cm</unit> > </size> > </xf:instance> > <xf:bind ref="subform-instance()/value" > changed="translate(subform-context(), '%incmptxe', '')"/> > <xf:bind ref="subform-instance()/unit" > changed="translate(subform-context(), '0123456789', '')"/> > </xf:model> > </xh:head> > <xh:body> > <xf:input ref="subform-instance()/value" incremental="true"> > <xf:label><xf:output > value="local-name(subform-context())"/>: </xf:label> > <xf:setvalue ev:event="xforms-value-changed" > ref="subform-context()" value="concat(subform-instance()/value, > subform-instance()/unit)"/> > </xf:input> > <xf:select1 ref="subform-instance()/unit"> > <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:setvalue ev:event="xforms-value-changed" > ref="subform-context()" value="concat(subform-instance()/value, > subform-instance()/unit)"/> > </xf:select1> > </xh:body> > </xh:html> > > > Thank you for your feedbacks! > > -Alain |
From: Alain C. <ala...@ag...> - 2013-06-05 20:03:20
|
Hi Eric, > Your example works perfectly well and does meet my requirements but I > have a few questions ;) ... > > The name of these functions (subform-instance() and subform-context()) > made me expect that they would be working not only with <xf:component/> > but also with "regular" subforms and that doesn't seem to be the case: I > have updated your example to load size.xml as a subform and haven't been > able to get it working. > > Are these functions limited to components? Currently, the default instance of a subform is merged with the one in the main form while, from a component, it has its own id. That's why those functions don't work with subforms even if their name would say so ... ;-) This might change, of course, but I have first to explicitly check with customers already using subforms. > > Similarly, is the new MIP (@changed) available only in that context or > is it available more generally (as far as I understand it it's a kind of > "calculate" except that the field doesn't become read-only)? Yes, @changed is a sort of @calculate with a @readonly="false" (I could not use @calculate because of a loop when refreshing). Again, the MIP name has not been validated by the W3C Forms Group... This is clearly an experimental feature built for your initial requirements ;-) XSLTForms is a versatile product which can very easily be extended at any level (I know I'm not the only one doing this...)! -Alain |
From: Eric v. d. V. <vd...@dy...> - 2013-06-05 20:22:39
|
Alain, Le mercredi 05 juin 2013 à 22:03 +0200, Alain Couthures a écrit : > Hi Eric, > > Your example works perfectly well and does meet my requirements but I > > have a few questions ;) ... > > > > The name of these functions (subform-instance() and subform-context()) > > made me expect that they would be working not only with <xf:component/> > > but also with "regular" subforms and that doesn't seem to be the case: I > > have updated your example to load size.xml as a subform and haven't been > > able to get it working. > > > > Are these functions limited to components? > Currently, the default instance of a subform is merged with the one in > the main form while, from a component, it has its own id. That's why > those functions don't work with subforms even if their name would say so > ... ;-) That's what I had guessed but can you elaborate on this instance merge? I had the feeling that the context node in the master form was becoming the instance of the subform, is that what you mean? > This might change, of course, but I have first to explicitly check with > customers already using subforms. Couldn't subform-instance() and subform-context() be pointers to the subform default instance and context node without changing the behaviour of this "merge"? > > Similarly, is the new MIP (@changed) available only in that context or > > is it available more generally (as far as I understand it it's a kind of > > "calculate" except that the field doesn't become read-only)? > Yes, @changed is a sort of @calculate with a @readonly="false" (I could > not use @calculate because of a loop when refreshing). Again, the MIP > name has not been validated by the W3C Forms Group... > > This is clearly an experimental feature built for your initial > requirements ;-) Indeed! > XSLTForms is a versatile product which can very easily be extended at > any level (I know I'm not the only one doing this...)! Sounds impressive... Thanks, Eric > -Alain > |
From: Alain C. <ala...@ag...> - 2013-06-05 20:46:24
|
Eric, >> Currently, the default instance of a subform is merged with the one >> in the main form while, from a component, it has its own id. That's >> why those functions don't work with subforms even if their name would >> say so ... ;-) > That's what I had guessed but can you elaborate on this instance merge? For subforms, models already with the same ids in the main form are merged: instances are merged and bindings are added in the main form. Merging instances is similar: if the corresponding id already exists in the main form, it is ignored; if not, it is added. The default model without an id and the default instance without an id are merged as if they had the same id. > > I had the feeling that the context node in the master form was becoming > the instance of the subform, is that what you mean? No, in a subform, instances are identical but scoping is effective and "." references the context node. > > Couldn't subform-instance() and subform-context() be pointers to the > subform default instance and context node without changing the behaviour > of this "merge"? Yes, that's possible but I would say that subform-instance() should be useless unless, depending on the different situations, a component would also be used as a subform. >> XSLTForms is a versatile product which can very easily be extended at >> any level (I know I'm not the only one doing this...)! > Sounds impressive... > > Well, XSLT is powerful and Javascript can now do a lot of things! -Alain |
From: Eric v. d. V. <vd...@dy...> - 2013-06-05 21:19:45
|
Alain, That's clearer, thanks for these explanations! I have a first bug report for these new features ;) ... If you replace the repeats by groups that's no longer working: <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <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>Figures</xh:title> <xf:model> <xf:instance id="main"> <figures> <rectangle height="10in" width="4em"/> <circle radius="8%"/> </figures> </xf:instance> </xf:model> </xh:head> <xh:body> <xf:group ref="rectangle"> <xf:output value="name()"/> <ul> <xf:group ref="@height"> <li> <xf:component ref="." resource="size.xml"/> <xf:output value="concat(' = ',.)"/> </li> </xf:group> <xf:group ref="@width"> <li> <xf:component ref="." resource="size.xml"/> <xf:output value="concat(' = ',.)"/> </li> </xf:group> </ul> </xf:group> </xh:body> </xh:html> The values which are displayed by the component in its input fields are now the initial values that are in the subform! Thanks, Eric Le mercredi 05 juin 2013 à 22:46 +0200, Alain Couthures a écrit : > Eric, > >> Currently, the default instance of a subform is merged with the one > >> in the main form while, from a component, it has its own id. That's > >> why those functions don't work with subforms even if their name would > >> say so ... ;-) > > That's what I had guessed but can you elaborate on this instance merge? > For subforms, models already with the same ids in the main form are > merged: instances are merged and bindings are added in the main form. > Merging instances is similar: if the corresponding id already exists in > the main form, it is ignored; if not, it is added. > > The default model without an id and the default instance without an id > are merged as if they had the same id. > > > > I had the feeling that the context node in the master form was becoming > > the instance of the subform, is that what you mean? > No, in a subform, instances are identical but scoping is effective and > "." references the context node. > > > > Couldn't subform-instance() and subform-context() be pointers to the > > subform default instance and context node without changing the behaviour > > of this "merge"? > Yes, that's possible but I would say that subform-instance() should be > useless unless, depending on the different situations, a component would > also be used as a subform. > >> XSLTForms is a versatile product which can very easily be extended at > >> any level (I know I'm not the only one doing this...)! > > Sounds impressive... > > > > > Well, XSLT is powerful and Javascript can now do a lot of things! > > -Alain > |