简体   繁体   中英

Loading data into static html form page or XML and using javascript

I have a text data (CSV) file that needs to be converted into a static HTML page for user viewing. In the HTML page, the user needs to be able to filter the data into views. Each HTML file will be archived.

I plan to use JavaScript for the user filtering functions. I plan to use a Perl script to convert the CSV file into an HTML file and include a form on the top of it for the user filter options. The HTML file will reference the JavaScript file.

My questions are:

  1. I'm considering converting the data into an XML instead. Is this better practice?
  2. If so, is it possible to have web forms in XML and run javascript functions?
  3. I have a CSS for the HTML file. Do I have to use XSLT for XML?
  4. Is there a way of combining XML and HTML into single file? Any benefit in this?

You can use XML as SOURCE instead of CSV, since XML defines cleaner handling of data (commas, semicolons, ' and " in the values).

If the content is static, and you will store it, then I suggest you use a format that is most close to the end result. That would be HTML+JS+CSS files. (JS and CSS help you keep some repetitive info out of the HTML).

Now a little background. XML is not viewable by default, you should use it with an XSLT file. What happens is that the browser "opens" the XML by transforming it with the XSLT into HTML. In this case you need the extra XSLT file, and a client capable of running it (most browsers are quite good at that nowadays). But you would only use this solution for three reasons. 1) If you have so many XML files (already at hand) that you do not want to process them with XSLT and save the resulting HTML instead of them, and leave this (wastly repetitive) computation burden to the clients. 2) You have other uses for the XML files. 3) The generated HTML is so much bigger than the source XML that it poses storage problems (although CSS and JS files should be enough to avoid that).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM