How to get the contents of an attachment (e.g. xml file)?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get the contents of an attachment (e.g. xml file)?

Zeder127
Hello,

I'm using orbeon 4.4. I'd like to extend the usability of file attachment
control (attachment.xbl). If I upload a xml file, I also want to have an
output field under the "download" symbol to show the contents of this xml
file. How could I make it work?

Thanks,
zeder127

--
View this message in context: http://discuss.orbeon.com/How-to-get-the-contents-of-an-attachment-e-g-xml-file-tp4657812.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: How to get the contents of an attachment (e.g. xml file)?

Alessandro  Vernet
Administrator
Hi zeder127,

I'm not sure you can quite do all of this just with XForms, as you'd need a function to check that the uploaded file is valid XML. The function doc() will read and parse the file, but will bomb if not valid. Also, displaying the XML in a "nice" way isn't trivial, and to do it properly you'd most likely want to use a JavaScript library doing some indenting and formatting.

I think I'd use xxf:doc-base64-available() to check if the file exists, if it does read it with xxf:doc-base64() and place its content in a HTML element, and do the rest (base64 to text aka XML parsing, and indenting/formatting in JavaScript).

http://wiki.orbeon.com/forms/doc/developer-guide/xforms-xpath-functions#TOC-xxf:doc-base64-

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: How to get the contents of an attachment (e.g. xml file)?

Zeder127
Hi Alex, thanks for your reply. I will try it.