/** * Generates an html tree representation of the component hierarchy having the root * designContext.getRootComponent(). The hierarchy is stored under <body> in the tree. The * generated tree represents a valid html document. * * @param designContext a DesignContext object specifying the root component * (designContext.getRootComponent()) of the hierarchy * @return an html tree representation of the component hierarchy */ private static Document createHtml(DesignContext designContext) { // Create the html tree skeleton. Document doc = new Document(""); DocumentType docType = new DocumentType("html", "", "", ""); doc.appendChild(docType); Element html = doc.createElement("html"); doc.appendChild(html); html.appendChild(doc.createElement("head")); Element body = doc.createElement("body"); html.appendChild(body); // Append the design under <body> in the html tree. createNode // creates the entire component hierarchy rooted at the // given root node. Component root = designContext.getRootComponent(); if (root != null) { Node rootNode = designContext.createElement(root); body.appendChild(rootNode); } designContext.writePackageMappings(doc); return doc; }