[Javascript] Client-side Word document creation via XML/XSLT

Rees, Mark Mark.Rees at astrazeneca.com
Mon Mar 22 04:54:48 CDT 2010


That's an interesting question. I don't know of any way to generate a Response in a browser which can then be presented to the browser for interpretation. As you say, that's effectively what you need. One very inefficient and clumsy way to do this, if you had access to the server, would be to send the generated word document to the server and have it echo it back in a properly prepared response. However if you are going that far you would be a lot better off generating the Word document on the server in the first place, which I assume isn't an option. 

I presume you're not working in a closed environment here, but if you were then you could perhaps (having arranged the necessary permissions) write the file to a local disk on the client, then open it from there using JavaScript. It's unlikely you will be granted that level of control though, certainly not if this is an internet application.

Good luck

Mark


--------------------------------------------------------------------------
AstraZeneca UK Limited is a company incorporated in England and Wales with registered number: 03674842 and a registered office at 15 Stanhope Gate, London W1K 1LN.
Confidentiality Notice: This message is private and may contain confidential, proprietary and legally privileged information. If you have received this message in error, please notify us and remove it from your system and note that you must not copy, distribute or take any action in reliance on it. Any unauthorised use or disclosure of the contents of this message is not permitted and may be unlawful.
Disclaimer: Email messages may be subject to delays, interception, non-delivery and unauthorised alterations. Therefore, information expressed in this message is not given or endorsed by AstraZeneca UK Limited unless otherwise notified by an authorised representative independent of this message. No contractual relationship is created by this message by any person unless specifically indicated by agreement in writing other than email.
Monitoring: AstraZeneca UK Limited may monitor email traffic data and content for the purposes of the prevention and detection of crime, ensuring the security of our computer systems and checking Compliance with our Code of Conduct and Policies.
-----Original Message-----
From: javascript-bounces at lists.evolt.org
[mailto:javascript-bounces at lists.evolt.org]On Behalf Of Dave Shaw
Sent: 22 March 2010 00:05
To: javascript at lists.evolt.org
Subject: [Javascript] Client-side Word document creation via XML/XSLT


This is going to be a bit long. Please bear with me.

I have a package called the Data Integration Toolkit (DIT) by CorasWorks
in one of my SharePoint environments. I can use this to fetch data in
XML format from nearly anywhere, including native SharePoint content,
then apply XSLT transforms against it for display on SharePoint web part
pages. I've gotten some very nice custom displays from this. I've
managed to also use the DIT to apply an XSLT template with WordML markup
to get SharePoint list content in a nicely-formatted Word document in
Word 2003 XML format.

I support another SharePoint environment that does not have the DIT
available. I'd like to accomplish some of these same things in that
environment. I figure I should be able to do all this client side. I've
managed to get the SharePoint list content in XML format (owssvr.dll is
your friend), and I've written a little Ajax code to fetch the data and
template, do the transform, and stuff the results into the innerHTML
property of a <div> for the onscreen displays. Works great; gives the
same results as my DIT tools.

As to creating a Word document... Using the same data and WordML
transform as I have on the DIT-enabled server, I've managed to do a
transform and I have what I believe to be the resulting XML/WordML in a
variable. It's about the right length, anyway (700K bytes). The problem
is that I can't for the life of me figure out how to get it from
Javascript into Word.

If I put this exact data in a file (document produced by doing the
transform offline) sitting on the server, and I open that in IE, IE
offers me an open-or-save dialog and I'm good; Word opens a
properly-formed and perfectly-formatted document. The URL is of the form
http://server.address/library/test.xml. Simple stuff.

Ideally, I'd like to simulate this on the client - provide appropriate
headers and the contents of the javascript variable to IE to open as if
it were streaming from a web server. I've tried playing with the window
object but I'm getting nowhere; IE just tries to write the output as raw
text to the browser window. Not useful. I've played with ActiveXObjects
but to no avail; I keep getting prompts to run the ActiveX control, and
then Word won't open. Even if it did, I find nothing in the Word object
model that leads me to believe that I can provide my Javascript/WordML
as if it were coming in through File->Open. Also, I'm not a fan of this
approach for portability reasons, but if I could make it work, I'd be a
good couple of steps ahead of where I am.

Google is leading me in circles. I keep finding the same
not-so-very-helpful web pages.

In a nutshell, I'd like to present HTTP headers and the transform
results (XML/WordML) created in the client browser to the same client
browser in such a way as it acts as though I'd opened it from a web
server.

Can anyone give me a nudge in a useful direction?

Thanks,

Dave Shaw

_______________________________________________
Javascript mailing list
Javascript at lists.evolt.org
http://lists.evolt.org/mailman/listinfo/javascript


More information about the Javascript mailing list