public void run() throws TemplateException {
        try {
	        // create html document
	        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
	        DocumentBuilder docBuilder;
	        docBuilder = docBuilderFactory.newDocumentBuilder();
	        template.setHtml(docBuilder.newDocument());
	        
            // add html node
            Element htmlNode = template.getHtml().createElement("html");
            template.getHtml().appendChild(htmlNode);
            // add head node
            tagHead = template.getHtml().createElement("head");
            htmlNode.appendChild(tagHead);
            // add style
            Element tagLink = template.getHtml().createElement("link");
            tagLink.setAttribute("rel", "stylesheet");
            tagLink.setAttribute("type", "text/css");
            tagLink.setAttribute("href", "styles.css");
            tagHead.appendChild(tagLink);
            // add body node
            tagBody = template.getHtml().createElement("body");
            htmlNode.appendChild(tagBody);
            // create template attributes
            tagScript = template.getHtml().createElement("script");
            tagScript.setAttribute("type", "text/xml");
            tagTemplateAttributes = template.getHtml().createElement("template_attributes");
            tagScript.appendChild(tagTemplateAttributes);
            // set obvious attributes
            Element topLevelNode = template.getHtml().createElement("top-level-flag");
            topLevelNode.setTextContent("true");
            tagTemplateAttributes.appendChild(topLevelNode);
            Element statusNode = template.getHtml().createElement("status");
            statusNode.setTextContent("active");
            tagTemplateAttributes.appendChild(statusNode);
            tagCodedContent = template.getHtml().createElement("coded_content");
            tagTemplateAttributes.appendChild(tagCodedContent);
            
            // add document attributes
            // title element
            Element titleNode = template.getHtml().createElement("title");
            titleNode.setTextContent(template.getTitle());
            tagHead.appendChild(titleNode);
            // meta charset
            Element metacharNode = template.getHtml().createElement("meta");
            metacharNode.setAttribute("charset", "UTF-8");
            tagHead.appendChild(metacharNode);
            // dc attributes
            for (DCAttribute dc : template.getDcAttributes()) {
	            Element metatitleNode = template.getHtml().createElement("meta");
	            metatitleNode.setAttribute("name", dc.getName());
	            metatitleNode.setAttribute("content", dc.getValue());
	            tagHead.appendChild(metatitleNode);
            }
            
            // add terms
            for (Term term : template.getTerms()) {
	            // base
	            Element termNode = template.getHtml().createElement("term");
	            termNode.setAttribute("type", term.getType());
	            tagTemplateAttributes.appendChild(termNode);
	            // meaning
	            Element meaningNode = template.getHtml().createElement("code_meaning");
	            meaningNode.setTextContent(term.getName());
	            termNode.appendChild(meaningNode);
	            // / value
	            Element valueNode = template.getHtml().createElement("code_value");
	            valueNode.setTextContent(term.getValue());
	            termNode.appendChild(valueNode);
	            // codeset
	            Element codesetNode = template.getHtml().createElement("coding_scheme_designator");
	            codesetNode.setTextContent(term.getCodeset());
	            termNode.appendChild(codesetNode);
            }
            
            // add terms
            for (CodedContentCollection ccc : template.getCodedContentSet()) {
                // base node to add
                Element entryNode = template.getHtml().createElement("entry");
                entryNode.setAttribute("ORIGTXT", ccc.getId());
                tagCodedContent.appendChild(entryNode);
                // iterate through items
                for (CodedContent cc : ccc.getContent()) {
                    // base entry
                    Element termNode = template.getHtml().createElement("term");
                    entryNode.appendChild(termNode);
                    // meaning
                    Element meaningNode = template.getHtml().createElement("code_meaning");
                    meaningNode.setTextContent(cc.getName());
                    termNode.appendChild(meaningNode);
                    // / value
                    Element valueNode = template.getHtml().createElement("code_value");
                    valueNode.setTextContent(cc.getValue());
                    termNode.appendChild(valueNode);
                    // codeset
                    Element codesetNode = template.getHtml().createElement("coding_scheme_designator");
                    codesetNode.setTextContent(cc.getCodeset());
                    termNode.appendChild(codesetNode);
                }
            }
            
            // add comments
            for (String message : template.getMessages()) {
                Comment comment = template.getHtml().createComment(message);
                tagHead.appendChild(comment);
            }
	        
            // do some stuff
            template.getBody().render(template.getHtml(), tagBody);
            
            // then do?
            tagHead.appendChild(tagScript);
            
            
        }
        catch (ParserConfigurationException e) {
            throw new TemplateException("ParserConfigurationException", e);
        }
        
	}