private static void writeHistory(Element element, String s, LinkedHashMap<String, HistoryElement> hst) {
        final Element historyElement = new Element(s);
        element.addContent(historyElement);

        for (String key : hst.keySet()) {
            final Element entryElement = new Element(HISTORY_ELEMENT);
            entryElement.setAttribute(EXPRESSION, key);
            historyElement.addContent(entryElement);

            final HistoryElement h = hst.get(key);
            for (Variable variable : h.variables) {
                final Element varElement = new Element(VARIABLE);
                varElement.setAttribute(NAME, variable.getName());
                varElement.setAttribute(EXPRESSION, variable.getExpression());
                entryElement.addContent(varElement);
            }

            for (Namespace namespace : h.namespaces) {
                final Element namespaceElement = new Element(NAMESPACE);
                namespaceElement.setAttribute(PREFIX, namespace.getPrefix());
                namespaceElement.setAttribute(URI, namespace.getUri());
                entryElement.addContent(namespaceElement);
            }
        }
    }
private static void writeHistory(Element element, String s, LinkedHashMap<String, HistoryElement> hst)