public void saveXml(OutputStream outputStream) throws EnrycherException {
		// create an empty XML document
		DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder docBuilder;
		try {
			docBuilder = docBuilderFactory.newDocumentBuilder();
		} catch (ParserConfigurationException e) {
			throw new EnrycherException(".", e);
		}
		org.w3c.dom.Document xmlDoc;
		xmlDoc = docBuilder.newDocument();		
		
		Element topElt = xmlDoc.createElement("item");
		topElt.setAttribute("id", id);
		
		// serialize meta-data
		Element metadataElt = xmlDoc.createElement("metadata");
		// save semantics
		Element semanticsElt = xmlDoc.createElement("semantics");
		saveAttributes(xmlDoc, semanticsElt, attributeV);
		metadataElt.appendChild(semanticsElt);
		// save pipeline
		Element pipelineElt = xmlDoc.createElement("pipeline");
		savePipeline(xmlDoc, pipelineElt, pipeline.getTools());
		metadataElt.appendChild(pipelineElt);
		// finish with meta-data
		topElt.appendChild(metadataElt);
		
		// serialize text
		Element textElt = xmlDoc.createElement("text");
		for (Paragraph para : paragraphV) {
			Element paraElt = xmlDoc.createElement(para.getTagName());
			saveParagraph(xmlDoc, para, paraElt);
			textElt.appendChild(paraElt);
		}
		topElt.appendChild(textElt);
		
		// serialize annotations
		Element annsElt = xmlDoc.createElement("annotations");
		for (Annotation ann : annotationH.values()) {
			Element annElt = xmlDoc.createElement("annotation");
			saveAnnotation(xmlDoc, ann, annElt);			
			annsElt.appendChild(annElt);
		}
		topElt.appendChild(annsElt);
		
		// serialize assertions
		Element assertionsElt = xmlDoc.createElement("assertions");
		for(Assertion assertion : assertionH.values()){
			Element assertionElt = xmlDoc.createElement("assertion");
			saveAssertion(xmlDoc, assertion, assertionElt);
			assertionsElt.appendChild(assertionElt);
		}
		topElt.appendChild(assertionsElt);
			
		// finish with the document
		xmlDoc.appendChild(topElt);
		
		// prepare serialization object
		TransformerFactory transFac = TransformerFactory.newInstance();
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6296446
		transFac.setAttribute("indent-number", new Integer(2));
		Transformer trans = null;
		try {
			trans = transFac.newTransformer();
		} catch (TransformerConfigurationException e) {
			throw new EnrycherException("Error creating Transformer.", e);
		}
		trans.setOutputProperty(OutputKeys.INDENT, "yes");
		// prepare input and output for serialization
	    DOMSource domSource = new DOMSource(xmlDoc);
		StreamResult streamResult = new StreamResult(outputStream);
		// do the serialization
		try {
			trans.transform(domSource, streamResult);
		} catch (TransformerException e) {
			throw new EnrycherException("Error serializing.", e);
		}
	}