diff --git a/archiva-base/archiva-xml-tools/pom.xml b/archiva-base/archiva-xml-tools/pom.xml
index efa42d3f0..352f6891b 100644
--- a/archiva-base/archiva-xml-tools/pom.xml
+++ b/archiva-base/archiva-xml-tools/pom.xml
@@ -37,11 +37,27 @@
dom4j
dom4j
1.6.1
+
+
+ xom
+ xom
+
+
jaxen
jaxen
1.1
+
+
+ jdom
+ jdom
+
+
+ xom
+ xom
+
+
org.codehaus.plexus
diff --git a/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java b/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java
new file mode 100644
index 000000000..575d8e7bc
--- /dev/null
+++ b/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java
@@ -0,0 +1,50 @@
+package org.apache.maven.archiva.xml;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.dom4j.Document;
+import org.dom4j.io.OutputFormat;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * XMLWriter
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class XMLWriter
+{
+ public static void write( Document doc, Writer writer )
+ throws XMLException
+ {
+ try
+ {
+ OutputFormat outputFormat = OutputFormat.createPrettyPrint();
+ org.dom4j.io.XMLWriter xmlwriter = new org.dom4j.io.XMLWriter( writer, outputFormat );
+ xmlwriter.write( doc );
+ }
+ catch ( IOException e )
+ {
+ throw new XMLException( "Unable to write xml contents to writer: " + e.getMessage(), e );
+ }
+ }
+}
diff --git a/archiva-base/archiva-xml-tools/src/test/examples/prolog-with-utf8.xml b/archiva-base/archiva-xml-tools/src/test/examples/prolog-with-utf8.xml
index c1aa8f454..3bc319199 100644
--- a/archiva-base/archiva-xml-tools/src/test/examples/prolog-with-utf8.xml
+++ b/archiva-base/archiva-xml-tools/src/test/examples/prolog-with-utf8.xml
@@ -1,7 +1,8 @@
-
+
+
Trygve Laugstøl
The ∞ Archiva
-
\ No newline at end of file
+
diff --git a/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/XMLWriterTest.java b/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/XMLWriterTest.java
new file mode 100644
index 000000000..f8dcde2ab
--- /dev/null
+++ b/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/XMLWriterTest.java
@@ -0,0 +1,55 @@
+package org.apache.maven.archiva.xml;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.util.FileUtils;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import java.io.StringWriter;
+
+/**
+ * XMLWriterTest
+ *
+ * @author Joakim Erdfelt
+ * @version $Id$
+ */
+public class XMLWriterTest
+ extends AbstractArchivaXmlTestCase
+{
+ public void testWrite()
+ throws Exception
+ {
+ String expectedResults = FileUtils.fileRead( getExampleXml( "prolog-with-utf8.xml" ) );
+
+ Element basic = DocumentHelper.createElement( "basic" );
+ Document doc = DocumentHelper.createDocument( basic );
+
+ Element names = basic.addElement( "names" );
+ names.addElement( "name" ).setText( "Trygve Laugst\u00f8l" );
+ names.addElement( "name" ).setText( "The \u221e Archiva" );
+
+ StringWriter actual = new StringWriter();
+ XMLWriter.write( doc, actual );
+
+ assertEquals( "Comparision of contents:", expectedResults, actual.toString() );
+ }
+}