private StringBuffer prepareFile(JoeTree tree, DocumentInfo docInfo) {
		String lineEnding = PlatformCompatibility.platformToLineEnding(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_LINE_ENDING));
		
		StringBuffer buf = new StringBuffer();
		
		buf.append("<?xml version=\"1.0\" encoding=\"").append(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_ENCODING_TYPE)).append("\"?>").append(lineEnding);
		buf.append("<").append(ELEMENT_OML).append(" ").append(ATTRIBUTE_VERSION).append("=\"1.0\">").append(lineEnding);
		
		buf.append("<").append(ELEMENT_HEAD).append(">").append(lineEnding);
		
			appendMetadataElement(buf, TITLE, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_PATH), lineEnding);
			appendMetadataElement(buf, DATE_CREATED, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_DATE_CREATED), lineEnding);
			appendMetadataElement(buf, DATE_MODIFIED, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_DATE_MODIFIED), lineEnding);
			appendMetadataElement(buf, OWNER_NAME, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_OWNER_NAME), lineEnding);
			appendMetadataElement(buf, OWNER_EMAIL, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_OWNER_EMAIL), lineEnding);
			appendMetadataElement(buf, EXPANSION_STATE, docInfo.getExpandedNodesStringShifted(1), lineEnding);
			appendMetadataElement(buf, VERTICAL_SCROLL_STATE, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_VERTICAL_SCROLL_STATE), lineEnding);
			appendMetadataElement(buf, WINDOW_TOP, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_WINDOW_TOP), lineEnding);
			appendMetadataElement(buf, WINDOW_LEFT, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_WINDOW_LEFT), lineEnding);
			appendMetadataElement(buf, WINDOW_BOTTOM, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_WINDOW_BOTTOM), lineEnding);
			appendMetadataElement(buf, WINDOW_RIGHT, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_WINDOW_RIGHT), lineEnding);
			
			appendMetadataElement(buf, APPLY_FONT_STYLE_FOR_COMMENTS, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_APPLY_FONT_STYLE_FOR_COMMENTS), lineEnding);
			appendMetadataElement(buf, APPLY_FONT_STYLE_FOR_EDITABILITY, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_APPLY_FONT_STYLE_FOR_EDITABILITY), lineEnding);
			appendMetadataElement(buf, APPLY_FONT_STYLE_FOR_MOVEABILITY, PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_APPLY_FONT_STYLE_FOR_MOVEABILITY), lineEnding);
			
			buildMetadataElements(tree, lineEnding, buf);
		
		buf.append("</").append(ELEMENT_HEAD).append(">").append(lineEnding);
		
		buf.append("<").append(ELEMENT_BODY).append(">").append(lineEnding);
			Node node = tree.getRootNode();
			for (int i = 0, limit = node.numOfChildren(); i < limit; i++) {
				buildOutlineElement(node.getChild(i), lineEnding, buf);
			}
		buf.append("</").append(ELEMENT_BODY).append(">").append(lineEnding);
		
		buf.append("</").append(ELEMENT_OML).append(">").append(lineEnding);
		return buf;
	}