public void transform(Document document) {
final Element frames = allocateElement();
// This visitor generates the grid/cell instance hierarchy from the
// pseudo markup
final DOMVisitor gridGenerator = new GridGenerator(frames, this);
// Generate the hierarchy of Grid/Cell instances needed, hung off
// this fake cell instance
gridGenerator.visit(document);
// Calculate all the dimensions; this aligns rows and columns in
// size as needed within grids
calculateDimensions();
// Calculate the positions of the panes and grid frames
calculatePosition(1, 1);
// Convert the pseudo markup into real VDXML
convertToVdxml(frames);
// This visitor makes sure that any text blocks found inside a
// form are moved out to immediately before the form. It also
// ensures that the HELP_ZONE_ELEMENT appears before any
// HELP_ELEMENTs. It also inserts next and previous links based on
// pseudo values.
// This works on the final real VDXML markup
DOMVisitor generalFixer = new GeneralFixerVisitor(frames);
// Finally ensure that forms don't contain any text blocks and the
// help zone is before any content that could contain help elements
generalFixer.visit(document);
}