Compress & Decompress with IONIC

Assalamualaykum Wr Br…Today we explore Ionic files. That’s the mainstream library, the full library, and it includes all the capability. If you have particular requirements, like you want a smaller library, or you want to exclude the Self-Extracting stuff, or you only want the ZLIB capability, then you may want to choose a
different assembly.Here’s a summary of the options.

Usage scenario Reference this DLL
Reading or writing Zip files Ionic.Zip.dll

Raw block or stream compression, ZLIB, GZIP, or DEFLATE Ionic.Zlib.dll

Raw block or stream compression, BZIP2 Ionic.BZip2.dll

Both raw compression as well as reading or writing Zip files Ionic.Zip.dll

Reading or writing Zip files on Compact Framework Ionic.Zip.CF.dll

Raw compression on Compact Framework Ionic.Zlib.CF.dll/Ionic.BZip2.CF.dll

Both raw compression as well as reading or writing Zip files on CF Ionic.Zip.CF.dll

Reading or writing Zip files, using desktop .NET framework but Ionic.Zip.Reduced.dll
never creating a self-extracting archive

Never reference both Ionic.Zlib.dll and Ionic.Zip.dll, or both Ionic.BZip2.dll and Ionic.Zip.dll in the same application. If your application does both Zlib and Zip stuff, you need only add a reference to Ionic.Zip.dll. It includes all the capability in Ionic.Zlib.dll and Ionic.BZip2.dll You always need to reference only a single Ionic DLL, regardless whether you use Zlib or BZip2 or Zip or some combination.

The classes in the ZIP library reside in these namespaces:

Namespace Interesting classes
Ionic.Zip ZipFile, ZipEntry, ZipOutputStream, and

Ionic.Zlib DeflateStream, GZipStream, ZlibStream

Ionic.BZip2 BZip2InputStream, BZip2OutputStream

Ionic.Crc CRC32

If you want only ZLIB (raw compression and decompression, RFC 1950, 1951, and 1952), the ZLIB classes are packaged independently, in Ionic.Zlib.dll. Likewise, if you want to do BZIP2 compression, outside the scope of a zip file, you can use the Ionic.BZip2.dll assembly.

If you want ZIP, or both ZIP and ZLIB, then your application should depend soly on Ionic.Zip.dll; this assembly includes a superset of the classes in Ionic.Zlib.dll and Ionic.BZip2.dll.


Xplore XSLT with Visual Studio…

Assalamualaykum Wr Br…Today we explore XSLT which stands for XSL stands for eXtensible Stylesheet Language. It is a language used to design and apply style sheets especially for XML documents. Originally the research started to provide style sheet technology to XML using XSL, but finally ended up with three more divisions of XSL. So, XSL now consists of three parts namely XSLT, XPath and XSL-FO.

XSLT is a language for transforming XML documents (even today, several programmers call XSLT as XSL).

XPath is a language to filter, search or sort information available in XML documents.

XSL-FO is a language for formatting XML documents.

In this article we mainly focus on XSLT, which stands for XSL Transformations. Lets begin with simple xml file with its associated xslt as shown below:

Please notice that at line 2 in above image we have HREF=”SAMPLE1.XSLT” which illustrates the browser to parse the xml document as per the standards mentioned in xslt file which is shown below:
When I try to open the simple.xml file in browser then it is displayed as:

Let us explore the xml document first few lines which delivers the mapping with xslt as shown:

<xml:stylesheet type=”text/xsl” href=”sample1.xslt”?>

This is the only magic needed in any XML file to be transformed to any XSLT. The above statement instructs browser to link the current XML document with “sample1.xslt” and present (transform) it accordingly. So, in general we will not see the XML document as a tree structure anymore. It will be presented (transformed) in a different way as specified in “sample1.xslt”.
Now, let us study the most important lines in sample1.xslt.

<xsl: stylesheet version=”1.0″ xmlns:xslt=””&gt;

The above line defines that it is basically an XSLT document used for certain transformation.

<xsl:template match=”/”/>

The above line specifies the format (template) applicable to the root of XML document. We can also specify individual templates for each and every XML element as well. The attribute ‘match’ can be provided with any XPath expression.

<xslt: value-of select=”Employees/Employee/Name”/>

And finally, the above line states that it has to get the value (text) present in that path (Employees/Employee/Name) of XML document (tree) starting from root. In this case it starts from root (/), then searches for Employees element (first element), within that Employee child element (first child element) and finally the child element Name (first child element) of Employee element. This path could be replaced with any XPath expression.

Now very interesting part begins now…
Create a new project and add simple.xml and simple1.xslt files to your solution as shown below:
its xslt file in visual studio is shown as:
Now hard code little code in page load as shown below:
Now Execute the code and output is as similar to shown above…hope enjoyed this post…
Jazakallah Khair…