September 19, 2008

QUANTUM COMPUTING

During the past forty years astounding advances have been made in the manufacture of computers. The number of atoms needed to represent a bit in memory has been decreasing exponentially since 1950. Likewise the numbers of transistors per chip, clock speed, and energy dissipated per logical operation have all followed their own improving exponential trends. Despite these fantastic advances, the manner in which all computers function is essentially identical. This rate of improvement cannot be sustained much longer, at the current rate in the year 2020 one bit of information will requite only one atom to represent it. The problem is that at that level of miniaturization the behavior of the components of a computer will become dominated by the principles of quantum physics. (Williams, Clearwater)

With the size of components in classical computers shrinking to where the behavior of the components may soon be dominated more by quantum physics than classical physics researchers have begun investigating the potential of these quantum behaviors for computation. Surprisingly it seems that a computer whose components are able to function in a quantum are more powerful than any classical computer can be.

It is the physical limitations of the classical computer, and the possibilities for the quantum computer to perform certain useful tasks more rapidly than any classical computer that drive the study of quantum computing.

During the past forty years astounding advances have been made in the manufacture of computers. The number of atoms needed to represent a bit in memory has been decreasing exponentially since 1950. Likewise the numbers of transistors per chip, clock speed, and energy dissipated per logical operation have all followed their own improving exponential trends. Despite these fantastic advances, the manner in which all computers function is essentially identical. This rate of improvement cannot be sustained much longer, at the current rate in the year 2020 one bit of information will requite only one atom to represent it. The problem is that at that level of miniaturization the behavior of the components of a computer will become dominated by the principles of quantum physics. (Williams, Clearwater)

With the size of components in classical computers shrinking to where the behavior of the components may soon be dominated more by quantum physics than classical physics researchers have begun investigating the potential of these quantum behaviors for computation. Surprisingly it seems that a computer whose components are able to function in a quantum are more powerful than any classical computer can be.

It is the physical limitations of the classical computer, and the possibilities for the quantum computer to perform certain useful tasks more rapidly than any classical computer which drive the study of quantum computing.

1.1 AN ANALOGY

Ø Newtonian physics is an approximation to Einsteinian physics (general relativity).

Ø Classical physics is an approximation to quantum mechanics.

Ø Classical information is an approximation to quantum information.

Ø In each case, the approximation excludes important details but serves well for many purposes.

Ø In each case, removing the approximation requires deeper understanding and harder math, but results in a truer picture of Nature and may enable new technologies.

Ø Yes, Nature: we are beginning to understand that information is a physical concept.

1.1.1 APPROXIMATIONS THAT WE REMOVE

Ø Relativity: we remove (among others) the approximation that we are traveling much slower than light.

Ø Quantum mechanics: we remove (among others) the approximation that we are manipulating things much larger than atoms.

Ø Quantum computation: we remove (among others) the approximation that the elements of information are independently manipulable.

1.1.2 THE REASONS

Ø That approximation means that we can look at one bit in a register without affecting the other bits.

Ø Why remove that approximation? Because it limits the power of the computer.

Ø Also, getting ahead of uss, that approximation turns out to be troublesome in representing information quantum mechanically.

1.1.3 WE ARE RUNNING OUT OF PARTICLES

Ø The insulators in CMOS transistors can’t get much smaller or the insulating layers will stop insulating (at around 6 atoms thick). (Maybe before 2010.)

Ø In optical fiber, we use ten thousand or so photons to represent a bit. There’s a Moore’s law for fiber, too, and we’ll soon run out of photons. (Maybe before 2010.)

Ø Quantum mechanical effects will become important in just a few years!

Ø Currently, we work in the classical information regime. That won’t last. We’d better come to understand quantum information.

Ø Of course, this version of the story isn’t how quantum computation came to be. (Keep in mind the analogies.) So let’s back up and tell a more historical story, to introduce the ideas.

1.2 FEASIBILITY OF QUANTUM COMPUTING

Is it feasible for a computer to simulate a physical system perfectly? The answer appears to be, "No". A classical computer seems to need time exponential in n to predict precisely the behavior of a general quantum mechanical system of n particles. (Yet nature manages to do it in real time.) Briefly, a quantum mechanical system of n particles is represented by a wave function in a Hilbert space of dimension exponential in n. We really do need that much dimensionality to r

1.1 QUANTUM MECHANICS

1.1.1 SLIDE 1

The state of a QM system is described by its wave function, y, an oscillating complex valued

function defined over all of space. y can interfere with itself.

Quantum mechanics is linear. We can create y by linear combination, e.g.:

y=aupyup + adownydown

For well defined states, e.g. up, we use the notation ïup>, so

y=aup ïup> + adown ïdown>

The as are complex coefficients that must normalize; if the ï> states are orthogonal, the as must satisfy:

S ïai ï2 = 1

These are called probability amplitudes and ïai ï2 (note the square) is the probability that if we make a measurement of the system, we will find it in state ïi>.

1.1.2 SLIDE 2

The quantum measurement postulate in math:

If we make a measurement on a system with wave function

y= Si ai ïi>s

and find it’s in state i, the wave function is now

y=ïi>.

Math aside: the i are the eigen values corresponding to eigenvectors ïi> of the operator (e.g. energy) defining the measurement.

1.1.3 SEE FOR YOURSELF

Light can be linearly polarized: its vibrations can lie in a plane, say horizontally or vertically. Represent these two possibilities as אַ> and ﭯ>. We call these orthogonal states a basis of the system.

Plain light is a mixture of these polarizations and in fact a single photon can be a mixture. For example, light polarized at 45° is 1/_`2 (אַ> + ï­¯>).

Light can also be circularly polarized: circular polarization can be created from linear as follows:

ïrcp> = 1/_`2 (אַ> + iï­¯>)

