private void buildDocumentAttributes(JoeTree tree, String lineEnding, StringBuffer buf) {
		Iterator it = tree.getAttributeKeys();
		if (it != null) {
			while (it.hasNext()) {
				String key = (String) it.next();
				Object value = tree.getAttribute(key);
				boolean isReadOnly = tree.isReadOnly(key);
				
				buf.append("<").append(ELEMENT_DOCUMENT_ATTRIBUTE);
				buf.append(" ").append(ATTRIBUTE_KEY).append("=\"").append(escapeXMLAttribute(key)).append("\"");
				if (isReadOnly) {
					buf.append(" ").append(ATTRIBUTE_IS_READ_ONLY).append("=\"true\"");
				}
				buf.append(">");
				buf.append(escapeXMLText(value.toString()));
				buf.append("</").append(ELEMENT_DOCUMENT_ATTRIBUTE).append(">").append(lineEnding);
			}
		}
	}