"; */ ?>

web 2.0

May 08

Generate XSD from XML

There are several tools out there to create (or to infer) an XSD schema from XML document. I liked trang command line tool the most. Found it first when reading about Spring web services in Spring in Action book (very good book btw).

Here are four simple steps how to create XSD from XML* using trang:

Step 1. Get trang

Download trang.zip from here (at the moment of writing “trang-20030619.zip”)

Step 2. Extract it

Use “unzip trang-version.zip”, or just winzip/winrar/7z etc.. if on windows

Step 3. Make an alias

This step is optional, but makes it extremely easy to run the tool with a single command. Make an alias to the “trang.jar” by (in my case Ubuntu/Linux) editing “~/.bashrc” and adding the following:

# execute trang.jar (create XSD from XMLs)
alias xml2xsd='java -jar ~/soft/utils/trang/trang-20030619/trang.jar'

above “~/soft/utils/trang” is the directory where “trang” was unzipped to.

Step 4. Create XSD from XML

Let’s look at the XML file we need an XSD for:

$ ls -l
total 4
-rw-r--r-- 1 user group 357 2008-05-28 15:38 holiday-request.xml
$ cat holiday-request.xml
<?xml version="1.0" encoding="UTF-8"?>
<holidayRequest xmlns="http://mycompany.com/hr/schemas">

now run the tool against it:

$ xml2xsd holiday-request.xml hr.xsd
$ cat hr.xsd
<?xml version=”1.0″ encoding=”UTF-8″?>
<xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema” elementFormDefault=”qualified” targetNamespace=”http://mycompany.com/hr/schemas” xmlns:schemas=”http://mycompany.com/hr/schemas”>
  <xs:element name=”HolidayRequest”>
        <xs:element ref=”schemas:Holiday”/>
        <xs:element ref=”schemas:Employee”/>
  <xs:element name=”Holiday”>
        <xs:element ref=”schemas:StartDate”/>
        <xs:element ref=”schemas:EndDate”/>
  <xs:element name=”StartDate” type=”xs:NMTOKEN”/>
  <xs:element name=”EndDate” type=”xs:NMTOKEN”/>
  <xs:element name=”Employee”>
        <xs:element ref=”schemas:Number”/>
        <xs:element ref=”schemas:FirstName”/>
        <xs:element ref=”schemas:LastName”/>
  <xs:element name=”Number” type=”xs:integer”/>
  <xs:element name=”FirstName” type=”xs:NCName”/>
  <xs:element name=”LastName” type=”xs:NCName”/>



* – NOTE: “trang” can create an XSD from multiple XML documents, not just one.

List of other tools to use as an alternative to trang:

XSD away, Good Luck!

Apr 08

Gmail is a Little Devil

Ok, so I travel a lot. Sometimes to places where when you say “Internet” people believe in it and bow, but as in any other religion, they have never seen the subject of believing…

So today I finally got to my Gmail, after a long and exotic trip. Logged in, and what do I see? Instead of: “Hey Buddy, welcome back!”, it says you have 666 lucky e-mails in your inbox:

gmail 666 - a little devil

Did not really know if that is a good thing or a sign that I should not go through my mail :)
Well, do not worry, dear puzzled reader, this story has a Hollywoodish happy ending – I went through pretty much all my mail, fell in love with it and we lived happily ever after…

Mar 08

Get Higher-Resolution YouTube Videos with a URL Hack

YouTube High Resolution URL HackYouTube announced in November that they would be testing out encoding videos at higher resolutions (and with higher-quality audio encoding). Now it appears that a small sampling of uploaded videos can already be seen at their higher resolutions, simply by adding a little tag to the end of the video’s URL. To get a noticeable bump in resolution on some clips, add &fmt=6 to the end of the address line. The trick, according to YouTube watchers, seems to work primarily with newer videos, and bumps the resolution from 320×240 to 448×336. Add &fmt=18 to the end of the URL, and you might get an MP4-encoded version, with better audio and a 480×360 resolution. Update: Now the Better YouTube Firefox extension includes this feature.

original source – “Google Systems
article source – “lifehacker.com

Feb 08

