Tuesday, May 26, 2009

Validate XML against XSD in C



The XML documents can reference schema documents that specify how the XML documents should be structured. The rules for validating the XML document is specified in the schema which use the extension .xsd For more information about W3C XML Schema click here

In this Tutorial I'll show how to use libxml2 to Validate XML documents.

Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform), it is free software available under the MIT License. XML itself is a meta language to design markup languages, i.e. text language where semantic and structure are added to the content using extra "markup" information enclosed between angle brackets. HTML is the most well-known markup language. Though the library is written in C a variety of language bindings make it available in other environments.

Libxml2 is known to be very portable, the library should build and work without serious troubles on a variety of systems (Linux, Unix, Windows, CygWin, MacOS, MacOS X, RISC Os, OS/2, VMS, QNX, MVS, ...)

Sample program in C to validate xml against xsd using libxml2

Environment & Settings:
* Install libxml2 2.6.32 binary [Installed by default in most of the Linux].

* Install libxml2-dev 2.6.32 package.

* IDE Eclipse CDT [GCC Compiler]

* Right click the project --> Properties --> C/C++ Build --> Settings

select Tool Settings --> GCC C Linker --> Libraries
Add "xml2"(without quotes) in Libraries

select GCC C Compiler --> Directories --> Include Paths
Add "/usr/include/libxml2" (without quotes)

* This sample program uses test.xml and test.xsd

Code: xmlvalidation.c


FYI

you can also validate XML against XSD using the following command in linux.

xmllint --noout --schema test.xsd test.xml

--
Sam

Tuesday, May 19, 2009

What Makes The Difference?


[click to view larger image]

Ever heard the story of the giant ship engine that failed?

The ship’s owners tried one expert after another, but none of them could figure but how to fix the engine. Then they brought in an old man who had been fixing ships since he was a youngster. He carried a large bag of tools with him, and when he arrived, he immediately went to work. He inspected the engine very carefully, top to bottom.

Two of the ship’s owners were there, watching this man, hoping he would know what to do. After looking things over, the old man reached into his bag and pulled out a small hammer. He gently tapped something. Instantly, the engine lurched into life. He carefully put his hammer away.

The engine was fixed!


A week later, the owners received a bill from the old man for ten thousand dollars.

”What?!” the owners exclaimed.

“He hardly did anything!”

So they wrote the old man a note saying, “Please send us an itemized bill”

The man sent a bill that read:

Tapping with a hammer ……………………. $ 2.00
Knowing where to tap ………………………. $ 9998.00

Effort is important, but knowing where to make an effort in your life makes all the difference.

Source: Inspirational

--
Sam

Print Online Pages | Easy Print | Custom Online Pages Print


[click to view larger image]


Ever reading a or online news article and want to print it out, but don’t want the sidebar and other graphics to waste your ink? A lot of sites aren’t particularly print friendly and perhaps don’t make this process as easy as it could be.

Enter PrintFriendly, a new site that simply lets you enter the URL of a webpage and get a printable version: just the content and inline images, in a very readable font. If you want, you can go one step further and remove the images from the post. You can also download the content as a PDF. Neat!

It doesn’t work perfectly: sites that have in-text widgets don’t convert particularly well. PrintFriendly could compensate for these issues by allowing you to edit the document before printing. Nonetheless, it’s a handy tool to have at your fingertips should you ever need a quick printout without wasting ink.

Source: http://www.printfriendly.com/

--
Sam

Broad Mind


[click to view larger image]

Once an unhappy young man came to an old master and told he was very sad and asked for a solution.


The old Master instructed the unhappy young man to put a handful of salt in a glass of water and then to drink it. “How does it taste?” the Master asked. “Awful,” spat the apprentice.

The Master chuckled and then asked the young man to take another handful of salt and put it in the lake.

The two walked in silence to the nearby lake and when the apprentice swirled his handful of salt into the lake, the old man said, “Now drink from the lake.”

As the water dripped down the young man’s chin, the Master asked, “How does it taste?” “Good!” remarked the apprentice.

“Do you taste the salt?” asked the Master. “No,” said the young man. The Master sat beside this troubled young man, took his hands, and said,


The pain of life is pure salt; no more, no less. The amount of pain in life remains the same, exactly the same. But the amount we taste the ‘pain’ depends on the container we put it into. So when you are in pain, the only thing you can do is to enlarge your sense of things..

Stop being a glass. Become a lake

Broader Mindset will solve most of the problems we face. So don’t allow problem to grow broader than your mind.


Source: Inspirational

--
Sam

Astronomers Compile Most Detailed Map of Nearby Universe


[click to view larger image]


A new detailed map of the nearby Universe reveals not only where local galaxies are currently, but where they are heading, how fast and why. “It’s like taking a snapshot of wildebeest on the African plain,” said Dr. Heath Jones of the Anglo-Australian Observatory (AAO), lead scientist for the Six-Degree Field Galaxy Survey (6dFGS), the most detailed survey of nearby galaxies to date. “We can tell which waterholes they’re heading to, and how fast they’re traveling.” it has recorded the positions of more than 110,000 galaxies over more than 80% of the Southern sky, out to about two thousand million light-years from Earth, Galaxies are tugged around by each other’s gravity.

By measuring the galaxies’ movements, the researchers were able to map the gravitational forces at work in the local Universe, and so show how matter, both seen and unseen, is distributed. Giant superclusters of galaxies are huge concentrations of mass, but they can’t be weighed accurately by looking at their light alone.

“Light can be obscured, but you can’t hide gravity,” said Dr. Jones.


The survey shows strings and clusters of nearby galaxies on large scales in unprecedented detail, and has revealed more than 500 voids—”empty” areas of space with no galaxies. The special aspect of this survey is that it will let the researchers disentangle two causes of galaxy movements. As well as being pulled on by gravity, galaxies also ride along with the overall expansion of the Universe. For about 10% of their galaxies, the 6dFGS researchers will tease apart these two velocity components: the one associated with the Universe’s expansion, and the one representing a galaxy’s individual, “peculiar”, motion.

Source: Universe Today

--
Sam

Monday, May 11, 2009

God Exists


[click to view larger image]

A man went to a barbershop to have his hair cut and his beard trimmed. As the barber began to work, they began to have a good conversation. They talked about so many things and various subjects. When they eventually touched on the subject of God, the barber said, “I don’t believe that God exists.”

“Why do you say that?” asked the customer.

“Well, you just have to go out in the street to realize that God doesn’t exist. Tell me, if God exists, would there be so many sick people? Would there be abandoned children? If God existed, there would be neither suffering nor pain. I can’t imagine a loving God who would allow all of these things.”

The customer thought for a moment, but didn’t respond because he didn’t want to start an argument. The barber finished his job and the customer left the shop.


Just after he left the barbershop, he saw a man in the street with long, stringy, dirty hair and an untrimmed beard. He looked dirty and unkempt. The customer turned back and entered the barber shop again and he said to the barber, “You know what? Barbers do not exist.”

“How can you say that?” asked the surprised barber. “I am here, and I am a barber. And I just worked on you!”

“No!” the customer exclaimed. “Barbers don’t exist because if they did, there would be no people with dirty long hair and untrimmed beards, like that man outside.”

“Ah, but barbers DO exist! That’s what happens when people do not come to me.”

“Exactly!” affirmed the customer. “That’s the point! God, too, DOES exist! That’s what happens when people do not go to Him and don’t look to Him for help. That’s why there’s so much pain and suffering in the world.”

Source: Fr Eugene Lobo SJ

--
Sam

Tamil News Live Online HD

Tamil News Live Online HD