Document (List<MimeTypeDescription> descriptions) { var ns = "http://www.freedesktop.org/standards/shared-mime-info"; var root = new Element("mime-info", ns); for (var description : descriptions) { var mimeType = new Element("mime-type", ns).setAttribute("type", description.type); mimeType.addContent(new Element("comment", ns).addContent(description.comment)); for (var pattern : description.globPatterns) { mimeType.addContent(new Element("glob", ns).setAttribute("pattern", pattern)); } root.addContent(mimeType); } return new Document(root); }