XSLT vs CSS/HTML/jQuery

 

It is a very confusing yet thoughtful decision picking up a technology to create web pages when you have the data in XML files. Hence, comparison of XSLT vs CSS/HTML/jQuery is important to study.

The full form of XSLT is eXtensible Stylesheet Language Transformations.
A file with extension XSL is used for converting the data from XML format to the human readable format and CSS can be embed into this template to enhance the GUI.

The use of XSL template seems to be a burden while displaying the data on the HTML page. When a person thinks of it for the first time, few questions arise in the mind.

  1. Why can’t one just use CSS for design, Javascript for fetching the data (it could be in JSON or XML) & making the GUI interactive and HTML for designing pages?
  2. Why add an additional component that is XSL when CSS, Javascript and HTML fulfil all the needs?
  3. Then, is there any advantage of using XSL?

Let’s see what the benefits of XSL language are and why it is used:
XSL helps in extracting data from complex XML (data file) file and converting into HTML format. XSL bridge the gap between complex XML-based documents and the CSS formatting model.

In simple terms, XSL is a language used to transform XML from one format to another. It takes the XML as input. Using some XSL tags, CSS and HTML gives XHTML as output.

The beauty of XSL is that you just need to include the reference of XML document and it will handle the transformation automatically at the browser/client side or this transformation can also be handled at the server side by using XALAN or Saxon engine.

Let’s clear the confusion first:
XSL – It’s a template that contains the formatting in the form of HTML/CSS and link to the XML file from where that data has been fetched.
XSL template can contain CSS and Javascript, but this is not necessary. The basic work of XSL template is to read data from XML file and give a structure to it.

Which means XSL is very different from CSS. On the other hand, CSS is used to give a stylish GUI to the data read using XSL.

Now, the question comes to the mind can we not just use javascript to render the XML file and make the GUI readable using HTML and CSS?

Right, the comparison is not really between CSS and XSL, but it’s between XSL and Javascript.
CSS and HTML will remain in place in either case (XSL + HTML/CSS and Javascript + HTML/CSS) to make the data presentable.

Also, CSS has now become a powerful language to define the structure of the web page so, it’s just a matter of reading the data and for that we have two options XSL or Javascript.
Both, XSL and Javascript are useful, let’s explore more to make a decision which combination to use:

In this case, it’s really up to the developer or architect developing what to choose for designing their application because both the technology has its own advantages.

  1. XSL is old and not easy to read because of which it is less known whereas Javascript is more popular because it is easier to read and implement.
  2. XSLT is a good solution for templating. The language and syntax are a bit unusual — “choose/when” instead of “case/switch” is a glaring example — but it does its job well.
  3. XSL is a template that can be processed at client side or at server side; it’s a matter of choice. If the processing happens on the client side the XML file gets transferred to the client side, which is not good. If the processing happens on the server side, then it will consume server resources. Whereas Javascript has a balance in that sense, it fetches all the data in a variable then transfers it to the client side where it can be processed, if needed.
  4. I feel Javascript will be lightweight as compared to XSLT report, but not tested.

I feel that using XSLT is not a good idea even if I have XML data that needs to be processed.

But most of the apache testing tools like Selenium and JMeter use XSLT reporting which brings in the confusion.

Is there really an advantage of using XSLT reports over plain Javascript, CSS and HTML?

Please share your thoughts in comments section.

How to run TDL

How to run TDL?
There are several ways to run a program written using notepad or Tally.Developer:

1. Using Tally.Developer
2. Using Tally.ERP configuration
3. Editing Tally.ini file

 

Using Tally.Developer

1. Right click on the file that needs to be executed choose “Execute Tally”. An error may occur if Tally.ERP executable path is not set and gives “Execution Failed: Tally.ERP9 Executable path is not specified. Please specify in preferences.” error
2. To remove open Preferences

Tally Preferences

3. Goto Compiler /Execution Options and set the path of tally.exe

Tally.ERP exe path

4. Now run the file again and it will open up the Tally ERP
 

Using Tally.ERP configuration

1. Run Tally ERP, you will see the following screen

Gateway of Tally

2. Now press F12 to enable configuration, you will see TDL configuration option
Tally Configuration

 

3. Click on TDL configuration, you will see the below screen
TDL Configuration1

4. now either press F4 or click on Local TDLs
TDL Configuration setup

5. Give the path and filename with extension, like, C:\abc.txt and press enter. The following screen will appear.

TDL Configuration setup1

6. Press “y”, it will save the changes

TDL active

 

Editing Tally.ini file

1. Find Tally.ini file in Tally.ERP
2. Open Tally.ini file in notepad
3. Add the file path and name under line User TDL=Yes, TDL=<Path>\<File_Name>

Maintain Session using URL Rewriting

In this method, we rewrite the URL and append the information to the URL to keep the track of the values. URL Rewriting can be used to maintain the session. We can maintain session using URL rewriting.

There are several methods to maintain session between client and server, see all types of method here

Lets see an example

—index.jsp—

How to maintain Session?

 


3.
URL rewriting

Once you click on the URL rewriting link URLRwriting.java class will append p3lang in the URL. See below code of URLRewriting.java

–rewrite.jsp–
This rewrite.jsp page is the response page. This page will display the value that we have sent in the URL.

OUTPUT:

Index page
URL Rewriting
Rewritten URL
URL Rewriting 1

Maintain Session using User Authorization

We can maintain session using User Authorization, the most common method.
Maintain Session using User Authorization is the second method in the series of http://p3lang.com/2014/06/playing-with-session-in-java/ post.

User Authorization is the most common way to maintain session between client and server.
A user has to sign-in into the application using their credentials. Once the user submits the form by filling the correct credentials a session gets created on the server that will be used during the entire user session.

Use these credentials to make this form work:
Email: session@session.com
Password: session

 
—index.jsp—
This page contains the login form.

 
—welcome.jsp—
If the user successfully logged in then, this welcome page will get displayed. This welcome page will display the hello message and email id of the user.

 
—error.jsp—

 
—Login.java—

 
—Logout.java—

 
OUTPUT:

User_Authorization_Login_page

In the above screenshot, you can see the login form. We haven’t logged in yet, the session present is the session that is by default assign by the Apache tomcat server to the browser.

Now let’s login with the credentials.

User_Authorization_Login_page_2

 
Using this method, We have set session in apache tomcat server not in cookies,

 
Below is the code snippet to display the session value on the webpage

Maintain Session using Cookies in jsp servlet

Session can be maintained using browser cookies.
Here in this post, we will see how to Maintain Session using Cookies in JSP servlet.

It is very simple to maintain session using cookies, you just need to create an object of Cookie Class then call addCookie() method on response.

Code Snippet:

 
See full example below:

—index.jsp—

 

—Cookie.java—

 
—cookie.jsp—

 

Explanation:
Once you run the code, you will see a cookie has been created with name “JSESSIONID”. This JSESSIONID is assigned by the apache tomcat server to the client or browser.
Expiration of this JSESSIONID can be configured in web.xml file.
 
cookies1

 
A cookie will be set, when you click on the ‘Cookies’ link. You can give any name to the link, Apple, for example.
This cookie is created using the code above.

 
cookie2