Hi Morgan, Actually, your XQuery essentially only contains an xhtml document with xforms. I think the xforms-ready event isn’t working as you would like. I have to ask, why not just put the value inside the instance?
I do notice two things that might prevent the action from working: 1. Your instance is in default (no-prefix) empty namespace, whereas the default namespace on the action is that of xhtml (as defined on the root of the entire page). 2. I notice you use a qualified name for the action ‘if’ attribute. What if you drop the prefix? I would also kindly remark that this mailing list isn’t the best resource for XForms-related questions. You might get more (and perhaps better) answers on an XForms or XSLTForms mailing list. You could also post your question on stackoverflow.. Kind regards, Geert Van: general-boun...@developer.marklogic.com [mailto:general-boun...@developer.marklogic.com] Namens mcundi...@comcast.net Verzonden: vrijdag 30 september 2011 2:55 Aan: general@developer.marklogic.com Onderwerp: [MarkLogic Dev General] setvalue in XForm Hello all: I am attempting to create an Xform (using XSLTForms and MarkLogic) where the instance initially contains no data, like this: <xf:model> <xf:instance xmlns="" id="i1"> <table> <row> <column></column> </row> </table> </xf:instance> </xf:model> I would like to set the value of the column element to "default" upon loading the form in a browser but have not been able to do so. My stab at it is the xquery below but it does not work as hoped. Can anyone tell me a correct way to do this? Thanks, Morgan ---------------------------------- xquery version "1.0-ml"; declare namespace xdmp="http://marklogic.com/xdmp"; let $page := (xdmp:set-response-content-type("application/xml"), <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events"> <head> <xf:model> <xf:instance xmlns="" id="i1"> <table> <row> <column></column> </row> </table> </xf:instance> </xf:model> <xf:action ev:event="xforms-ready"> <xf:action xf:if="string(instance('i1')/row/column) != 'default'"> <xf:setvalue ref="instance('i1')/row/column" value="'default'" /> </xf:action> </xf:action> </head> <body> <h3>Datafield</h3> <xf:group nodeset="/table"> <xf:repeat id="repeat-row" nodeset="row"> <xf:input ref="column"/> </xf:repeat> <xf:trigger> <xf:label>Add Row</xf:label> <xf:action ev:event="DOMActivate" if="index('repeat-row') != (count(row))"> <xf:insert nodeset="row" at="index('repeat-row')" position="after" /> <xf:setvalue ref="row[index('repeat-row')]/column" value="/table/row/column" /> </xf:action> <xf:action ev:event="DOMActivate" if="index('repeat-row') = (count(row))"> <xf:insert nodeset="row[last()]" position="after" at="last()"/> <xf:setvalue ref="row[last()]/column" value="/table/row/column"/> </xf:action> </xf:trigger> </xf:group> </body> </html> ) let $xslt-pi := processing-instruction xml-stylesheet {'type="text/xsl" href="xsltforms/xsltforms.xsl"'} return ($xslt-pi, $page)
_______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general