Is it possible to obtain automatically (via a tool or a Java api) an
xslt file from the "A" and the "B"
xsd files, able to transform the xml from the "B" format to
the "A" format?
It's not possible to automate this process, but there are a number of tools
(Stylus Studio is one) that allow you to design an XSLT transformation
graphically, using the source and target schemas as your starting points. In
my experience such tools work reasonably well provided the source and target
schemas are very similar.