How to and strange problem
I discovered a trick to upload files with XSLTForms
In case of submission method "xml-urlencoded-post" XSLTForms dynamically build a form whose ID is "xsltforms_form"
If this form still exists, XSLTForms replaces the value of the first child of the form by the serialization of the submitted instance content
Example
Model
<xf:model>
<xf:instance>
<ps:data>
<ps:input> Hi everybody! </ ps: input>
</ ps: data>
</ xf: instance>
<xf:submission id="sub" method="xml-urlencoded-post" replace="all" action="load.xql">
<xf:message level="modeless" ev:event="xforms-submit-error"> Submit error. </ xf: message>
</ xf: submission>
</ xf: model>
Form
<form name="upload" id="xsltforms_form" action="load.xql" enctype="multipart/form-data" method="post">
<input type="hidden" name="postdata"/>
<input type="file" name="file1" style="width: 360px" />
<br />
<input type="file" name="file2" style="width: 360px" />
<br />
<input name="a1" />
</ form>
Submission
<xf:submit submission="sub">
<xf:label class="label"> Send </ xf: label>
</ xf: submit>
This works very well, so one can say that XSLTForms supports file upload
My problem with XQuery / eXist is generating XSLTForms by XQuery
XQuery does not allow
return
<?xml version = "1.0" encoding = "iso-8859-1"?>
<?xml-stylesheet href = "some.xsl" type = "text / xsl"?>
We must, as it is documented, use a redirect pipe (controller.xml)
The problem is that the result of the transformation is strange characters are added at the beginning of IDs and inserted in some classes.
These chars are #xA and other #x160
My controller source is the following (just a copy/paste from documentation)
xquery version "1.0";
import module namespace request = "http://exist-db.org/xquery/request";
import module namespace xdb = "http://exist-db.org/xquery/xmldb";
let $ foo: = 0
return
if (ends-with ($ exist: resource "-xf.xql") or ($ exist: resource eq "xforms.xql"))
then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<view>
<forward servlet="XSLTServlet">
<set-attribute name="xslt.stylesheet" value="xsltforms/xsltforms.xsl"/>
<set-attribute name="xslt.output.omit-xml-declaration" value="yes"/>
<set-attribute name="xslt.output.indent" value="no"/>
<set-attribute name="xslt.output.media-type" value="text/html"/>
<set-attribute name="xslt.output.method" value="xhtml"/>
<set-attribute name="xslt.baseuri" value="xsltforms/"/>
</ forward>
</ view>
<cache-control cache="yes"/>
</ dispatch>
else
<ignore xmlns="http://exist.sourceforge.net/NS/exist">
<cache-control cache="yes"/>
</ ignore>
I suspect that extra insertions of #x0A are due to bad interpretation of new lines patterns.
I believe that in the future controller mechanisms will be replaced by XProc
About #x0A
Remember that Microsoft, Unix, Apple have their own implementation of new line
By the way the best choice was made by Microsoft , as like for old type writers a new line must starts after a [Carriage Return] and a [Line Feed]
I am pleased to say that eXist works well under Windows Web Server 2008
Re: XSLTForms/XQuery with eXist - How to upload files - ...
I suspect the (one of them ?) origin of my problem with strange XSL transformation.
It comes from the Bytes Order Mark (BOM)
Updated Post (Feb 22)
Some of my source files had BOM.
I use Visual Studio 2008 from MS that write xml and text files with BOMs.
One must in this case use notepad and resave the file in ANSI format.
Re: XSLTForms/XQuery with eXist - How to upload files - ...
Dominique,
Adding the XSLTForms header is actually fairly easy in eXist:
let $doc := <html xmlns:xf="http://www.w3.org/2002/xforms">...your xforms doc here ...</html>
let $xsltheader := processing-instruction xsl-stylesheet {'href="url-to-stylesheet" type="text/xsl"'}
return ($xsltheader,$doc)
This will send the xslt header in as a PI prior to the document, giving you full support for XSLTForms.
Re: XSLTForms/XQuery with eXist - How to upload files - ...
I have an XML file (XForms), whose outputs returned from http (get) through IIS and Jetty are different. Rendering by Jetty led to an XSL transformation that generates extra characters (#A, #160) in the page code
Re: XSLTForms/XQuery with eXist - How to upload files - ...
The extra characters are possibly due to text-encoding problems. In your output you can control the encodings in a transformation by using the encoding attribute:
<xsl:output method="xml" encoding="UTF-8"/>
Don't know if that helps, but it may be a start.
Re: XSLTForms/XQuery with eXist - How to upload files - ...
Did you have a look at http://en.wikibooks.org/wiki/XRX/XSLTForms_and_eXist ?
-Alain
Re: XSLTForms/XQuery with eXist - How to upload files - ...
I both tried Server/Side and Client/Side XSLT processing.
Yes I read the docs at http://en.wikibooks.org/wiki/XRX/XSLTForms_and_eXist
Did you installed eXist on your PC or Server ?