Hi,
I have the following instance for an XML table: <xforms:instance id="table-template"> <table xmlns=""> <tgroup cols=""> <thead></thead> <tbody></tbody> </tgroup> </table> </xforms:instance> <thead> and <tbody> can have a <row> attribute. <row> can have <entry> for each table cell in the row. Is it possible to lock the number of <entry> elements within <row> based on the number defined in tgroup/@cols? For example, I would like to create an "Add Row" trigger that inserts a <row> into <tbody>. If I define @cols as 4, I'd like "Add Row" to insert <row><entry/><entry/><entry/><entry/></row>, with an input for each <entry/> Or maybe there is a better way of creating a table? Thanks, Ethan -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
Ethan,
On Mon, Oct 26, 2009 at 11:40 AM, Ethan Gruber <[hidden email]> wrote: > For example, I would like to create an "Add Row" trigger that inserts a > <row> into <tbody>. If I define @cols as 4, I'd like "Add Row" to insert > <row><entry/><entry/><entry/><entry/></row>, with an input for each <entry/> It looks like you need a way to execute an action a given number of times. In pseudo-code, you could do something like: <xforms:action xxforms:iterate="for $i in 1 to tgroup/@cols return xxforms:element('dummy')"> <xforms:insert context="row" origin="xxforms:element('entry')"/> </xforms:action> The 1 to tgroup/@cols returns a sequence of (1, 2, 3, 4) if you have 4 columns, and the xxforms:element() creates an element for each one, as the context for XPath evaluation is expected to be a node. Alex -- Orbeon Forms - Web forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ My Twitter: http://twitter.com/avernet -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Thanks, Alex
I understand the logic now, but there is probably something wrong with my syntax since it is still not working properly. Here's a clip of what I have (current context is tgroup) <div> <xforms:trigger appearance="minimal"> <xforms:label> <img src="/apps/ead/images/add.gif"/>Add Table Header</xforms:label> <!-- inserts row into thead: this works --> <xforms:insert ev:event="DOMActivate" context="thead" origin="instance('row-template')"/> <!-- loop from 1 to @cols to add an entries into the thead/row: does not work --> <xforms:action xxforms:iterate="for $i in 1 to @cols return xxforms:element('dummy')"> <xforms:insert context="thead/row" origin="instance('entry-template')"/> </xforms:action> </xforms:trigger> </xforms:group> </div> <xforms:input ref="@cols"> <xforms:label>Columns</xforms:label> <xforms:alert>Required</xforms:alert> <xforms:hint>This must be an integer</xforms:hint> </xforms:input> <xforms:group ref="thead/row"> <div class="subsection"> <!-- this appears --> <h4>Table Header</h4> <xforms:trigger appearance="minimal"> <xforms:delete ev:event="DOMActivate" nodeset="."/> <xforms:label> <img src="/apps/ead/images/remove.gif"/> </xforms:label> </xforms:trigger> <!-- this does not appear --> <xforms:repeat nodeset="entry"> <div> <xforms:input ref="."> <xforms:label>Cell</xforms:label> </xforms:input> </div> </xforms:repeat> </div> </xforms:group> --- What exactly is xxforms:element('dummy')? Why does something need to be returned? Thanks, Ethan On Mon, Oct 26, 2009 at 9:58 PM, Alessandro Vernet <[hidden email]> wrote: Ethan, -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Ethan,
If my hunch is correct... 'Dummy' is just an arbitrary element returned by xxforms:iterate. Since the value of the xxforms:iterate attribute must be a node/nodeset, the statement: <xf:action xxforms:iterate="for $i in 1 to 4 return xxforms:element('dummy')"> ... </xf:action> will return four <dummy/> elements for the xxforms:iterate attribute to iterate over. This is the same as doing: <xf:instance id="test"> <data> <dummy/> <dummy/> <dummy/> <dummy/> </data> </xf:instance> ... <xf:group ref="instance('test')"> <xf:action xxforms:iterate="dummy"> ... </xf:action> <xf:group> Hope this helps, Philip
|
Free forum by Nabble | Edit this page |