JavaPlugin.log(e);
throwWriteException(e); } catch (IOException e) { throwWriteException(e);
	public void saveToStream(OutputStream stream) throws IOException {		try {			DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();			DocumentBuilder builder= factory.newDocumentBuilder();					Document document= builder.newDocument();			Node root= document.createElement("templates"); // $NON-NLS-1$ //$NON-NLS-1$			document.appendChild(root);						for (int i= 0; i != fTemplates.size(); i++) {				Template template= (Template) fTemplates.get(i);								Node node= document.createElement("template"); // $NON-NLS-1$ //$NON-NLS-1$				root.appendChild(node);								NamedNodeMap attributes= node.getAttributes();								Attr name= document.createAttribute(NAME_ATTRIBUTE);				name.setValue(template.getName());				attributes.setNamedItem(name);					Attr description= document.createAttribute(DESCRIPTION_ATTRIBUTE);				description.setValue(template.getDescription());				attributes.setNamedItem(description);					Attr context= document.createAttribute(CONTEXT_ATTRIBUTE);				context.setValue(template.getContext());				attributes.setNamedItem(context);							Attr enabled= document.createAttribute(ENABLED_ATTRIBUTE);				enabled.setValue(template.isEnabled() ? "true" : "false"); // $NON-NLS-1$ // $NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-2$				attributes.setNamedItem(enabled);								Text pattern= document.createTextNode(template.getPattern());				node.appendChild(pattern);						}								OutputFormat format = new OutputFormat();			format.setPreserveSpace(true);			Serializer serializer = SerializerFactory.getSerializerFactory("xml").makeSerializer(stream, format); //$NON-NLS-1$			serializer.asDOMSerializer().serialize(document);					} catch (ParserConfigurationException e) {			JavaPlugin.log(e);		}			}