473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

exporting DOM Transform output

Hi!
I'm trying to add an export option to my application. I use Javascript
DOM to transform XHTML-tables displayed in the browser window to
CSV-format (client-side) using a simple XSL. All works fine, except
that I can't seem to get any further than alerting the output
*sigh*... Who can give me hints on how to get the output to the client
somehow? Should I save it to the server first and then allow the
client to get it from there, or can I pass it directly back to the
client who pressed the export button and requested it? I tried writing
the output to a document and then do execCommand to let the client
save it but
1) I don't want the output in a new window, I just want the 'save as'
dialog to appear directly. But the execcommand method needs an object
e.g. the document and I don't know how to circumvent this...
2) the 'save as' dialog only allows me to save the output as *txt or
*html and does not have ANSI coding as an option. As a result, when I
save the file as html using the default coding (Unicode) and open it
in Excel all data are displayed in one column. I need ANSI. (When I
open the csv in Notepad and save it with ANSI coding it is displayed
correctly in Excel).
Who can give me a hint on what to do next? I'm desperately waiting for
your replies, TIA!

This is the DOM function:

function buttonExportClick()
{
var xslt = new ActiveXObject('Msxml2.XSLTemplate.3.0');
var s = new ActiveXObject('msxml2.FreeThreadedDOMDocument.3.0' );
s.async=false;
s.load("/lib/xtable/convert.xsl");
var xslProc;
xslt.stylesheet = s;
var xmlDoc = document.XMLDocument;
if (xmlDoc==null)
{xmlDoc=navigator.XMLDocument};
xslProc = xslt.createProcessor();
xslProc.input = xmlDoc;
xslProc.transform();
var output = xslProc.output;
alert(output);
}
Jul 23 '05 #1
6 3022


Sharon wrote:

I'm trying to add an export option to my application. I use Javascript
DOM to transform XHTML-tables displayed in the browser window to
CSV-format (client-side) using a simple XSL. All works fine, except
that I can't seem to get any further than alerting the output
*sigh*... Who can give me hints on how to get the output to the client
somehow? Should I save it to the server first and then allow the
client to get it from there, or can I pass it directly back to the
client who pressed the export button and requested it? I tried writing
the output to a document and then do execCommand to let the client
save it but
1) I don't want the output in a new window, I just want the 'save as'
dialog to appear directly. But the execcommand method needs an object
e.g. the document and I don't know how to circumvent this...
2) the 'save as' dialog only allows me to save the output as *txt or
*html and does not have ANSI coding as an option. As a result, when I
save the file as html using the default coding (Unicode) and open it
in Excel all data are displayed in one column. I need ANSI. (When I
open the csv in Notepad and save it with ANSI coding it is displayed
correctly in Excel).
Who can give me a hint on what to do next? I'm desperately waiting for
your replies, TIA!


What you have is IE/Win or even IE 6/Win only as you are using MSXML 3.
If you know that you only have such clients then maybe you can write an
HTA( HTML application) where you then have access to object like
ADODB.Stream or the FileSystemObject to save the result directly on the
client.
If not then it seems better to use the server to to the transformation
and save it back to the client.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Yes, thanks, I have read about that. However the information I found was
not very clear and I don't exactly know how I should go about that.
Could you give me a hint or perhaps even show me an example on how to do
this HTA thing?
TIA, Sharon

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3


Sharon Steringa wrote:

However the information I found was
not very clear and I don't exactly know how I should go about that.
Could you give me a hint or perhaps even show me an example on how to do
this HTA thing?


It is rather easy, to start save your file as whatever.hta instead of
whatever.html.
Then you can check the documentation on MSDN:
http://msdn.microsoft.com/library/de...node_entry.asp

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #4
Thanks Martin, but what exactly should be saved as *.hta? I'm not saving
anything as *.html to begin with so I'm not really getting this... :S
Sharon

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #5


Sharon Steringa wrote:
Thanks Martin, but what exactly should be saved as *.hta? I'm not saving
anything as *.html to begin with so I'm not really getting this...


Your HTML documents are not saved as for instance page.html (or page.htm)?
These documents need to be saved as page.hta so they are treated as HTML
applications.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #6
Nope, they aren't. They are dynamically generated out of XML records
(also generated from a db) into neat pages with HTML tables, using XSL.
They are never saved. Now I have added an 'export' button so that users
can export whatever table they have displayed in their browsers at that
moment.
What I'm trying at the moment is to have the 'export' button open a
HTA-page. In the HTA page I have a BODY onload call the aforementioned
function that transforms to CSV:

function buttonExcelClick()
{
var xslt = new ActiveXObject('Msxml2.XSLTemplate.3.0');
var s = new ActiveXObject ('Msxml2.FreeThreadedDOMDocument.3.0');
s.async=false;
s.load("/lib/xtable/convert.xsl");
var xslProc;
xslt.stylesheet = s;
var xmlDoc = document.XMLDocument;
if (xmlDoc==null)
{xmlDoc=navigator.XMLDocument};
alert(xmlDoc);
xslProc = xslt.createProcessor();
xslProc.input = xmlDoc;
xslProc.transform();
var output = xslProc.output;
alert(output);
}

But of course, the var xmlDoc returns 'undefined', since the HTA
document contains no XMLDocument > I need the XMLDocument from the
browser window that is still open. How do I call/address this browser
window? Hope you can help me!Sharon

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Patrick Guio | last post by:
Dear all, I am trying to use the std::transform algorithm to to the following vector< vector<char> >::iterator ik = keys.begin(); // key list iterator vector< vector<char> >::iterator is = ik;...
3
by: edgekaos | last post by:
Is method 2 valid? Method 1: wstring input = L"STRING"; wstring output = input; transform(output.begin(), output.end(), output.begin(), towupper); Method 2: wstring input = L"STRING";...
6
by: Stephen Cook | last post by:
Having worked through the problems around enabling the document function using an XmlUrlResolver I started work on building a useful class to hide the intricacies. Trying to generalise the process...
4
by: schneider | last post by:
Anyone know if there is a way to dynamicly create a Xslt template/s and use them as an xml transform with-out use files for the Xslt? All the methods I see use files. I want to create a Xslt...
3
by: Andy | last post by:
Hi all, I'm having a problem doing an Xslt transform in code. I've done it before, so I'm not really sure why its not working. The problem is that the result of the transform is an empty...
3
by: vitaly.tomilov | last post by:
I'm using an ASP.NET form to display data from my database table, and I'm doing it in the following way: XmlDataDocument doc = new XmlDataDocument(mydataSet); XPathNavigator nav =...
6
by: Vijai Kalyan | last post by:
Hello, I am trying to use std::transform to take in a collection of strings, transform them and insert the result into an output container. So, I wrote something like this: std::wstring...
3
KevinADC
by: KevinADC | last post by:
If you are entirely unfamiliar with using Perl to sort data, read the "Sorting Data with Perl - Part One and Two" articles before reading this article. Beginning Perl coders may find this article...
1
by: sudhaMurugesan | last post by:
Hi all, I am using VS2003. I am new to VS2003. I cannot transform an xml file into a string output in my windows application. But the same function works well with VS2005. it also asks for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.