[Xsltforms-support] XSLTForms transform function
Brought to you by:
alain-couthures
From: <mcu...@co...> - 2011-10-11 15:27:54
|
Hello All, 1. My general question is: can you point me to any examples that make use of the XSLTForms transform function? The only one I have been able to find is the one provided by Alain at: http://www.agencexml.com/svgopen/graphs.xml 2. My specific question is: is it possible to use the output from the transform function to insert an element node into an existing instance? My attempt to do this is below but it does not work as hoped. Note: the referenced stylesheet (ex2.xsl) just returns this: <p>para content</p> Thank you. 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="http://www.w3.org/1999/xhtml" id="i1"> <table> <row> <column></column> </row> </table> </xf:instance> <xf:insert ev:event="xforms-ready" context="instance('i1')/row/column" nodeset="p" origin="transform(instance('i2'), 'ex2.xsl')"/> </xf:model> <xf:model> <xf:instance xmlns="" id="i2"> <p>para content</p> </xf:instance> </xf:model> </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/p" /> </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/p"/> </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) ------------------------------- |