ïlcp> = 1/_`2 (אַ> - iï­¯>)

This is another orthogonal basis of the polarization.

We can demonstrate that light obeys the quantum measurement postulate using three linear polarizing filters and an overhead projector....

1.1.4 WAVE FUNCTIONS

  1. Quantum mechanics is a linear theory: we can create linear superpositions of wave functions, provided we keep the probability amplitudes normalized.
  2. The quantum measurement postulate can be described as the wave function ‘collapsing’ to the basis state corresponding to the outcome of the experiment.
  3. We cannot discover the full quantum state of a system, only the squared probability amplitudes ïaï2. The a are the projections of the system onto the basis states and are complex valued.

THE QUANTUM COMPUTER


2.1 QUANTUM PHYSICS

When considering the possible power of a computer which makes use of the results of quantum physics, it is helpful to know a little of quantum physics itself. Quantum physics arose from the failure of classical physics to offer correct predictions on the behavior of photons and other elementary particles. Quantum physics has since been under intense scrutiny, as some of its predictions seem very strange indeed. Nevertheless experiments verify the same strange behavior which leads skeptics to challenge the veracity of Quantum physics.

2.2 THE CLASSICAL BIT

To understand the ways in which a quantum computer is different from a classical computer you must first understand the rudiments of the classical computer. The most fundamental building block of a classical computer is the bit. A bit is capable of storing one piece of information, it can have a value of either 0 or 1. Any amount of information can be encoded into a list of bits. In a classical computer a bit is typically stored in a silicone chip, or on a metal hard drive platter, or on a magnetic tape. About 10 10 atoms are currently used to represent one bit of information. The smallest conceivable storage for a bit involves a single elementary particle of some sort. For example, for any particle with a spin -1/2 of particle, which can be characterized by its spin value, which when measured is either +1/2 or –1/2. We can thus encode 1 to be +1/2 and 0 to be –1/2, and if we assume we can measure and manipulate the spin of such a particle then we could theoretically use this particle to store one bit of information. If we were to try to use this spin-1/2 particle as a classical bit, one that is always in the 0 or 1 state, we would fail. We would be trying to apply classical physics on a scale where it simply is not applicable. This single spin-1/2 particle will instead act in a quantum manner. (Williams, Clearwater) S

This spin -1/2 particle which behaves in a quantum manner could be the fundamental building block of a Quantum computer. We could call it a qubit, to denote that it is analogous in some ways to a bit in a classical computer. Just as a memory register in a classical computer is an array of bits, a quantum memory register is composed of several spin -1/2 particles, or qubits. There is no particular need for the spin-1/2 particle, equally well we could use a Hydrogen atom, and designate its electron being measured in the ground state to be the 0 state, and it being in the first excited state to be the 1 state. There are a multitude of possible qubit representations that will work. For simplicity I will discus only the spin-1/2 particle from here on, but analogous arguments could be made for many things.

2.3 STATE VECTORS AND DIRAC NOTATIONS

We wish to know exactly how the behavior of the spin-1/2 particle, our qubit, differs from a that of a classical bit. Recall that a classical bit can store either a 1 or a 0, and when measured the value observed will always be the value stored. Quantum physics states that when we measure the spin-1/2 particles state we will determine that it is in the +1/2 state, or the spin -1/2 state. In this manner our qubit is not different from a classical bit, for it can be measured to be in the+1/2, or 1 state, or the -1/2, or 0 state. The differences between the qubit and the bit come from what sort of information a qubit can store when it is not being measured.

According to quantum physics we may describe that state of this spin-1/2 particle by a state vector in a Hilbert Space. In general the mathematical term space refers to a something which depends on many independent coordinates which can be defined by a set of perpendicular axes, one for each independent variable. For example you are probably familiar with the x, y, z coordinate system where the x, y, and z axes are mutually perpendicular real number lines, which coincide at the point x=0, y=0, z=0.

A Hilbert Space is a special kind of space, it has the properties that it is a complex vector space, and it is a linear vector space.

The fact that it is a complex vector space means that the lengths of the vectors within the space are described with complex numbers. Complex numbers are numbers which take the form a+i*b, where a and b are real numbers, and I is defined to be the square root of negative one.

The fact that it is a linear vector space means that you may add and multiply vectors that lie in a given Hilbert Space and the resulting vector will still lie within that Hilbert Space. (Williams, Clearwater)

In the Hilbert Space for our state vector, which describes the state of our spin-1/2 particle, these perpendicular axes will correspond to each possible state that the system can be measured in. So our Hilbert Space for a single qubit will have two perpendicular axes, one corresponding to the spin-1/2 particle being in the +1/2 state, and the other to the particle being in the -1/2 state. These states which the vector can be measured to be are referred to as ``eigenstates.'' The vector which exists somewhere in this space which represents the state of our spin-1/2 particle is called the ``state vector.'' The projection of the state vector onto one of the axes shows the contribution of that axes' eigenstate to the whole state. This means that in general, the state of the spin-1/2 particle can be any combination of the base states. In this manner a qubit it totally unlike a bit, for a bit can exist in only the 0 or 1 state, but the qubit can exist, in principle, in any combination of the 0 and 1 state, and is only constrained to be in the 0 or 1 state when we measure the state.

Now I will introduce the standard notation for state vectors in Quantum physics. The state vector is written with the following way and called a ``ket vector'' 1y>. Where y is a list of numbers, which contain information about the projection of the state, vector onto its base states. The term ket and this notation come from the physicist Paul Dirac who wanted a concise shorthand way of writing formulas that occur in Quantum physics. These formulas frequently took the form of the product of a row vector with a column vector. Thus he referred to row vectors as ``bra vectors'' represented as, and would be referred to as a ``bracket.'' (Williams, Clearwater)

There is nothing special about this vector notation, you may think of any state vector being written as a letter with a line over it, or as a bold letter, as vectors are normally denoted. If you do further reading into this area you will almost assuredly come across the bra and ket notation, which is why it is presented.

2.4 SUPERPOSITION AND EIGENSTATES

Earlier I said that the projection of the state vector onto one of the perpendicular axes of its Hilbert Space shows the contribution of that axes' eigenstate to the whole state. You may wonder what is meant by the ``whole state.'' You would think (and rightly so, according to classical physics) that our spin-1/2 particle could only exist entirely in one of the possible +1/2 and -1/2 states, and accordingly that its state vector could only exist lying completely along one of its coordinate axes. If the particle's axes are called x and y, and the state vector's x coordinate which denotes the contribution to the +1/2 , or 0 state, and y coordinate which denotes the contribution to the –1/2 , or 1 state, should only be (1,0), or (0,1).

That seems perfectly reasonable, but it simply is not correct. According to quantum physics a quantum system can exist in a mix of all of its allowed states simultaneously. This is the Principle of Superposition, and it is key to the power of the quantum computer. While the physics of superposition is not simple at all, mathematically it is not difficult to characterize this kind of behavior.

2.5 THE QUANTUM QUBIT

Back to our qubit, our spin -1/2 particle. Now that we know that while it can only be measured to have a spin of +1/2 or –1/2, it may in general be in a superposition of these states when we are not measuring it. We could refer to its state in the following manner.

Let x1 be the eigenstate corresponding to the spin +1/2 state, and let x0 be the eigenstate corresponding to the spin -1/2 state. Let X be the total state of our state vector, and let ω1 and ω0 be the complex numbers that weight the contribution of the base states to our total state, then in general:

|X>=ω0*|x0> + ω1*|x1 >


At this point it should be remembered that ω0 and ω1, the weighting factors of the base states are complex numbers, and that when the state of X is measured, we are guaranteed to find it to be in either the state:

\begin{displaymath}0 * \vert x_{0} \rangle + w_{1} * \vert x_{1} \rangle \equiv (0,w_{1})\end{displaymath}


or the state

\begin{displaymath}w_{0} * \vert x_{0} \rangle + 0 * \vert x_{1} \rangle \equiv (w_{0},0)\end{displaymath}


This is analogous to a system you should be more familiar with, a vector with real weighting factors in the a two dimensional plane. Let the base states for this two dimensional plane be the unit vectors $x$, and $y$. In this case we know that the state of any vector $V$can be described in the following manner:

\begin{displaymath}V = x_{0} * x + y_{0} * y \equiv (x_{0},y_{0})\end{displaymath}

Our state vector is a unit vector in a Hilbert space, which is similar to vector spaces you may be more familiar with, but it differs in that the lengths of the vectors are complex numbers. It is not necessary from a physics perspective for the state vector to be a unit vector (by which I mean it has a length of 1), but it makes for easier calculations further on, so I will assume from here on out that the state vector has length 1. This assumption does not invalidate any claims about the behavior of the state vector. To see how to convert a state vector of any length to length 1 see appendix A.

With all this in mind we have fully defined the basic building block of our quantum computer, the qubit. It is fundamentally different from our classical bit in that it can exist in any superposition of the 0 and 1 states when it is not being measured. (Barenco, Ekert, Sanpera, Machiavello)

2.6 QUANTUM PARALLELISM

Given that our quantum memory register differs from a classical one in that it can store a superposition of the base states of the register, one might wonder what this implies as to the power of quantum computing. The study of quantum computing is relatively new, most give credit to Richard Feynman for being the first to suggest that there were tasks that a quantum computer could perform exponentially better than a classical computer. Feynman observed that a classical computer could not simulate a quantum mechanical system without suffering from exponential slowdown. At the same time he hinted that perhaps by using a device whose behavior was inherently quantum in nature one could simulate such a system without this exponential slowdown. (Feynman)

Most modern theoretical quantum algorithms rely on something called quantum parallelism. Quantum parallelism arises from the ability of a quantum memory register to exist in a superposition of base states. A quantum memory register can exist in a superposition of states, each component of this superposition may be thought of as a single argument to a function. A function performed on the register in a superposition of states is thus performed on each of the components of the superposition, but this function is only applied one time. Since the number of possible states is $2^{n}$where $n$is the number of qubits in the quantum register, you can perform in one operation on a quantum computer what would take an exponential number of operations on a classical computer. This is fantastic, but the more superposed states that exist in you register, the smaller the probability that you will measure any particular one will become.

As an example suppose that you are using a quantum computer to calculate the function $\mathcal{F}(x) = 2*x \bmod 7$, for $x$integers between 0 and 7 inclusive. You could prepare a quantum register that was in a equally weighted superposition of the states 0-7. Then you could perform the $2*x \bmod 7$operation once, and the register would contain the equally weighted superposition of 1,2,4,6,1,3,5,0 states, these being the outputs of the function $2*x \bmod 7$for inputs 0 - 7. When measuring the quantum register you would have a $2/8$chance of measuring 1, and a $1/8$chance of measuring any of the other outputs. It would seem that this sort of parallelism is not useful, as the more we benefit from parallelism the less likely we are to measure a value of a function for a particular input. Some clever algorithms have been devised, most notably by Peter Shor and L. K. Grover which succeed in using quantum parallelism on a function where they are interested in some property of all the inputs, not just a particular one.

2.7 THE POWER OF QUANTUM COMPUTER

Given the possible power of quantum parallelism much work has been done to show formally with mathematical proofs how quantum computers differ from classical ones in their power to compute things. Here is a short list of some of the landmarks in the study of the power of quantum computers.

In 1980 Paul Benioff offered a classical Turing machine which used quantum mechanics in its workings, thus showing that theoretically a quantum computer was at least as powerful as a classical computer. (Benioff)

In 1982 Richard Feynman showed that a classical Turing Machine (and hence any classical computer) could not simulate a quantum mechanical system without suffering exponential slowdown. (Feynman)

David Deutsch and Richard Jozsa showed in a paper in 1992 that there was an algorithm that could be run in poly-log time on a quantum computer, but required linear time on a deterministic Turing machine. This may have been the first example of a quantum computer being shown to be exponentially faster than a deterministic Turing machine. Unfortunately for the quantum computer, the problem could also be solved in poly-log time in a probabilistic Turing machine, a Turing machine which is capable of making a random choice. (Deutsch, Jozsa)

Also in 1992 Andre Berthiaume proved that $P \subset QP$, where $P$is a complexity class as mentioned earlier and $QP$corresponds to problems which can be solved in worst case polynomial time by a quantum computer, so with regards to tractability a quantum computer is more powerful than any classical computer. (Berthiaume, Brassard)

SHOR’S ALGORITHM


4.1 INTRODUCTION

By the early nineties it was know that a quantum computer could be faster than any classical computer. Nonetheless these observations were largely driven by academic curiosity. There was not much motive for people to spend lots of money or time trying to build a quantum computer.

That changed in 1994 when Peter Shor, a scientist working for Bell Labs devised a polynomial time algorithm for factoring large numbers on a quantum computer. This discovery drew great attention to the field of quantum computing.

4.2 STEPS

Peter Shor showed how to design a quantum computer to calculate the factors of an integer in polynomial time, theoretically breaking RSA.

We want to factor N, that is, find A and B such that AB =N.

Trick: find distinct x and y such that

x 2 ºy 2 mod N.

Then

x 2 - y 2 = (x + y)(x - y) º0 mod N

so one must contain a factor, which we can find by e.g.

gcd(x - y,N).

Next, take y to be 1, so if x r º1 and r is even then

(x r/2 - 1)(x r/2 + 1) º0 modN.

Then r is the period of the function x a mod N in a.

Looking for pair x,r such that (x r/2 - 1)(x r/2 + 1) º0 mod N.

Greatly simplifying, algorithm builds a superposition of all integers x , then calculates xa mod N for all a in parallel.

Discover the periods using a (quantum) FFT on the resulting entanglement. The final state is (sort of) an entanglement of all valid x,r pairs.

Finally, measure the output register. QMP says it must choose one x,r pair, and we can factor.

With probability << 1/2, the output may be zero; if so, we run it again.

Not much like a regular computer program!

4.3 WHAT ELSE WE CAN DO?

Shor’s algorithm factors in polynomial time.

(We expect to get a nonzero result in a small number of runs.)It’s dramatically faster than any known classical algorithm.

Entanglement gives us exponential parallelism.

A few other quantum algorithms go faster than classical. Most are obscure but one is important:

Lov Grover’s algorithm searches an unordered database of N elements to finds an element satisfying a given condition in √N time. In other words,

it searches a linear list in square root time.

Not as dramatic as the exponential speedup in Shor’s algorithm, but remarkable and possibly even practical.

4.4 DECOHERENCE

Factoring a 200digit number using Shor requires 3500 perfectly well behaved qubits. (Current state of the art is four entangled qubits.) But that’s not the hard part.

The challenge is decoherence: the ‘leakage’ of quantum state into the environment. Actually, it is entanglement with the environment. (Believed to be the explanation for why the macroscopic world behaves classically).

QC must be run in a sealed box without any interaction with the outside world. Otherwise the qubits will be contaminated.(This is another reason debugging could be hard.)

The required isolation is extreme; today’s entangled atomic states in the lab last for about 10ns, and decoherence proceeds exponentially fast in the number of particles.

4.5 ERROR CORRECTION

Decoherence would be the death knell for QC, except that Shor and others discovered quantum error correction. Like classical error correction, but QEC can correct an arbitrary error in a qubit, even if we don’t know its state! (Much more astonishing than repairing a bit flip in a classical message.)

Many such codes exist, e.g. 7 qubits can fully repair damage to any one qubit in the message.

QEC could compensate for decoherence and other losses if they’re at a low enough rate. (Current theory ranges from 10 - 6 to 10 - 2.) Error correcting a t sstep computation involves overhead polynomial in log t.

Using Shor to factor 200 digits requires 3500 perfect qubits, 100,000 if error correction is involved.


AMAZING FACTS ABOUT BILL GATES

1. Bill Gates earns US$250 every SECOND, that's about US$20 Million a DAY
and US$7.8 Billion a YEAR!

2. If he drops a thousand dollars, he won't even bother to pick it up b'coz
by the 4th second he picks it, he already earns it back.

3. US's national debt is about 5.62 trillion, if Bill Gates pays the debt
by himself; he will finish it in less then 10 years.

4. He can donate US$15 to everyone on earth but still be left with US$5
Million for his pocket money.

5. Michael Jordan is the highest paid athlete in the US. If he does'nt
drink and eat, and keep his annual income US$30 Million up, he'll have to
wait for 277 years to become as rich as Bill Gates now.

6. If Bill Gates is a country, he is the 37th richest country on earth,or
US 13th biggest company, even bigger then IBM.

7. If exchange all Bill Gate's money to US$1, you can make a road from
earth to moon, 14 times back and forth. But you have to make that road
non-stop for 1,400 years, and use a total of 713 BOEING 747 plane to
transport all the money.

8. Bill Gates is 53 this year. If we assume that he still can live for 25
years, he has to spend US$6.78 Million per day to finish his money before
going to heaven.

9. BUT!!! If Microsoft Windows' users can claim US$1 for every time their
computers hang because of Microsoft Windows, Bill Gates will bankrupt in 3
years!

AMAZING PERCENTAGES

D I S C I P L I N E
4 9 19 3 9 16 12 9 14 5 = 100%


A T T I T U D E
1 20 20 9 20 21 4 5 = 100%


R E E N G I N E E R (changing yourself)
18 5 5 14 7 9 14 5 5 18 = 100 %


And here comes the next ones.....
C O M P E T E N C E
3 15 13 16 5 20 5 14 3 5 = 99 %


H A R D W O R K
8 1 18 4 23 15 18 11 = 98 %


K N O W L E D G E
11 14 15 23 12 5 4 7 5 = 96 %


In addition to Knowledge, Hard work & Competence, the
important things that a person needs to be successful is to have DISCIPLINE,
ATTITUDE & the will to RE ENGINEER oneself in the face of calamities/hardships.
By the way... FORTUNE counts to 99% only

WHY ENGLISH LANGUAGE?

Let's face it--English is a crazy language. There is no egg in
eggplant nor ham in hamburger; neither apple nor pine in pineapple.
English muffins weren't invented in England or French fries in
France. Sweetmeats are candies while sweetbreads, which aren't sweet,
are meat.
We take English for granted. But if we explore its paradoxes, we
find that quicksand can work slowly, boxing rings are square and a
guinea pig is neither from Guinea nor is it a pig.
And why is it that writers write but fingers don't fing, grocers don't
groce and hammers don't ham? If the plural of tooth is teeth, why isn't
the plural of booth beeth? One goose, 2 geese. So one moose, 2 meese?
One index, 2 indices?
Doesn't it seem crazy that you can make amends but not one amend? If yo
have a bunch of odds and ends and get rid of all but one of them, what
do you call it?
If teachers taught, why didn't preachers praught? If vegetarians eat
vegetables, what does a humanitarian eat? If you wrote a letter, perhaps
you bote your tongue?
Sometimes I think all the English speakers should be committed to an
asylum for the verbally insane. In what language do people recite at a
play and play at a recital? Ship by truck and send cargo by ship?
Have noses that run and feet that smell? Park on driveways and drive
on parkways?
How can a slim chance and a fat chance be the same, while a wise man and
a wise guy are opposites? How can overlook and oversee be opposite,
while quite a few and quite a lot are alike? How can the weather be hot
as hell one day and cold as hell the other day.
You have to marvel at the unique lunacy of a language in which your
house can burn up as it burns down, in which you fill in a form by
filling it out and in which an alarm clock goes off by going on
English was invented by people, not computers, and it reflects the
creativity of the human race (which of course, isn't a race at all).
That is why, when the stars are out, they are visible, but when the
lights are out, they are invisible. And why, when I wind up my watch,
I start it, but when I wind up this essay, I end it.

SOME STUPID QUESTIONS IN OUR DAILY LIFE

Stupid Questions

1. At the movies: When you meet acquaintances/friends...
Stupid Question:- Hey, what are you doing here?
Answer:- Don't u know, I sell tickets in black over here..

2. In the bus: A heavy lady wearing pointed high-heeled shoes steps on your feet...
Stupid Question:- Sorry, did that hurt?
Answer:- No, not at all, I'm on local anesthesia..... why don't you try again.

3. At a funeral: One of the teary-eyed people ask...
Stupid Question:- Why, why him, of all people.
Answer:- Why? Would it rather have been you?

4. At a restaurant: When you ask the waiter
Stupid Question:- Is the "Butter Paneer Masala" dish good??
Answer:- No, its terrible and made of adulterated cement. We occassionaly also spit in it.

5. At a family get-together: When some distant aunt meets you after years...
Stupid Question:- Munna,Chickoo, you've become so big.
Answer:- Well you haven't particularly shrunk yourself.

6. When a friend announces her wedding, and you ask...
Stupid Question:- Is the guy you're marrying good?
Answer:- No,he's a miserable wife-beating , insensitive lout...it's just the money.

7. When you get woken up at midnight by a phone call...
Stupid Question:- Sorry. were you sleeping?
Answer:- No. I was doing research on whether the Zulu tribes in
Africa marry or not. You thought I was sleeping....
you dumb witted moron.

8. When you see a friend/colleague with evidently shorter hair...
Stupid Question:- Hey have you had a haircut?
Answer:- No, its autumn and I'm shedding......

9. At the dentist when he's sticking pointed objects in your mouth...
Stupid Question:- Tell me if it hurts?
Answer:- No it wont. It will just bleed.

10. You are smoking a cigarette and a cute woman asks...
Stupid Question:- Oh, so you smoke.
Answer:- Gosh, it's a miracle ............it was a
piece of chalk and now it's in flames!!!

VALUE OF TIME

The Value of Time


To realize the value of ONE YEAR
Ask a student who has failed his exam.

To realize the value of ONE MONTH
Ask a mother who has given birth to a pre-mature baby.

To realize the value of ONE WEEK
Ask an editor of a weekly.

To realize the value of ONE DAY
Ask a daily wage laborer.

To realize the value of ONE HOUR
Ask the lovers who are waiting to meet.

To realize the value of ONE MINUTE
Ask a person who has missed the train.

To realize the value of ONE SECOND
Ask a person who has survived an accident.

To realize the value of ONE MILLI-SECOND
Ask the person who has won a silver medal in Olympics.

To realize the value of ONE MICRO-SECOND
Ask a NASA scientist.

To realize the value of ONE NANO-SECOND
Ask a Hardware Engineer.

And if you still don't realize the value of time
you must be a Software Engineer!!!

JUST 4 LAUGHS TO TICKLE UR FUNNY BONE

>Innocent answers by kids!!!!


TEACHER: Why are you late?
WEBSTER: Because of the sign.
TEACHER: What sign?
WEBSTER: The one that says, "School Ahead, Go Slow."

-------------------------------------------------------------------

TEACHER: Cindy, why are you doing your maths sums on the floor?
CINDY: You told me to do it without using tables!

-------------------------------------------------------------------

TEACHER: John, how do you spell "crocodile"?
JOHN: "K-R-O-K-O-D-A-I-L"
TEACHER: No, that's wrong
JOHN: Maybe it's wrong, but you ask me how I spell it!

-------------------------------------------------------------------

TEACHER: What is the chemical formula for water?
SARAH: "HIJKLMNO"!!!
TEACHER: What are you talking about?
SARAH: Yesterday you said it's H to O!

-------------------------------------------------------------------

TEACHER: George, go to the map and find North America.
GEORGE: Here it is!
TEACHER: Correct. Now, class, who discovered America?
CLASS: George!

-------------------------------------------------------------------

TEACHER: Willy, name one important thing we have today that we didn't
had ten years ago.
WILLY: Me!

-------------------------------------------------------------------

TEACHER: Tommy, why do you always get so dirty?
TOMMY: Well, I'm a lot closer to the ground then you are.

-------------------------------------------------------------------

SILVIA: Dad, can you write in the dark?
FATHER: I think so. What do you want me to write?
SYLVIA: Your name on this report card.

-------------------------------------------------------------------

TEACHER: How can you prevent diseases caused by biting insects?
JOSE: Don't bite any.

-------------------------------------------------------------------

TEACHER: Ellen, give me a sentence starting with "I".
ELLEN: I is...
TEACHER: No, Ellen. Always say, "I am."
ELLEN: All right... "I am the ninth letter of the alphabet."

-------------------------------------------------------------------

Teacher: "Can anybody give an example of COINCIDENCE?"
Johnny : "Sir, my Mother and Father got married on the sameday and at same time


-------------------------------------------------------------------

Teacher: "George Washington not only chopped down his father's
Cherry tree, but also admitted doing it. Now do you know why his father
did't punish him?"
Johnny : "Because George still had the axe in his hand."

-------------------------------------------------------------------


At a church school gathering, one little old lady approached a cute girl
and asked her where she got her good looks. "I musta got 'em from my daddy
said the little girl,"'cause Mommy's still got hers."

-------------------------------------------------------------------

Teacher: Now, children, if I saw a man beating a donkey and stopped him,what
virtue would I be showing?
Student: Brotherly love.

-------------------------------------------------------------------


Teacher: Now, Sam, tell me frankly do you say prayers before eating?
Sam : No sir, I don't have to, my mom is a good cook.

-------------------------------------------------------------------

Teacher: Desmond, your composition on "My Dog" is exactly the same as

brother's. Did u copy his?
Desmond: No, teacher, it's the same dog!

--------------------------------------------------------------------

big city California lawyer went duck hunting in rural New
South Wales. He shot and dropped a bird, but it fell into a
farmer's paddock on the other side of a fence.

As the lawyer climbed over the fence, an elderly farmer
drove up on his tractor and asked him what he was doing. The
litigator responded, "I shot a duck and it fell in this
field, and now I'm going into retrieve it."

The old farmer replied. "This is my property, and you
are not coming over here."

The indignant lawyer said, "I am one of the best trial
attorneys in the States and, if you don't let me get that
duck, I'll sue you and take everything you own."

The old farmer smiled and said, "Apparently, you don't know
how we do things up here in the Northern Rivers. We
settle small disagreements like this with the Dorrigo
Three Kick Rule."

The lawyer asked, "What is the Dorrigo Three Kick Rule?"

The Farmer replied. "Well, first I kick you three times and
then you kick me three times, and so on, back and forth,
until someone gives up."

The attorney quickly thought about the proposed contest and
decided that he could easily take the old codger. He
agreed to abide by the local custom. The old farmer
slowly climbed down from the tractor and walked up to the
city feller.

His first kick planted the toe of his heavy work boot
into the lawyer's groin and dropped him to his knees. His
second kick nearly ripped the man's nose off his face.
The barrister was flat on his belly then the farmer's third
kick to a kidney nearly caused him to give up.

The lawyer summoned every bit of his will and managed to
get to his feet and said, "Okay, you old coot - now it's
my turn."

The old farmer smiled and said, "Nah, I give up. You can
have the duck."

--------------------------------------------------------------------

A man walking along a California beach was deep in prayer. All of a sudden, he said out
loud, "Lord grant me one wish." Suddenly the sky clouded above his head and in a booming
voice the Lord said, "Because you have TRIED tobe faithful to me in all ways, I will grant
you one wish." The man said, "Build a bridge to Hawaii, so I can drive over anytime I want."

The Lord said, "Your request is very materialistic. Think of the enormous challenges for that
kind of undertaking. The supports required to reach the bottom of the Pacific! The concrete
and steel it would take! I can do it, but it is hard for me to justify your desire for worldly
things. Take a little more time and think of another wish, a wish you think would honour and
glorify me." The man thought about it for a long time. Finally he said, "Lord, I wish that I
could understand women. I want to know how they feel inside, what they are thinking when they
give me the silent treatment, why they cry, what they mean when they say 'nothing', and how I
can make a woman truly happy."

The Lord replied, "You want two lanes or four on that bridge?"

--------------------------------------------------------------------

SON: Dad, I have to do a special report for school. Can I ask
you a question?
DAD: Sure Son, what's the question?
SON: What is politics?
DAD: Well, let's take our home for an example. I am the wage
earner, so lets call me "Capitalism". Your mother is the
administrator of the money so we'll call her "Government".

We take care of you and your needs, so let's call you "the
people". We'll call the maid "the working class" and your
baby brother "the future". Do you understand, Son?
SON: I'm not really sure, Dad. I'll have to think about it.
That night, awakened by his baby brother crying, the boy
went to see what was wrong. Discovering that the baby had
seriously soiled his diaper, the boy went to his parents'
room and found his mother sound asleep. He then went to the
maid's room and saw his father in bed with the maid. The
boy's knocking went totally unheard by his father and
the maid,so the boy returned to this room and went back to
asleep. The next morning he reported to his father.

SON: Dad, now I think I understand what politics is.
DAD: Good, Son. Can you explain it to me in your own words?
SON: Well, while CAPITALISM is screwing the WORKING CLASS and
the GOVERNMENT is sound asleep, the PEOPLE are being
completely ignored and the FUTURE is full of shit.

--------------------------------------------------------------------

Son : Daddy, have you ever been to Egypt?
Father : No. Why do you ask that?
Son : Well, where did you get mummy then?

--------------------------------------------------------------------

Lady : Is this my train?
Station Master : No, it belongs to the Railway Company.
Lady : Don't try to be funny. I mean to ask if I can take this
train to Kuala Lumpur.
Station Master : No Madam, I'm afraid it's too heavy.

--------------------------------------------------------------------

Peter : What a pair of strange socks you are wearing, one is
green and one is blue with red spots!
Kirk : Yes it's really strange. I've got another pair of the
same at home.

--------------------------------------------------------------------

Teacher : Peter, why are you late for school again?
Peter : Well, Miss, I dreamed that I was playing football and
the game went into extra time.

--------------------------------------------------------------------

Wife : Do you want dinner?
Husband : Sure, what are my choices?
Wife : Yes and no.

--------------------------------------------------------------------

First Guy (proudly): "My wife's an angel!"
Second Guy : "You're lucky, mine's still alive."

--------------------------------------------------------------------

The girl asked her lover, "Darling, if we get engaged will you
give me a ring?"
"Sure," replied her lover "What's your phone number?"

--------------------------------------------------------------------

A drunkard was brought to court. Just before the trial there was
a commotion in the gallery. The judge pounded the gravel on his
table and shouted, "Order, order."
The drunkard immediately responded, "Thank you, your honour,
I'll have a scotch and soda."

--------------------------------------------------------------------

'For twenty years my husband and I were very happy' 'What happened
then?'
'We met.'

--------------------------------------------------------------------

Customer : 'If I post this letter tonight, will it get to
Brighton in two days' time?'
Post Master : 'Well it might do.'
Customer : I bet you, it won't.
Post Master : Why not?
Customer : It's addressed to London.

--------------------------------------------------------------------

An absent-minded man went to see a psychiatrist.
'My trouble is,' he said, 'that I keep forgetting things.'
'How long has this been going on?' asked the psychiatrist.
'How long has what been going on?' said the man.

--------------------------------------------------------------------

Girl : Do you love me ?
Boy : Yes Dear
Girl : Would you die for me ?
Boy : No, mine is undying love

--------------------------------------------------------------------

1st thief : Oh! The police is here. Quick! Jump out of the window
2nd thief : But this is the 13th floor.
1st thief : Hurry! this is no time for superstitions.

--------------------------------------------------------------------

Man : How old is your father ?
Boy : As old as me
Man : How can that be ?
Boy : He became a father only when I was born

--------------------------------------------------------------------

Teacher : Correct the sentence, "A bull and a cow is grazing in
the field"
Student : A cow and a bull is grazing in the field
Teacher : How ?
Student : Ladies first.

--------------------------------------------------------------------

Waiter : I've stewed liver, boiled tongue and frog's leg.
Customer : Don't tell me your problems. Give me the menu card.

--------------------------------------------------------------------

SOME USEFUL AND IMPORTANT LINKS

for music downloads logon to:
www.cooltoad.com
www.songs.pk
www.bollyextreme.com
www.apniisp.com
www.multimedia_search.com


for video downloads logon to:
www.ezmobiles.com
www.youtube.com
www.videos.google.com
www.metacafe.com


for seminar and seminar related information logon to:
www.wikipedia.com
www.ieee.com
www.ieeexplore.org
www.seminar.com
www.freearticles.com
www.articlecity.com


for universal downloads logon to:(only when you have torrent installed)
www.utorrent.com

for software downloads logon to:
www.download.com
www.ezmobiles.com
www.utorrent.com

September 18, 2008

XML BASED SERVERS

1.1 WHAT IS XML?

Extensible Markup Language (XML) is the latest buzzword on the Internet, but it is also a rapidly growing and maturing technology with real world applications, particularly for management, display, and the organization of data. It is primarily a technology concerned with the description and structuring of data.

The idea of a universal data format is not new. An early attempt to combine a universally acceptable data format with rich information storage capabilities was SGML (Standard Generalized Markup Language). The best known application of SGML is HTML (Hypertext Markup Language). The idea was that any HTML document (or web page) would be presentable in any application that was capable of understanding HTML (termed the Web Browser).

Unfortunately, SGML is such a complicated language that it is not well suited to data interchange over the Web. HTML too is limited in its scope, in that it is intended for displaying documents in a browser only. Thus to adapt SGML to provide facilities to describe some kinds of specialized information, XML was developed. Thus XML is actually a subset of SGML and fully compatible with it.

It is important to note however that XML is not really a language at all, but a standard for creating languages that meet the XML criteria. It thus describes a syntax that you would use to create your own languages. XML can be viewed in an IE5 web browser since IE5 contains a default built in style sheet that enables us to view XML documents in a web browser.

XML is very flexible. Hence it is targeted to be the basis for defining data exchange languages, especially for communication over the Internet. It makes it very easy to work with data within applications but it also makes it easy to share this information with others. The coming chapters will highlight some factors about the use of XML in real world applications, as well as the reason why it is becoming the lingua franca for database applications.

1.2 WHY EXTENSIBLE ?

Since we have full control over the creation of the XML document, we can shape the data any way we wish, so that it makes sense to our particular application. For example, instead of creating a text file to store the name- John Doe, I might create an XML file like

John

Doe

If I do not wish for this level of flexibility, i.e. different tags for each part of the name, I can also write

John Fitzgerald Byers

We are thus free to structure the same data in different applications to suit the requirements of that application. If we want to create data in a way that only a particular computer program will use, we can do so. If we want to share data with other programs we can do so.

This is where the “Extensible” in XML comes from, in the freedom to use our own tags to describe data, to make it more comprehensible. Anyone is free to mark up data in any way using the language, even if others are doing it in totally different ways.

To interchange information much more easily, if people use the same format of data, it becomes much more easier. Thus XML allows us to use various industry-standard vocabularies to describe various types of data. For example, Scalable Vector Graphics (SVG) is an XML vocabulary for describing 2-dimensional graphics, MathML is an XML vocabulary for describing mathematics as a basis for machine to machine communication, etc.

1.2.1 Hierarchies in XML

XML groups information in hierarchies. The items in the document relate to each other in parent/child and sibling/sibling relationships.

These items are called elements or individual pieces of information in the data.


1.3 PIECES OF XML

Here are some of the important technologies that make up the XML family, each specification covering different aspects of communicating information.

q XML 1.0 is the base specification upon which the XML family is built. It describes the syntax that XML documents have to follow, the rules that XML parsers follow, and anything else you need to know to write an XML document.

q DTD’s (Document Type Definitions) and Schemas provide ways to create templates for our document types.

q Namespaces provide a way to distinguish one XML vocabulary from another, which allows us to create richer documents.

q XPath describes a querying language for addressing parts of an XML document.

q CSS (Cascading style sheets) and XSL (Extensible Style sheet language) are used to format the XML documents for displaying them.

q XLink and XPointer are languages used to link the XML documents with one another, in a similar manner to HTML hyperlinks.

q DOM (Document Object Model) provides a traditional way to interface with XML documents, and SAX (Simple API for XML) is an alternative way for programmers to interface with XML documents from their code.


1.4 WHERE IT IS USED


1.4.1 Reducing Server Load

Web based applications can use XML to reduce the load on web servers. This can be done by keeping all the information on the client as long as possible and then sending the information to those servers in one big XML document.

1.4.2 Web Site Content

The W3C (world wide web consortium) uses XML to write their specifications. These XML documents can then be transformed into HTML for display or transformed into a number of other presentation formats.

Some web sites also use XML entirely for their content where traditionally HTML would have been used.

XML is the basis for metadata (information about information, a special type of data) such as Microsoft’s Channel Definition Format (CDF) for describing Web push channels or Netscape’s Meta Content Framework (MCF).

1.4.3 Remote Procedure Calls

XML is also used for Remote Procedure Calls (RPC’s) , which allow objects on one computer to call objects on another computer to do work, allowing distributed computing. Using XML and HTTP for these RPC calls allows this to occur even through a firewall, which would normally block such calls, providing greater opportunities for distributed computing.

1.4.4 E-Commerce

E-Commerce is one of those buzzwords that you hear al over the place. Companies are discovering that communicating via the Internet, instead of by more traditional methods, they can streamline their processes, decreasing costs and increasing response times. Whenever one company needs to send data to another, XML is the perfect fir for the exchange format.


XML IN THE BROWSER


2.1 EXAMPLE XML DOCUMENT

Suppose we wish to create an XML document to describe a library of books according to information contained as regards the book name, author, price and other statistics. We use XML for such a project since it allows us to create a prototype of data that can be used in other files as well.

ISBN="8763-343-2343" >

Professional JINI

Sing Li

Wrox Publications

22/10/1999

XML Programming

Sudhir Ancha

Mann Publications

Couple of things to be noticed in the XML File :

The line "" is called the XML prolog. The XML version number should be mentioned at the start of every XML file. The rest of the line is optional. It tells the server about the type of character encoding our text is in, the style sheet files used, if any, and so on.

In the above XML file, after the XML Prolog

""

we have added one more line called

""

Here DOCTYPE Library indicates that all the Tags inside this XML file will be under the Tag "Library". Which means "Library" will be the parent or root of all other Tags in this XML file. Each XML file can have only one DOCTYPE.

Also in the XML File we have added comments for Book1 using the Following syntax

The Element called "Book" has both Attributes and More Tags under it. For Example in the above XML file, for the Book Element, ISBN is attribute and Title, Author and Publisher are sub Tags under the Book Element. If the Tags and Elements need to be added compulsorily or not in the XML file along with the Element is defined by DTD (Document Type Definition) file. For Example in the above XML file, For Book Element, ISBN might be compulsory if the search Based on ISBN is supported. And Date Published Tag may not be necessary at all times if there's no search facility based on get the Most Recent Books. I will explaining how to create DTD's after next few sections.

We have declared a Empty Tag for , under Second Book. This statement is equivalent to writing . This feature could save your XML file size if there is no Data required between the Tags.

The above XML document may be called well formed XML.

Well formed XML is the XML document thatmeets certain grammatical rules outlined in the XML 1.0 specification. There are a certain set of rules to be adhered to by the tags for the well formedness of XML documents. They are listed in the forthcoming section.

2.2 RULES FOR ELEMENTS

XML documents should adhere to the following rules to be well formed.

q Every start tag must have a matching end tag.

q Tags cannot overlap.

q XML documents can have only one root element.

q Element names must obey XML naming conventions.

q XML is case sensitive with respect to tags.

q XML will keep white space in your text.

2.3 XML PARSERS

The main reason for creating all these rules about the well formed-ness of XML documents is so that we can create a computer program to read in the data and easily tell markup from information. An XML processor is more commonly called a parser, since it simply parses XML and provides the application with any information it needs.

There are quite a number of XML parsers available. Some of them include Microsoft Internet Explorer Parser, James Clark’s Expat, Vivid Creations ActiveDOM, and popular among Java users, JavaSofts's XML Parser and IBM's Xerces Parser.

2.4 FORMATTING XML DOCUMENTS


Trying to view an XML document in the IE5 browser will certainly result in some kind of output due to the inbuilt default style sheet language in IE5. But this output will not be conforming to how you wanted it, in terms of color, foreground, design, formatting and general style. This is why we have style sheet languages like Cascading StyleSheet Language (CSS) and the default style sheet language for XML developed by the W3C called the XSL (Extensible Stylesheet language).

The need for formatting arises from the fact that in XML user defined tags rule the roost. Thus in our earlier book example, there is nothing built into the browser that will recognize that Book title, author, ISBN identification number et al, will appear in different columns, in different fonts or colors, or even on different lines. What we would see would be an unending line of words separated by whitespaces at the appropriate places.

Thus we develop the Content/Presentation paradigm with the use of stylesheet languages, which essentially embodies the idea that you separate the data from the way that data is displayed.

2.4.1 CASCADING STYLE SHEETS


It is a styling tool that can be used with XML as well as HTML documents. It provides us with the facility of being able to style individual tags the way we want; for example, the book name in bold, with a font size of 15 in blue color, the ISBN in red, with a font size of 18, and italicized print, and things like that.

Since my aim in this seminar is to show the importance of XML in data storage applications, I will not be delving into the details of how we can make XML documents look attractive in a browser environment. Nevertheless, an example is presented below.

Consider the following example of an XML document which is used to display the news of the week on a website:

The Weekly News

Bush Warns Terrorists

By our correspondent

Beijing, China.

Saturday February 23 2002 9:43 IST

The President of the United States, George W. Bush, today issued a statement, in which he came down hard on the abductors, and supposedly the killers, of the kidnapped Washington Post correspondent Daniel Pearl.

A grim faced Bush told reporters that the agents of terror operating in Asia would not get away with what they had done to the American journalist.

Although the abductors have not released Pearls's body, American sources said they have received evidence of Pearl's murder, in the form of a video tape showing him being stabbed.

The news of Pearl's death comes as no surprise after the arrested Pakistani militant Omar Sheikh, said that Pearl had been murdered by his abductors.However it has been received by the world community with a mixture of shock, sadness and outrage. Pearl is survived by his reporter wife Marianne, who is pregnant with their first child.

As can be seen in the above document, we have a well formed XML document. But it will appear on the website as a drab line by line account that will leave visitors with a bad taste for reasons other than the news it is displaying. But this problem can be offset by the efficient use of a cascaded style sheet document that will attach style to each of the tags. All that needs to be done is linking the CSS file with the above XML document with the use of the line:

first.css will be the cascaded style sheet document that can be typed on a simple notepad and then be saved as a .css file. For example, the CSS file for the above document can be written as follows:

/*File name-first.css*/

hedline {

display: block;

width: 400px;

border-bottom: 5px double black;

text-align: right;

font-family: Times, serif;

font-size: 36pt;

background-image: url("c:\news.bmp");

}

byline {

display: inline;

width: 200px;

text-align: left;

color: black;

font-family: Times, serif;

font-size: 14pt;

}

dateline {

display: inline;

width: 200px;

text-align: right;

color: black;

font-family: Times, serif;

font-size: 11pt;

font-style: italic;

}

p {

display: block;

width: 400px;

color: black;

font-family: Times, serif;

font-size: 12pt;

}

As can be seen in the above example, CSS files specify the tag of the corresponding XML document (in the same case) and also specify various attributes like font size, font family, color, background color, background image, width of the place on the webpage occupied by the tag etc, followed by the value of that particular attribute. For example, the statement:

background-image: url("c:\news.bmp");

in the “hedline” tag, styles the document in such a way that the headline of the news item is presented on the background of the news.bmp image.

Other attributes like alignment, indentation, margins and padding, position of the content with respect to the browser (static, relative, absolute and fixed), height and width of the output and tables can also be specified similarly.

2.4.2 EXTENSIBLE STYLE SHEET LANGUAGE


It is a language that can transform XML documents into any text based format, XML or otherwise. It is also used to create style sheets, similar to CSS. You can define the layout of the output document, and where to get data from within the output document.

XSLT style sheets are built on structures called templates, which specify what to look for in the source tree, and what to put into the result tree.

XSLT is especially important in the area of E-Commerce. For instance, consider two companies that wish to communicate their data. “A” is a store and “B” fulfils A’s orders.

Then three scenarios are possible- A can use the same structure for its data as B uses, B can use the same data structure as A’s, or they can use whatever XML format they wish to use internally, but transform their data to a common format whenever they wish to communicate the information outside.

With XSLT, this kind of transformation becomes quite easy.

Consider the following example of a database consisting of student records. The XML document looks like this:

Shaivya Easwaren

6, Gagangiri Villa, Vidyasagar Colony, Gultekdi, Pune

115

020-4272832

shaivya_e@yahoo.com

Ranjana Rao

7/A, Pleasant Park,Bhairoba Nala,Hadapsar, Pune

126

020-6871580

rrao@chequemail.com

Namita Sane

4,Center Court, Prabhat Road, Deccan Gymkhana, Pune

132

020-5673275

namita_s@hotmail.com

Krushna Bagade

532/2, Adinath Society, Vithoba Chowk , Kothrud, Pune

104

020-5436119

krushna_b@yahoo.com

The above information needs to be displayed in tabular format, which is not possible if we simply open the file in the Internet Explorer 5.0 browser. Here is where XSLT comes to our rescue.

The statement in the afore mentioned XML document:

tells the browser that the type of style sheet used for styling the file is a .XSL file and to look for the linked xsl file that contains the formatting information of the XML document.

The XSL file will look something like this:

Student table

Student Records

Name

Address

Roll no

Tel No.

E-mail ID






In the above .XSL file the first statement is necessary. It defines the W3C standard used in the XSL document. Templates are the heart and soul of XSLT. Style sheets are simply a collection of these templates, which are applied to the input document to get the output document. Style sheets may have as many templates as are needed.

The section of the source tree to which the template applies is specified by the match attribute. In this case match=”/” indicates the template is matched against the document root.

Special XSLT elements indicate to the processor that it should do some work. In this case, an element called is in effect, a mini template applying to any XML element in the source tree matching its select attribute. The element called is used to put the value of the XML element in the result tree.

When viewed in the browser, an XSL file appears in the form of a hierarchical tree, much like the XML document it is intended to style.

XSLT can also be used in conjunction with CSS. They provide a complementary functionality. XSLT can help you structure your pages in a wide number of formats. CSS can then balance this with easily modifiable media representations for those browsers that support it. XSLT’s primary domain is to provide transformation (i.e. programming) services to XML, while CSS takes the results of such transformations and makes XML into multimedia.

XML INTERFACES

3.1 DOCUMENT OBJECT MODEL AND XML-DOM


The Document Object Model (DOM) provides a means of working with XML documents and other types of documents through the use of code, and a way to interface with that code in the programs that we write. For instance DOM enables us to create documents and parts of documents, navigate through the document, move, copy and remove parts of the document, add or modify attributes.

Working with an object model makes working with information easier. An XML document in fact is structured very much like an object model, as seen in chapter 1. it is hierarchical, with nodes potentially having other nodes as children.

The DOM can model any XML document regardless of how it is structured. It is usually added as a layer between the XML parser and the application that needs information from the document, meaning that the parser reads the data from the XML document and then feeds the data into the DOM. The DOM is then used by a higher level application. The application can do whatever it desires with such information, including putting it into another proprietary object model if desired.

The DOM does not really deal with objects that much. It mainly works with interfaces. An interface is, by definition, a contract to support certain properties and methods, which can be applied to an object. Different programming languages may or may not use the term interface, or have a specific mechanism for providing interfaces, but the same concept can be applied to any language.

3.2 SIMPLE API FOR XML (SAX)

The Simple API for XML or SAX was developed in order to enable more efficient analysis of large XML documents. The problem with DOM is that before you can use it to traverse a document, it has to build a massive in-memory map of it. This takes up space and time, and is inefficient if you wish to recover small amounts of information.

If we want to locate only specific parts of the document, a second approach is more appropriate. The way that SAX works, and that is EVENT-DRIVEN. Rather than parse the document into the DOM and then use the DOM to navigate around the document, we tell the parser to raise events whenever it finds something.

Known SAX interfaces such as DocumentHandler can be used to “catch” events passed to us by the parser. We can use this to extract some simple information from the XML document. It is also possible to implement error handling by making the DocumentHandler throw SAXExceptions whenever an error is detected in the parsing.

Sophisticated intelligent parsing allows us to report errors and throw exceptions as they are found. Error handling mechanisms in the parser can be supplemented by using the Locator object.

Thus SAX is an excellent API for analyzing and extracting information from large XML documents without incurring the time and space overheads associated with the DOM. The latest version of SAX is the SAX 2.0.

3.3 NAMESPACES


Namespaces are the means by which we can differentiate elements and sometimes attributes of different XML document types from each other when combining them together into other documents or even when processing multiple documents simultaneously.

Because of the nature of XML, it is possible for any individual to create XML document types which describe the world in their own terms. If company A feels that element to denote a person’s name when XHTML already has a <title> element, which is used to describe the title of an HTML document? Further, how can one distinguish these from the <title> of a book? The answer is- namespaces.</p> <p style="line-height: 150%;">A traditional namespace is a set of zero or more names, each of which must be unique within the namespace and constructed according to the rules (if any) of the namespace. For example, the names of element types in an XML document inhabit a traditional namespace, as do the names of tables in a relational database and the names of class variables in a Java class. Traditional namespaces also occur outside the field of computer science -- for example, the names of people could be thought to inhabit a traditional namespace, as could the names of species.</p> <p style="line-height: 150%;">Different traditional namespaces are disjoint, i.e. they are not related. Because of this, a name in one traditional namespace does not collide with the same name in a different traditional namespace. This property is useful to applications that have multiple sets of names. By assigning each set of names to a different traditional namespace, they can allow the same name to occur in each set of names without fear of collision. For example, in the following XML document, there is no conflict between the three different uses of the name Value.</p> <pre style="line-height: 150%;"><span style=""> </span><b><span style="font-size: 11pt; line-height: 150%; font-family: "><auctionitem><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><title value="486Laptop"><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><category value="Computers"><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><value>$100</value><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span></auctionitem><o:p></o:p></span></b></pre><pre><o:p> </o:p></pre> <p style="line-height: 150%;">This is because an XML document has one traditional namespace for element type names and, for each element type, one traditional namespace for the names of the attributes that apply to that element type. Thus, the two Value attribute names don't conflict because each is assigned to a different traditional namespace -- the first to the attribute namespace for the Title element type and the second to the attribute namespace for the Category element type. Furthermore, neither of the Value attribute names conflicts with the Value element type name because element type names are kept in a traditional namespace that is separate from the attribute namespaces. The XML namespaces recommendation does not define anything except a two-part naming system for element names and attributes. </p> <p style="line-height: 150%;">As an example of how XML namespaces are used to resolve naming conflicts in XML documents that contain element types and attributes from multiple XML languages, consider the following two XML documents:</p> <pre style="line-height: 150%;"><span style=""> </span><b><span style="font-size: 11pt; line-height: 150%; font-family: "><?xml version="1.0" ?><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><address><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><street>Wilhelminenstr. 7</street><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><city><st1:city st="on"><st1:place st="on">Darmstadt</st1:place></st1:City></city><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><state>Hessen</state><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><country><st1:country-region st="on"><st1:place st="on">Germany</st1:place></st1:country-region></country><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><postalcode>D-64285</postalcode><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span></address><o:p></o:p></span></b></pre> <p style="line-height: 150%;">and:</p> <pre style="line-height: 150%;"><span style=""> </span><b><span style="font-size: 11pt; line-height: 150%; font-family: "><?xml version="1.0" ?><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><server><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><name>OurWebServer</name><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><address>123.45.67.8</address><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span></server><o:p></o:p></span></b></pre> <p style="line-height: 150%;">Each document uses a different XML language and each language defines an Address element type. Each of these Address element types is different -- that is, each has a different content model, a different meaning, and is interpreted by an application in a different way. This is not a problem as long as these element types exist only in separate documents. But what if they are combined in the same document, such as a list of departments, their addresses, and their Web servers? How does an application know which Address element type it is processing?</p> <p style="line-height: 150%;">The answer is to assign each language (including its Address element type) to a different namespace. This allows us to continue using the Address name in each language, but to distinguish between the two different element types.</p> <p style="line-height: 150%;">By assigning each Address name to an XML namespace, we actually change the name to a two-part name consisting of the name of the XML namespace plus the name Address. This means that any code that recognizes just the name Address will need to be changed to recognize the new two-part name. However, this only needs to be done once, as the two-part name is universally unique. </p> <p style="line-height: 150%;">The name of the XML namespace is a URI. This allows XML namespaces to provide a two-part naming system for element types and attributes. The first part of the name is the URI used to identify the XML namespace -- the <i>namespace name</i>. The second part is the element type or attribute name itself -- the <i>local part</i>, also known as the <i>local name</i>. Together, they form the <i>universal name</i>. For example: </p> <pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><department><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><name>DVS1</name><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><addr:addressxmlns:addr="http://www.tudarmstadt.de/to/addresses"><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><addr:street>Wilhelminenstr. 7</addr:Street><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><addr:city><st1:city st="on"><st1:place st="on">Darmstadt</st1:place></st1:City></addr:City><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><addr:state>Hessen</addr:State><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><addr:country><st1:country-region st="on"><st1:place st="on">Germany</st1:place></st1:country-region></addr:Country><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><addr:postalcode>D-64285</addr:PostalCode><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span></addr:Address><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><serv:server serv="http://www.tu-darmstadt.de/ito/servers"><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><serv:name>OurWebServer</serv:Name><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span><serv:address>123.45.67.8</serv:Address><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span></serv:Server><o:p></o:p></span></b></pre><pre style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%; font-family: "><span style=""> </span></department><o:p></o:p></span></b></pre> <p style="line-height: 150%;">Thus, each universal name is unique, meeting the requirement that each element type in an XML document have a unique name.</p> <p style="line-height: 150%;">Thus we have seen the functions of various XML interfaces and the modularity and reusability each of them incorporate into the language.</p><br /><p style="line-height: 150%;"><br /></p><span style="font-size:180%;"><i><u><span style="font-size: 18pt; line-height: 150%;">XML DATA</span></u></i></span> <p style="margin-left: 0.5in; text-indent: -0.5in; line-height: 150%;"><o:p> </o:p><span style="font-size: 16pt; line-height: 150%;"><span style="">4.1<span style="font-family: "> </span></span></span><!--[endif]--><b><i><u><span style="font-size: 16pt; line-height: 150%;">INTRODUCTION <o:p></o:p></span></u></i></b></p> <p style="line-height: 150%;">XML Documents follow a tree structure. A tree is a natural structure that is richer than a simple flat list yet also respectful of cognitive and data processing requirements for economy and simplicity. Valid XML documents belong to classes- document types- that determine the tree structure and other properties of their member documents. The properties of the classes themselves comprise the document type definitions or DTD’s which serve the same role for documents that schemas do for databases.</p> <p style="line-height: 150%;"><span style=""> </span>XML-Data is a notation in the form of an XML document that is both an alternative to markup declarations for writing DTD’s and a means of augmenting DTD’s with additional capabilities. For instance,</p> <p style="margin-left: 0.5in; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="font-size: 8pt; line-height: 150%; font-family: Wingdings;"><span style="">q<span style="font-family: "> </span></span></span><!--[endif]-->XML-data supports rich data types, allowing for tighter validation of data and reduced application effort. </p> <p style="margin-left: 0.5in; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="font-size: 8pt; line-height: 150%; font-family: Wingdings;"><span style="">q<span style="font-family: "> </span></span></span><!--[endif]-->Through the namespaces facility, XML-Data improves expressiveness, ensuring the existence of uniquely qualified names.</p> <p style="margin-left: 0.5in; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="font-size: 8pt; line-height: 150%; font-family: Wingdings;"><span style="">q<span style="font-family: "> </span></span></span><!--[endif]-->XML-Data provides for greater and more efficient semantic capabilities by incorporating the concept of inheritance, enabling one schema to be based on another. For instance, a bookstore purchase order schema could be based on a general- purpose E-Commerce schema. </p> <p style="margin-left: 0.25in; line-height: 150%;">Other benefits of the XML-Data, which uses XML instance syntax, include </p> <p style="margin-left: 1in; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="font-family: Wingdings;"><span style="">§<span style="font-family: "> </span></span></span><!--[endif]-->The same tools that are used to parse XML can be used to parse the XML-Data notation.</p> <p style="margin-left: 1in; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="font-family: Wingdings;"><span style="">§<span style="font-family: "> </span></span></span><!--[endif]-->As the syntax is very similar to HTML, it is easy for HTML authors to write and read.</p> <p style="margin-left: 1in; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="font-family: Wingdings;"><span style="">§<span style="font-family: "> </span></span></span><!--[endif]-->It is easily extensible.</p> <p style="margin-left: 0.25in; text-indent: 27pt; line-height: 150%;"><span style=""> </span>Schemas define the characteristics of classes of objects. Syntactic schemas are used for classes that are strictly syntactic, like XML. Conceptual schemas are used for classes that indicate concepts or relations among concepts, like RDBMS. Schemas are composed of declarations for </p> <p style="margin-left: 1.5in; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="font-size: 8pt; line-height: 150%; font-family: Symbol;"><span style="">Þ<span style="font-family: "> </span></span></span><!--[endif]-->Element- indicates the containment of a single element type (property). </p> <p style="margin-left: 1.5in; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="font-size: 8pt; line-height: 150%; font-family: Symbol;"><span style="">Þ<span style="font-family: "> </span></span></span><!--[endif]-->Empty, Any, String and Mixed content- the names are self-explanatory. Mixed content is a mixture of parsed character data and one or more elements.</p> <p style="margin-left: 1.5in; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="font-size: 8pt; line-height: 150%; font-family: Symbol;"><span style="">Þ<span style="font-family: "> </span></span></span><!--[endif]-->Group- a set of sequence of elements.</p> <p style="margin-left: 1.5in; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="font-size: 8pt; line-height: 150%; font-family: Symbol;"><span style="">Þ<span style="font-family: "> </span></span></span><!--[endif]-->Constraints and additional properties- like min and max constraints, domain and range constraints etc.</p> <p style="margin-left: 0.25in; line-height: 150%;"><o:p> </o:p></p> <p style="margin-left: 0.5in; text-indent: -0.5in; line-height: 150%;"><!--[if !supportLists]--><span style="font-size: 16pt; line-height: 150%;"><span style="">4.2<span style="font-family: "> </span></span></span><!--[endif]--><b><i><u><span style="font-size: 16pt; line-height: 150%;">XML-SPECIFIC ELEMENTS<o:p></o:p></span></u></i></b></p> <p style="margin-left: 0.5in; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="">1)<span style="font-family: "> </span></span><!--[endif]-->ATTRIBUTES</p> <p style="margin-left: 0.25in; line-height: 150%;">The XML syntax allows that certain properties can be expressed in a form called attributes. An attribute may be given a default value. For example:</p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="">2)<span style="font-family: "> </span></span><!--[endif]-->ENTITY DECLARATION ELEMENT TYPES</p> <p style="margin-left: 0.25in;"><span style=""> </span>Entities are a shorthand mechanism similar to macros in a programming language.</p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="">3)<span style="font-family: "> </span></span><!--[endif]-->EXTERNAL DECLARATIONS ELEMENT TYPE </p> <p style="margin-left: 0.25in; line-height: 150%;"><span style=""> </span>The extDcls declaration gives a clean mechanism of importing fragments from other schema.</p> <p style="margin-left: 0.25in; line-height: 150%;"><o:p> </o:p></p> <p style="margin-left: 0.5in; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="">4)<span style="font-family: "> </span></span><!--[endif]-->DATATYPES<span style=""> </span></p> <p style="margin-left: 0.25in; line-height: 150%;"><span style=""> </span>A datatype indicates that the contents of an element can be interpreted as both a string, and also, more specifically, as an object that can be interpreted more specifically as a number, date etc. The datatype indicates that the elements contents can be parsed or interpreted to yield an object more specific than a string.</p> <p style="margin-left: 0.25in; line-height: 150%;">Some common data types, their parse types, storage types in memory etc. are given in the table on the next page.</p> <p style="margin-left: 0.25in; line-height: 150%;">XML-Data datatypes include all the highly popular types and all the built in types of popular data base and programming languages like SQL, Visual Basic, C, C++, and Java. </p> <p style="margin-left: 0.25in; line-height: 150%;"><o:p> </o:p></p> <p style="margin-left: 0.25in; line-height: 150%;"><o:p> </o:p></p> <p style="margin-left: 0.25in; line-height: 150%;"><span style="font-size: 14pt; line-height: 150%;">TABLE 4.1 :<span style=""> </span>SPECIFIC DATATYPES IN XML-Data<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: medium none ; margin-left: 0.25in; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr> <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">NAME</p> </td> <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">PARSE TYPE </p> </td> <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">STORAGE TYPE</p> </td> <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">EXAMPLE</p> </td> </tr> <tr> <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">string</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">Pcdata</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">String(Unicode)</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">Greek letters</p> </td> </tr> <tr> <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">number</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">A number, with no limit on its digits, and optional sign, float and exponent</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">String</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">15, 3.14, 123.456E+10</p> </td> </tr> <tr> <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">int </p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">A number with optional sign, no fraction, no exponent</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">32-bit signed binary</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">1,58502, -13</p> </td> </tr> <tr> <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">float </p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">Same as for number</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">64 bit IEEE 488</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">.31415926E+1</p> <p style="line-height: 150%;"><o:p> </o:p></p> </td> </tr> <tr> <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">fixed .14.4</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">Same as number, less than 15 digits to left of ‘.’, 4 to the right.</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">64 bit signed binary </p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">12.0044</p> <p style="line-height: 150%;"><o:p> </o:p></p> </td> </tr> <tr> <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">boolean</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">“1” or “0”</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">Bit</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">0,1 (1==true)</p> </td> </tr> <tr> <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">char</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">String </p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">1 unicode character (16 bits)</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;"><o:p> </o:p></p> </td> </tr> <tr> <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">string.ansi</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">String with only ascii characters</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">Unicode or single byte string</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">I am Shaivya.</p> </td> </tr> <tr> <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">bin.hex</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">Hexadecimal digits representing octets</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">No specified size</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;"><o:p> </o:p></p> </td> </tr> <tr style=""> <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">uri</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">Universal resource identifier</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">Per W3C spec</p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2in;" valign="top" width="192"> <p style="line-height: 150%;">http://www.gossamer.org/fluky</p> </td> </tr> </tbody></table> <p style="margin-left: 0.25in; line-height: 150%;"><span style="font-size: 14pt; line-height: 150%;"><o:p> </o:p></span></p> <p style="margin-left: 0.25in; line-height: 150%;">Other datatypes include:</p> <p style="margin-left: 45pt; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="">-<span style="font-family: "> </span></span><!--[endif]-->i1: an 8-bit binary number with optional sign, no fractions, no exponent.</p> <p style="margin-left: 45pt; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="">-<span style="font-family: "> </span></span><!--[endif]-->i2: 16-bit binary.</p> <p style="margin-left: 45pt; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="">-<span style="font-family: "> </span></span><!--[endif]-->i4: 32-bit binary.</p> <p style="margin-left: 45pt; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="">-<span style="font-family: "> </span></span><!--[endif]-->i8: 64-bit binary.</p> <p style="margin-left: 45pt; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="">-<span style="font-family: "> </span></span><!--[endif]-->ui1-ui8: unsigned binary.</p> <p style="margin-left: 45pt; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="">-<span style="font-family: "> </span></span><!--[endif]-->r4: IEEE 488 4-byte float.</p> <p style="margin-left: 45pt; text-indent: -0.25in; line-height: 150%;"><!--[if !supportLists]--><span style="">-<span style="font-family: "> </span></span><!--[endif]-->r8: IEEE 488 8-byte float.</p> <p style="line-height: 150%;"><span style="font-size: 16pt; line-height: 150%;"><o:p> </o:p></span></p> <p style="line-height: 150%;"><span style="font-size: 16pt; line-height: 150%;">4.3<span style=""> </span><b><i><u>EXAMPLE XML SCHEMA</u></i></b> <b><i><u><span style=""> </span><o:p></o:p></u></i></b></span></p> <p style="line-height: 150%;"><b><i><span style="font-size: 14pt; line-height: 150%;">The Schema element type:<o:p></o:p></span></i></b></p> <p style="line-height: 150%;">All schema declarations are contained within a schema element type like this:</p> <p><b><span style="font-size: 11pt;"><?XML version=’1.0’?><o:p></o:p></span></b></p> <p><b><span style="font-size: 11pt;"><?xml:namespace<o:p></o:p></span></b></p> <p><b><span style="font-size: 11pt;"><span style=""> </span>name=”urn:uuid:BDC6E-11d1-00AA00CC14822/”<o:p></o:p></span></b></p> <p><b><span style="font-size: 11pt;"><span style=""> </span>as = “s”/?><o:p></o:p></span></b></p> <p><b><span style="font-size: 11pt;"><s:schema id="’ExampleSchema’"><o:p></o:p></span></b></p> <p><b><span style="font-size: 11pt;"><span style=""> </span><!—schema goes here-- ><o:p></o:p></span></b></p> <p><b><span style="font-size: 11pt;"></s:schema><o:p></o:p></span></b></p> <p style="line-height: 150%;">The heart of the XML-Data schema is the elementType declaration which defines a class of objects (or “type of element” in XML terminology). The id attribute serves a dual role of identifying the definition and also naming the specific class.</p> <p style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%;"><elementtype id="”author”/"><o:p></o:p></span></b></p> <p style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%;"><span style=""> </span><description> The description subelement may be used to provide a human readable description of the element’s purpose. In this case it is the person who wrote the book. </description><o:p></o:p></span></b></p> <p style="line-height: 150%;"><b><span style="font-size: 11pt; line-height: 150%;"></elementtype><o:p></o:p></span></b></p> <p style="line-height: 150%;">Consider the following schema that describes the book object. The element may be required or optional and may occur multiple times, as indicated by the occurs attribute that may have the values “REQUIRED”, “OPTIONAL” , “ZEROORMORE” or “ONEORMORE”. It has a default of required.</p> <p style="margin-left: 0.25in;"><b><span style="font-size: 11pt;"><elementtype id="”Book”"><o:p></o:p></span></b></p> <p style="margin-left: 0.25in;"><b><span style="font-size: 11pt;"><span style=""> </span><element type ="”#title”" occurs="”OPTIONAL”/"><o:p></o:p></span></b></p> <p style="margin-left: 0.25in;"><b><span style="font-size: 11pt;"><span style=""> </span><element type="”#author”" occurs="”ONEORMORE”/"><o:p></o:p></span></b></p> <p style="margin-left: 0.25in;"><b><span style="font-size: 11pt;"><span style=""> </span><attribute name="”copyright”/"><o:p></o:p></span></b></p> <p style="margin-left: 0.25in;"><b><span style="font-size: 11pt;"></elementtype> </span></b></p> <p style="margin-left: 0.25in;">describes an instance such as</p> <p style="margin-left: 0.25in;"><b><span style="font-size: 11pt;"><book copyright="”1922”"><o:p></o:p></span></b></p> <p style="margin-left: 0.25in;"><b><span style="font-size: 11pt;"><span style=""> </span><title>Hitchhiker’s Guide to the Galaxy should contain a certain set of information, and B feels it should contain a different set of information, they can both go ahead and create different document types to describe that information. However, personalized XML vocabularies are bound to create a problem sometime, due to the limits imposed by the scope of human vocabulary. How can one define a

Douglas Adams

Here each instance of “book” may contain a title and must contain one or more authors.

Consider another example of the schema to make the idea clearer.

name=”urn:uuid:BDC6E-11d1-00AA00CC14822/”

as = “s”/?>

Consider an instance of the above schema, that is, the information regarding a single book:

Henry Ford

Samuel Crowley

The Unofficial Guide to Intergalactic Travel <titlepart>A Spoof on Martians and Everything Otherworldly</titlepart>

Then the schema defines an instance of Book to have an optional title, and one or more authors. The name element has a content model of any, meaning that free text is not allowed, but any arrangement of subtitlements is valid. The content model of title is mixed, allowing a free intermixture of characters and any number of titleParts. The author, name and titleParts elements have a content model of string.

Mapping between schemas

Syntactic schemas often have fewer elements compared to explicitly conceptual ones. It is also easier to design a schema that merely covers syntax than a well thought out conceptual data model. An effect of this is that many practical schemas will not contain all the elements that a conceptual schema would, either for reasons of economy or because the schema was simply syntactic. But it is useful to make the implicit explicit, or more general over time, so that more generic processors can make use of the data.

Thus we can add mapping information to the syntactic schema using the statement. It will tell us how to interpolate the implied elements thereby creating a conceptual or RDBMS data model.

Thus schemas are an alternative way to constrain the nature and structure of data items in XML as well as the relationships among those data items. They also provide several advantages over DTD’s .


XML AND DATABASES


5.1 USING XML IN AN N-TIER APPLICATION

The N-tier architecture typically has the following logical layers-

q Data services, where all data for the application is stored (usually a database).

q Data Objects, which handle the communication between the database and Business Objects.

q Business Objects, which take care of the business logic in your application, and are responsible for communication between the presentation and data layers.

q Presentation, which is responsible for communication between the user and the business logic tier.

If XML is to be used in the above client-server environment, the presentation layer is going to be using XML for its data needs. Our business objects will also be using XML, both to communicate with the presentation tier and with each other. So we can might as well go all the way and have our data objects return XML instead of recordsets. When updating the database the Business Object could pass XML to the data objects, which would parse the XML and pull out the appropriate data to insert into the databases. This means that potentially, any time one object would communicate with another it would use XML as the common language.

5.2 RETURNING XML FROM A DATA OBJECT

We will be using Visual Basic to write the data object, ADO to connect to the database, and Microsoft’s XML parser, MSXML (Section 5.3.1), to create an XML document with the results of the query.

Dim cnnDatabaseConnection as ADODB.Connection.

Set cnnDatabaseConnection=New ADODB.Connection.

‘here we are connecting to the database….

Dim strSQL as string

StrSQL=”SELECT last_name FROM Customer WHERE account_number=1952”

We are now ready to execute our SQL. We call the execute() method that returns a recordset object as the result of the query.

Dim rsResult as ADODB.Recordset

Set rsResult=cnnDatabaseConnection.Execute(strSQL)

We then create a quick XML document and populate that object via the DOM with the values from our SQL.

Dim objXML as MSXML.DOMDocument

Set objXML=New MSXML.DOMDocument

objXML.loadXML “

The XML document looks like this:

And finally the last step is to get the value from our recordset and add it to the XML document.

objXML.selectSingleNode(“/root/lastname”).Text=rsResults(“last_name”).Value

MSXML provides a property of the Document object called xml which returns a string containing the XML document that this DOM is modeling. All the data object now has to do is to return the text from that property and we are done.

5.3 DATABASE VENDORS AND XML

With both XML and database being data-centric technologies, they are not in competition with each other, contrary to established belief. XML is best used to communicate data and a database is best used to retrieve data, which makes the two complementary rather than competitive. For this reason, database vendors, while realizing that XML will never replace the database, but become more closely integrated with it, have recognized the power and flexibility of XML. They are thus building support for XML right into their products.

5.3.1 MICROSOFT’S XML TECHNOLOGIES

Microsoft has been big on XML since the very beginning. Some of its technologies providing XML support are:

q MSXML

The Internet Explorer Browser comes bundled with the MSXML COM-based parser which provides a DOM interface. It provides validating and non-validating modes as well as support for XML namespaces. It also provides support for XSL transformations.

q Visual Basic Code generator

It can read XML Schema documents and produce Visual Basic code to match the schema. In effect, you can build the basics of an Object Model, based on an XML document type automatically.

q SQL Server

There is XML support built into SQL Server, Microsoft’s Relational Database Management System. SQL server provides the capability to perform an SQL query through an HTTP request via an ISAPI filter for Internet Information Server (Microsoft’s Web Server). Not only can you get data from the SQL Server using XML, you can also put it in using SQL Update Grams. These are XML files containing the information you want to put into the database in a certain format.

5.3.2 ORACLE’S XML TECHNOLOGIES

q XML parsers:

The first tool available from Oracle is the XML parser. Oracle provides parsers written in Java, C, C++, and PL/SQL. These parsers provide a DOM interface, a SAX interface, both validating and non-validating support, support for namespaces and fully compliant support for XSLT.

q Code Generators:

Oracle offers Java and C++ class generating applications like the Visual Basic code generator. However these generators work from DTD’s and not schemas, meaning they are fully conformant with W3C specifications.

q XML SQL Utility for Java

The XDK (XML Developer’s Kit) also provides the XML SQL Utility for Java that can generate an XML document from an SQL query, either in text form or as a DOM. It can also take in XML documents and use the information to update the database, like SQL Server 2000.

q XSQL Servlet

This servlet takes in an XML document that contains SQL queries, like the XML templates used by the SQL Server. It can optionally perform XSL transformations on the results, so the results can potentially be any type of file that can be returned from an XSLT transformation, including XML and HTML. Because it is a servlet, it can run on any web server that has a Java virtual machine and can host servlets.


APPLICATIONS OF XML

YOU CAN DO WITH XML

The potential areas of application of XML can be classified into three main ones: three tier web applications, multi-platform electronic publishing and electronic commerce or EDI.

Some of the possible areas of improvement using XML are outlined below:

The following are just a few examples of some of the exciting new technologies enabled by XML:

1) Internet Search Engines:

Imagine a search engine that understands and uses contextual information when performing a full-text search. Searching for information about the Java programming language would no longer yield links to coffee sites or the Island of Java. This is because searching for the term "Java" is narrowed down to those fields tagged as a "programming language". As a result, the speed and accuracy of the search is dramatically improved. Widespread use of XML repository technology on Web servers will play a vital role in easing the "information overload" currently suffered by Internet users. Of course all of these benefits require a sophisticated, scalable and fast repository. This repository must be able to manage the rich XML links and understand XML structure so that it indexes text based on its context and use in a document.

2) Electronic Commerce:

The long-expected rise of electronic commerce has been stymied by the difficulty encountered by consumers in finding the desired product among the myriad of vendors setting up shop on the Internet, all with different product lines, prices, on-line viewing capabilities, delivery options and so forth. So-called intelligent agents have not helped because they have an even harder time than humans in trying to make sense of the digital morass presented by HTML. With XML repository technology, on-line stores can present product information in a standard, structured format, independent of page design. Electronic commerce is obviously focused on financial transactions. Using HTML, the user must manually wade through HTML information to extract relevant data like price, tax, etc. And unlike text, numbers have no inherent context. In other words, price means something, but how do you know whether a number is associated with a price, a tax, an address or anything? XML creates this association, making human and machine interpretation a reality. XML is the catalyst that will finally unleash the explosive potential of electronic commerce. The XML-aware query facilities of the repository make it possible to retrieve relevant information directly and re-purpose it as needed it for processing by an automatic agent or a user. By reducing the time needed to locate a product, a price, or any other relevant information on the Internet, XML repositories will play an important role in making on-line shopping more efficient and enjoyable.

3) Electronic Data Interchange (EDI):

EDI (Electronic Data Interchange) works by providing a collection of standard message formats and element dictionary in a simple way for businesses to exchange data via any electronic messaging service.

XML/EDI provides a standard framework to exchange different types of data -- for example, an invoice, healthcare claim, project status -- so that the information be it in a transaction, exchanged via an Application Program Interface (API), web automation, database portal, catalog, a workflow document or message can be searched, decoded, manipulated, and displayed consistently and correctly by first implementing EDI dictionaries and extending our vocabulary via on-line repositories to include our business language, rules and objects. Thus by combining XML and EDI we create a new powerful paradigm different from XML or EDI.

4) Data Re-purposing:

By breaking documents into discrete elements, it becomes very easy for individuals to extract the truly relevant information from several sources and reassemble it into any format (e.g. web page, document, presentation, whatever). This helps to address the current information overload, because the user receives only the relevant information. In fact, the information might even be assembled by a personal agent. This ability also facilitates the acceleration of learning since it becomes much easier to assemble the "current" body of work on a particular subject, and then take it a step further, pushing the development of human knowledge ever forward.

These are just a few of the exciting technologies enabled by XML. Looking at these examples, it is easy to understand why XML is creating such excitement in the Internet community. As software developers begin to implement XML applications, however, they will have to address the need to turn these ideas into reality, while keeping up with the ever shortening development cycles characteristic of Web development. In many cases, developers will find that their prototypes work fine in the test laboratory but do not scale to address real world conditions of concurrent usage and data volume. XML's rich interlinking and hierarchical naming structure introduces a whole new set of requirements that bring solutions based on the file system of relational architectures to their knees. An XML-savvy object repository, designed to be embedded in XML applications of all types, or the operating system itself, is the only solution that provides the functionality and scalability required to drive the realization of this vision of a new generation of networked applications.