Re: [Xsltforms-support] file uploads
Brought to you by:
alain-couthures
From: Tim T. <tim...@gm...> - 2017-02-10 17:30:33
|
Conal, I was also going to suggest using the transform() function with an identity template. Here's a working example that uses it with your fork of XSLTForms: http://timathom.github.io/xforms/upload.xhtml The service seems to require the filename in the Content-Disposition, so I just hard-coded in a temporary name (line 2001 of xsltforms.js). XSLTForms nicely provides access to the "response-body" object for the "xforms-submit-done" event (even though the spec only includes it for the xforms-submit-error event), so it's easy to insert that (assuming it's XML) into an XForms instance. I second Michael's suggestion of documenting your work in the Wikibook :) I've referred several times myself to the page he created to document the transform() function. -- Tim A. Thompson Metadata Librarian (Spanish/Portuguese Specialty) Princeton University Library www.linkedin.com/in/timathompson ta...@pr... On Fri, Feb 10, 2017 at 9:46 AM, C. M. Sperberg-McQueen < cm...@bl...> wrote: > > > On Feb 10, 2017, at 3:01 AM, Conal Tuohy <con...@gm...> wrote: > > ... > > > > So It seems to me, in order to send my XML as a form parameter, I need > to serialize the XML first, and then submit the serialization. I was hoping > that XForms would provide a custom "serialize()" function that would escape > my XML as text, or that there'd be some other obvious way to fix this, but > I haven't found anything. > > What version of XSLTForms are you using? > > The current draft of XForms 2.0 does define a serialize() function, and > the snapshot of XSLTForms I downloaded last month from SourceForge > does have an implementation of it. (Hmm. For that matter, so does > 1.0RC2 — at least, the array XsltForms_xpathCoreFunctions defined > in xsltforms.js has an entry for serialize.) > > The transform() function also produces a string (with the serialized form > of the XML in question), so the expression transform(instance(‘thisone’), > ’identity.xsl’,false) > should produce the string you want. > > > > > The only solution I can see is to use a recursive <xf:action> to walk my > XML instance's tree, gradually serializing it into a text node in another > instance, and then submit THAT instance. This seems awkward, but I'm sure > it's possible, and I'll do it if no-one can suggest anything better! > > Ooof! Well, that would work, I guess. But try serialize() and > transform() first. > You may need to serialize into another instance using xf:setvalue, just > because > XForms isn’t always ready to accept values instead of references to values. > > And on another note — if you have just spent time figuring out how > xf:upload > works out of the box in XSLTForms, and how to modify XSLTForms to make it > do what you actually needed, could you be persuaded to add a page to the > XSLTForms wikibook describing what you learned? > > If every time a serious user of XSLTForms had trouble making something > work, we made it a practice to write up what we learned and put it into the > XSLTForms wikibook, to help the next user, the wikibook would soon be > much more useful than it has been. (Even in a purely self-interested way, > this can pay off. Every time I come back to using transform() after a long > period of not thinking about it, I find myself trying to remember how it > works, > and so the time I spent writing a page on it in the wikibook a couple of > years ago has now been paid back two or three times.) > > ******************************************** > C. M. Sperberg-McQueen > Black Mesa Technologies LLC > cm...@bl... > http://www.blackmesatech.com > ******************************************** > > |