Re: [Xsltforms-support] applying a stylesheet in an instance to data in an instance
Brought to you by:
alain-couthures
From: C. M. Sperberg-M. <cm...@bl...> - 2012-07-17 22:04:04
|
On Jul 17, 2012, at 3:17 PM, Alain Couthures wrote: > Rev. 550 includes a new experimental action named "setnode" with @inner or @outer attributes to perform a "loadXML" for the corresponding node. That looks great! Thank you very much. > > Here is a test case: > <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> > <title>Inner & Outer Set Node</title> > <xf:model> > <xf:instance> > <data xmlns=""> > <item>a</item> > </data> > </xf:instance> > </xf:model> > </head> > <body> > <h1>Inner & Outer Set Node</h1> > <xf:output value="item"/> > <xf:trigger> > <xf:label>Inner</xf:label> > <xf:setnode ref="." ev:event="DOMActivate" inner="'<item>b</item>'"/> > </xf:trigger> > <xf:trigger> > <xf:label>Outer</xf:label> > <xf:setnode ref="item" ev:event="DOMActivate" outer="'<item>c</item>'"/> > </xf:trigger> > </body> > </html> This works fine. To try to make sure I understood the new action, however, I tried the following variation, which works as expected with one exception: <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> <title>Inner & Outer Set Node</title> <xf:model> <xf:instance> <data xmlns=""> <item>a</item> </data> </xf:instance> </xf:model> </head> <body style="margin: 0.5em;"> <h1>Inner & Outer Set Node</h1> <p>The instance currently looks like this:</p> <pre> <xf:output value="serialize(.)" mediatype="text/plain"> </xf:output> </pre> <hr/> <p>These buttons apply the <code>setnode</code> action to the instance root (<code>.</code>):</p> <xf:trigger> <xf:label>Set Inner to '<item>b</item>'</xf:label> <xf:setnode ref="." ev:event="DOMActivate" inner="'<item>b</item>'"/> </xf:trigger> <xf:trigger> <xf:label>Set Outer to '<item>c</item>'</xf:label> <xf:setnode ref="." ev:event="DOMActivate" outer="'<item>c</item>'"/> </xf:trigger> <hr/> <p>These buttons apply the <code>setnode</code> action to the child of the instance root (<code>./item</code>):</p> <xf:trigger> <xf:label>Set Inner to '<item>d</item>'</xf:label> <xf:setnode ref="./item" ev:event="DOMActivate" inner="'<item>d</item>'"/> </xf:trigger> <xf:trigger> <xf:label>Set Outer to '<item>e</item>'</xf:label> <xf:setnode ref="./item" ev:event="DOMActivate" outer="'<item>e</item>'"/> </xf:trigger> </body> </html> The second button of the first pair attempts to supply an outer value for the outermost element of the instance (.) -- essentially, that is, it attempts to replace the instance entirely. The other buttons work as I expected, but this one doesn't seem to have the desired effect (and after I click it, the others stop working). My idea is that setnode ref="instance('x')" outer="..."/> should have essentially the same effect as <xf:submit target="bounce-xml-string-back-as-xml" replace="instance" instance="x" ref="y"/> when y is an XPath expression pointing to a node set whose serialization is the same string as given in the 'outer' attribute. If that's not possible from an implementation point of view, I can live with it. But I predict I won't be the last user who hopes it will work that way :) In any case, thank you again, this is great. -- **************************************************************** * C. M. Sperberg-McQueen, Black Mesa Technologies LLC * http://www.blackmesatech.com * http://cmsmcq.com/mib * http://balisage.net **************************************************************** |