Discover Owners of SVCHOST.EXE

Microsoft Windows (any flavor) is known to be very secretive and dishonest when it comes to telling its user/client/owner what is taking up sooo much system resources, and answer the question “why is my Windows so slow?“.

If you take a closer look at your Windows system you will notice that many CPU cycles and megabytes of RAM belongs to the process with very non-descriptive name “svchost.exe“. You can go to windows task manager by pressing “Ctrl+Alt+Del” and choosing task manager (if it does not come up by itself), or by running “taskmgr” command in your run window “Start -> Run” (more about the second approach in this arcticle “Windows Commands: Think You Know It All !?). So here is an example of a Windows Task Manager:

windows task manager processes

(click on “Processes” tab to get to the same view)

This is a snapshot of a “clean” Windows that has just started with NO custom applications running (well besides “mspaint.exe” to get a snapshot, which is ultra small). And already you can see there are 6(!) “svchost.exe” processes that take up RAM and will take up a lot of CPU when you start your Internet Browser, e-mail client, MS Office, Games, etc…

But if you ask what these “svchost.exe” processes responsible for, who started them, and who is their owner, Windows will say: “You are an average Windows user, we exposed everything you need through window managers, if you are unhappy, well.. tough luck”. And that happens to most of people who use Windows, because most people who are technical enough will use something like Linux or if budget allows people would go for Mac.

So here is a simple howto, for all people who are still on Windows, on identifying and disabling owners of “svchost.exe”.

To see the owners follow these two simple steps:

  • Go to “Start->Run”
  • Type “cmd” and press “Enter”. Black command screen will pop up. (Don’t be afraid of it – it is your friend :) )
  • In this back command prompt (what people call it) type “tasklist /svc” and press “Enter”

You should see something similar to the picture below:

tasklist /svc - Discover owners of svchost.exe

Now you can actually see the “services” that are hidden behind this meaningless name “svchost.exe”. Well, that is one step forward, but now what?

Now you can go to Windows Service manager and read about each service that is using “svchost.exe”. Let’s do together:

  • Go to “Start->Run”
  • Type “services.mcs” and press “Enter”

windows start->run services.mcs

After you press “Enter”, you should see windows services manager:windows services manager

Browsing through the services you can read their description and decide whether or not you want the service to run.

There is another quicker way to enable/disable services, but without their descriptions:

  • Go to “Start->Run”
  • Type “msconfig” and press Enter

windows start->run msconfig

After pressing “Enter”, you should see “System Configuration Utility”:

msconfig -> System Configuration Utility

Click on “services” tab to get the above view. As you can see you can “check/uncheck” desired services to change their state from “Running” to “Stopped”. But if you unfamiliar with a particular service, read its description first in “windows services manager”, or google it, if it is not there.

Keep up a “clean” and fast Windows system, and good luck!

Jan 08

Make Internet Explorer Behave Like a Standard-Compliant Browser

Internet Explorer by W3 Standards

If you have ever done web development, especially web design, you know that almost 50% of all development time goes to make CSS work for all the browsers. And, of course, Internet Explorer is the most non-complaint browser out there. Not only that, but it also lacks backward compatibility – so some features that work in IE6, would either break or what they call it “work differently” in IE7 and of course work another way in IE5.

One way around that would be to write a custom Java Script redirector that would determine what browser the client uses and redirected to the correct CSS. Another one, is to write a custom JavaScript that actually implements the functionality of all different browsers and makes sure everything is W3 compliant no matter what browser the client uses.

The problem in a second approach is that usually developers tend to write that JavaScript file only for a limited set of features that their application (web site) uses, and hence their JavaScript files are hardly reusable by others.

However, recently one of my good friends and developers discovered an open source JavaScript library – ie7-js, which is hosted on code.google.com and has an MIT License. This 70Kb library implements all the W3 features, which means it is highly reusable, and it makes web development to be a much much easier task, since developers do not need to worry about cross browser (at least from IE perspective), as this library supports ALL versions of Internet Explorer (5.0, 6.0, 7.0, 8.0 +). Which makes it universal for any web development project.

Enjoy and reuse the cross-browser wisdom!