There's a nifty online tool here: http://www.flame-ware.com/xml2xsd/
I've seen this referred to as "infering" an XSD from an XML document.
I guess there's problems with converting in this direction. If your document 'unicycle.xml' has one element <wheel> then the inferring logic will have no way of knowing that wheel should be a repeating element, and so 'car.xml' will not validate against the inferred XSD. Still, it's can be handy as a starting point when developing XSDs.
But did anyone create anything like this in java? My search is turning up a lot of .NET (C#) code.