Posts

Showing posts with the label XML/XSL

HOW TO display ANY "flat XML" file as a HTML table using generic XSL stylesheet

Image
In response to a forum posting, I adapted the XSL code in the article "Convert XML To an Excel Spreadsheet Using XSL" to display ANY "flat XML" file (like the one used in the examples in W3Schools) as a HTML table with this generic XSL stylesheet - <?xml version= "1.0" encoding= "ISO-8859-1" ?> <xsl:stylesheet version= "1.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" > <xsl:template match= "/" > <HTML> <BODY> <xsl:apply-templates/> </BODY> </HTML> </xsl:template> <xsl:template match= "/*" > <TABLE BORDER= "1" > <TR> <xsl: for -each select= "*[position() = 1]/*" > <TD> <xsl:value-of select= "local-name()" / > </TD> </xsl: for -each> </TR> <xsl:apply-templates/> </TABLE> </xsl:template> <xsl:te...

HOW TO implement "Download as Word/Excel" functionality through a web page

I "discovered" Office XML two summers ago when I had to implement "Download as Word Document" functionality for a report with customized features, through a web page without using any third party utility. In Office 2000 (& above) documents can be converted from Word to HTML (File->Save As) and vice versa! It is interesting to see how an Office Document renders HTML. The various formatting features in the Office document are defined through XML as explained in the Microsoft Office HTML and XML Reference . By manipulating these properties exposed through XML programmatically, we can incorporate custom formatting capability in the Office docs that we offer for downloading. All this without resorting to Office Automation or expensive tools. I recently stumbled upon a stellar example that utilizes this technique from among a bunch of re-usable utility methods that Daniel Olson has kindly shared. The method "DataTable2ExcelString" takes a DataTable...

Atlas & AJAX

The type of rich development that Atlas enables is broadly referred to as AJAX (Asynchronous JavaScript and XML), which is a relatively new acronym for a combination of technologies that have been around for quite some time. The Atlas features of ASP.NET are not just another AJAX script library for writing client-centric Web applications. Atlas builds on the .NET Framework 2.0 and adds support for better utilizing the capabilities of client-side JavaScript and the XMLHttpRequest object. The client script library simplifies the task of writing JavaScript and provides constructs for using an object-oriented approach to writing JavaScript. It includes server-based features that make it easy to enrich existing ASP.NET applications, as well as a client script library that is used by the Atlas controls and services. Scenarios enabled by Atlas are not limited to updating regions of the page with an asynchronous JavaScript call. You also get richer client experiences that would otherwise be i...

When and Why to Use XML

According to the XML Litmus Test , XML is the appropriate tool for the job if the following criteria are satisfied by choosing XML as the data representation format for a given application: There is a need to interoperate across multiple software platforms. One or more of the off-the-shelf tools for dealing with XML can be leveraged when producing or consuming the data. Parsing performance is not critical. The content is not primarily binary content, such as a music or image file. The content does not contain control characters that aren't carriage return, line feed, or tab because they are illegal in XML.