public void convert(Root root) {

        try {

            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
            doc = docBuilder.newDocument();

            Element rootElement = doc.createElement(root.getLabel());
            doc.appendChild(rootElement);

            /* Put our RootUsedInEditingScreen attributes in the DOM root element */
            Attr attr = doc.createAttribute("image");
            attr.setValue(root.getImageName());
            rootElement.setAttributeNode(attr);

            attr = doc.createAttribute("direction");
            attr.setValue(root.getDirection());
            rootElement.setAttributeNode(attr);

            ArrayList<CompoundNode> blockList = (ArrayList)root.getChildren();
            if(blockList != null && blockList.size() > 0) {
                for(int i = 0 ; i < blockList.size();i++) {
                                /* Create an Element from each TextBlock or ImageBlock */
                    Element el;
                    if(blockList.get(i) instanceof ImageBlock)
                        el = getImageBlockElement(blockList.get(i));
                    else
                        el = getBlockElement(blockList.get(i));
                                /* Add Element to rootElement */
					if (! (blockList.get(i) instanceof PageNumberBlock))
							rootElement.appendChild(el);
                }
			}

			/* Create the Composed Block element and add it */
            Element cBlockElement = doc.createElement("ComposedBlock");
            ComposedBlock cBlockObject = new ComposedBlock();
            if (root.getPageNumberBlock() != null)
            	cBlockObject.addChild(root.getPageNumberBlock());
            else
            	return;
            attr = doc.createAttribute("type");
            attr.setValue(cBlockObject.getType());
            cBlockElement.setAttributeNode(attr);
            cBlockElement.appendChild(getBlockElement(cBlockObject.getBlock()));
            rootElement.appendChild(cBlockElement);
            
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(XMLWriter.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
        	// Flush the changes
        }
    }