void appendChild(XML xml) {
		if (xml.isAttribute()) {
			if (attributes == null) attributes = new TreeMap<String, XML>();
			attributes.put(xml.getNodeName(), xml);
		} else {
			if (nodeValue != null) throw new IllegalStateException("only leaf node can contain text");
			if (elements == null) {
				elements = new TreeMap<String, XML>();
				elementsOrder = new ArrayList<XML>();
			}
			elementsOrder.add(xml);
			String qname = xml.getNodeName();
			XML child = elements.get(qname);
			if (child == null) {
				elements.put(qname, xml);
			} else if (child.getNodeType() == NodeType.ELEMENT_LIST) {
				((XMLList) child).appendToList(xml);
			} else {
				XMLList xmllist = new XMLList();
				xmllist.appendToList(child);
				xmllist.appendToList(xml);
				elements.put(qname, xmllist);
			}
		}
	}