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_OPML).append(" version=\"1.0\">").append(lineEnding);
		
		buf.append("<").append(ELEMENT_HEAD).append(">").append(lineEnding);
		
		buf.append("<").append(ELEMENT_TITLE).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_PATH))).append("</").append(ELEMENT_TITLE).append(">").append(lineEnding); // We'll use path for the title since that is how our outliner difines window titles.
		buf.append("<").append(ELEMENT_DATE_CREATED).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_DATE_CREATED))).append("</").append(ELEMENT_DATE_CREATED).append(">").append(lineEnding);
		buf.append("<").append(ELEMENT_DATE_MODIFIED).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_DATE_MODIFIED))).append("</").append(ELEMENT_DATE_MODIFIED).append(">").append(lineEnding);
		buf.append("<").append(ELEMENT_OWNER_NAME).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_OWNER_NAME))).append("</").append(ELEMENT_OWNER_NAME).append(">").append(lineEnding);
		buf.append("<").append(ELEMENT_OWNER_EMAIL).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_OWNER_EMAIL))).append("</").append(ELEMENT_OWNER_EMAIL).append(">").append(lineEnding);
		buf.append("<").append(ELEMENT_EXPANSION_STATE).append(">").append(escapeXMLText(docInfo.getExpandedNodesStringShifted(1))).append("</").append(ELEMENT_EXPANSION_STATE).append(">").append(lineEnding);
		buf.append("<").append(ELEMENT_VERTICAL_SCROLL_STATE).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_VERTICAL_SCROLL_STATE))).append("</").append(ELEMENT_VERTICAL_SCROLL_STATE).append(">").append(lineEnding);
		buf.append("<").append(ELEMENT_WINDOW_TOP).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_WINDOW_TOP))).append("</").append(ELEMENT_WINDOW_TOP).append(">").append(lineEnding);
		buf.append("<").append(ELEMENT_WINDOW_LEFT).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_WINDOW_LEFT))).append("</").append(ELEMENT_WINDOW_LEFT).append(">").append(lineEnding);
		buf.append("<").append(ELEMENT_WINDOW_BOTTOM).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_WINDOW_BOTTOM))).append("</").append(ELEMENT_WINDOW_BOTTOM).append(">").append(lineEnding);
		buf.append("<").append(ELEMENT_WINDOW_RIGHT).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_WINDOW_RIGHT))).append("</").append(ELEMENT_WINDOW_RIGHT).append(">").append(lineEnding);
		
		buf.append("<").append(ELEMENT_APPLY_FONT_STYLE_FOR_COMMENTS).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_APPLY_FONT_STYLE_FOR_COMMENTS))).append("</").append(ELEMENT_APPLY_FONT_STYLE_FOR_COMMENTS).append(">").append(lineEnding);
		buf.append("<").append(ELEMENT_APPLY_FONT_STYLE_FOR_EDITABILITY).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_APPLY_FONT_STYLE_FOR_EDITABILITY))).append("</").append(ELEMENT_APPLY_FONT_STYLE_FOR_EDITABILITY).append(">").append(lineEnding);
		buf.append("<").append(ELEMENT_APPLY_FONT_STYLE_FOR_MOVEABILITY).append(">").append(escapeXMLText(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_APPLY_FONT_STYLE_FOR_MOVEABILITY))).append("</").append(ELEMENT_APPLY_FONT_STYLE_FOR_MOVEABILITY).append(">").append(lineEnding);
		
		buildDocumentAttributes(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_OPML).append(">").append(lineEnding);
		return buf;
	}