পৃষ্ঠাসমূহ

.

Search Your Article

Total Pageviews

Wednesday, January 25, 2017

Apache Xerces - Quick Guide

What is XML?

XML is a simple text based language which was designed to store and transport data in plain text format. It stands for Extensible Markup Language. Following are some of the salient features of XML.

  • XML is a markup language.
  • XML is a tag based language like HTML.
  • XML tags are not predefined like HTML.
  • You can define your own tags which is why it is called extensible language.
  • XML tags are designed to be self descriptive.
  • XML is W3C Recommendation for data storage and transport.

Example

<?xml version="1.0"?>
<Class>
   <Name>First</Name>
   <Sections>
      <Section>
         <Name>A</Name>
         <Students>
            <Student>Rohan</Student>
            <Student>Mohan</Student>
            <Student>Sohan</Student>
            <Student>Lalit</Student>
            <Student>Vinay</Student>
         </Students>
      </Section>
      <Section>
         <Name>B</Name>
         <Students>
            <Student>Robert</Student>
            <Student>Julie</Student>
            <Student>Kalie</Student>
            <Student>Michael</Student>    
         </Students>
      </Section>
   </Sections>
</Class>

Advantages

Following are the advantages that XML provides:
  • Technology agnostic - Being plain text, XML is technology independent. It can be used by any technology for data storage and transmission purpose.
  • Human readable- XML uses simple text format. It is human readable and understandable.
  • Extensible - in XML, custom tags can be created and used very easily.
  • Allow Validation - Using XSD, DTD and XML structure can be validated easily.

Disadvantages

Following are the disadvantages of XML usage:
  • Redundant Syntax - Normally XML file contains lot of repeatitive terms.
  • Verbose-Being a verbose language, XML file size increases the transmission and storage costs.

Apache Xerces - Environment Setup

This chapter takes you through the process of setting up Apache Xerces on Windows and Linux based systems. Apache Xerces can be easily installed and integrated with your current Java environment following a few simple steps without any complex setup procedures. User administration is required while installation.

System Requirements

JDKJava SE 2 JDK 1.5 or above
Memory1 GB RAM (recommended)
Disk SpaceNo minimum requirement
Operating System VersionWindows XP or above, Linux
Let us now proceed with the steps to install Apache Xerces.

Step 1: Verify your Java Installation

First of all, you need to have Java Software Development Kit (SDK) installed on your system. To verify this, execute any of the two commands depending on the platform you are working on.
If the Java installation has been done properly, then it will display the current version and specification of your Java installation. A sample output is given in the following table.
PlatformCommandSample Output
WindowsOpen Command Console and type:java -version Java version "1.7.0_60" Java (TM) SE Run Time Environment (build 1.7.0_60-b19) Java Hotspot (TM) 64-bit Server VM (build 24.60-b09,mixed mode)
LinuxOpen command terminal and type: $java -version java version "1.7.0_25" Open JDK Runtime Environment (rhel-2.3.10.4.el6_4-x86_64) Open JDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Step 2: Set your Java Environment

Set the environment variable JAVA_HOME to point to the base directory location where Java is installed on your machine. For example,
PlatformDescription
WindowsSet JAVA_HOME to C:\ProgramFiles\java\jdk1.7.0_60
LinuxExport JAVA_HOME=/usr/local/java-current
Append the full path of Java compiler location to the System Path.
PlatformDescription
WindowsLinux
Append the String "C:\Program Files\Java\jdk1.7.0_60\bin" to the end of the system variable PATH.Export PATH=$PATH:$JAVA_HOME/bin/
Execute the command java -version from the command prompt as explained above.

Step 3: Install Apache Xerces Library

Download the latest version of Apache Xerces from http://xcerces.apache.org/download.html and unzip its contents to a folder from where the required libraries can be linked to your Java program. Let us assume the files are collected in a folder xerces-2_11_0 on C drive.
Add the complete path of the five jars as highlighted in the above image to the CLASSPATH.
PlatformDescription
Windows Append the following strings to the end of the user variable
CLASSPATH:
C:\xerces-2_11_0\resolver.jar;
C:\xerces-2_11_0\serializer.jar;
C:\xerces-2_11_0\xercesImpl.jar;
C:\xerces-2_11_0\xercesSamples.jar;
C:\xerces-2_11_0\xml-apis.jar;
Linux Export CLASSPATH=$CLASSPATH:
/usr/share/xerces-2_11_0\resolver.jar:
/usr/share/xerces-2_11_0\serializer.jar:
/usr/share/xerces-2_11_0\xercesImpl.jar:
/usr/share/xerces-2_11_0\xercesSamples.jar:
/usr/share/xerces-2_11_0\xml-apis.jar:

No comments:

Post a Comment