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




------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
Xsltforms-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xsltforms-support

Reply via email to