Are you trying to take an XML document and CREATE a Schema that validates the document? If you're looking for a simple solution, many of the good XML IDE have a feature to load an instance document and generate a schema from that document.
Stylus Stuido and XML Spy come to mind. Be warned, the schemas that are generated from these automatically are usually poor schemas. If you don't have one of these IDEs, PM me, I might be able to help.
If you're looking for some kind of transformation to take an XML document and generate a schema file. You're going to need to define all the rules for the transformation in order to do that, but it can be done easily with xslt.
this is a lab sheet what i got in my class.. i have to use visual studio 2008. and i created it. but its hard to understand how it happened when creating into XSD.. if u want i can mail u the lab sheet..