diff --git a/NOTICE.txt b/NOTICE.txt
index 9b71e46658..2ea45edfa2 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -195,3 +195,11 @@ can be obtained at:
* HOMEPAGE:
* http://logging.apache.org/log4j/
+This product optionally depends on 'Aalto XML', an ultra-high performance
+non-blocking XML processor, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.aalto-xml.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * http://wiki.fasterxml.com/AaltoHome
+
diff --git a/codec-xml/pom.xml b/codec-xml/pom.xml
new file mode 100644
index 0000000000..f3938758cc
--- /dev/null
+++ b/codec-xml/pom.xml
@@ -0,0 +1,48 @@
+
+
+
+
+ 4.0.0
+
+ io.netty
+ netty-parent
+ 4.1.0.Beta4-SNAPSHOT
+
+
+ netty-codec-xml
+ jar
+
+ Netty/Codec/XML
+
+
+
+ ${project.groupId}
+ netty-codec
+ ${project.version}
+
+
+ ${project.groupId}
+ netty-handler
+ ${project.version}
+
+
+ com.fasterxml
+ aalto-xml
+
+
+
+
diff --git a/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlAttribute.java b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlAttribute.java
new file mode 100644
index 0000000000..d40ce138c3
--- /dev/null
+++ b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlAttribute.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2014 The Netty Project
+ *
+ * The Netty Project 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.
+ */
+package io.netty.handler.codec.xml;
+
+
+/**
+ * XML attributes, it is part of {@link XmlElement}
+ */
+public class XmlAttribute {
+
+ private final String type;
+ private final String name;
+ private final String prefix;
+ private final String namespace;
+ private final String value;
+
+ public XmlAttribute(String type, String name, String prefix, String namespace, String value) {
+ this.type = type;
+ this.name = name;
+ this.prefix = prefix;
+ this.namespace = namespace;
+ this.value = value;
+ }
+
+ public String type() {
+ return type;
+ }
+
+ public String name() {
+ return name;
+ }
+
+ public String prefix() {
+ return prefix;
+ }
+
+ public String namespace() {
+ return namespace;
+ }
+
+ public String value() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) { return true; }
+ if (o == null || getClass() != o.getClass()) { return false; }
+
+ XmlAttribute that = (XmlAttribute) o;
+
+ if (!name.equals(that.name)) { return false; }
+ if (namespace != null ? !namespace.equals(that.namespace) : that.namespace != null) { return false; }
+ if (prefix != null ? !prefix.equals(that.prefix) : that.prefix != null) { return false; }
+ if (type != null ? !type.equals(that.type) : that.type != null) { return false; }
+ if (value != null ? !value.equals(that.value) : that.value != null) { return false; }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = type != null ? type.hashCode() : 0;
+ result = 31 * result + name.hashCode();
+ result = 31 * result + (prefix != null ? prefix.hashCode() : 0);
+ result = 31 * result + (namespace != null ? namespace.hashCode() : 0);
+ result = 31 * result + (value != null ? value.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "XmlAttribute{" +
+ "type='" + type + '\'' +
+ ", name='" + name + '\'' +
+ ", prefix='" + prefix + '\'' +
+ ", namespace='" + namespace + '\'' +
+ ", value='" + value + '\'' +
+ '}';
+ }
+}
diff --git a/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlCdata.java b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlCdata.java
new file mode 100644
index 0000000000..e1e96a8572
--- /dev/null
+++ b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlCdata.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2014 The Netty Project
+ *
+ * The Netty Project 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.
+ */
+package io.netty.handler.codec.xml;
+
+/**
+ * XML CDATA ...
+ */
+public class XmlCdata extends XmlContent {
+
+ public XmlCdata(String data) {
+ super(data);
+ }
+
+}
diff --git a/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlCharacters.java b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlCharacters.java
new file mode 100644
index 0000000000..f29a997b79
--- /dev/null
+++ b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlCharacters.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2014 The Netty Project
+ *
+ * The Netty Project 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.
+ */
+package io.netty.handler.codec.xml;
+
+/**
+ * XML characters, e.g. <test>characters</test>, but not CDATA.
+ */
+public class XmlCharacters extends XmlContent {
+
+ public XmlCharacters(String data) {
+ super(data);
+ }
+
+}
diff --git a/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlComment.java b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlComment.java
new file mode 100644
index 0000000000..d01da0d404
--- /dev/null
+++ b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlComment.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2014 The Netty Project
+ *
+ * The Netty Project 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.
+ */
+package io.netty.handler.codec.xml;
+
+/**
+ * XML Comment
+ */
+public class XmlComment extends XmlContent {
+
+ public XmlComment(String data) {
+ super(data);
+ }
+
+}
diff --git a/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlContent.java b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlContent.java
new file mode 100644
index 0000000000..a47df3312c
--- /dev/null
+++ b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlContent.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2014 The Netty Project
+ *
+ * The Netty Project 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.
+ */
+package io.netty.handler.codec.xml;
+
+/**
+ * XML Content is base class for XML CDATA, Comments, Characters and Space
+ */
+public abstract class XmlContent {
+
+ private final String data;
+
+ protected XmlContent(String data) {
+ this.data = data;
+ }
+
+ public String data() {
+ return data;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) { return true; }
+ if (o == null || getClass() != o.getClass()) { return false; }
+
+ XmlContent that = (XmlContent) o;
+
+ if (data != null ? !data.equals(that.data) : that.data != null) { return false; }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return data != null ? data.hashCode() : 0;
+ }
+
+ @Override
+ public String toString() {
+ return "XmlContent{" +
+ "data='" + data + '\'' +
+ '}';
+ }
+}
diff --git a/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlDTD.java b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlDTD.java
new file mode 100644
index 0000000000..754539b243
--- /dev/null
+++ b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlDTD.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2014 The Netty Project
+ *
+ * The Netty Project 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.
+ */
+package io.netty.handler.codec.xml;
+
+/**
+ * DTD (Document Type Definition)
+ */
+public class XmlDTD {
+
+ private final String text;
+
+ public XmlDTD(String text) {
+ this.text = text;
+ }
+
+ public String text() {
+ return text;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) { return true; }
+ if (o == null || getClass() != o.getClass()) { return false; }
+
+ XmlDTD xmlDTD = (XmlDTD) o;
+
+ if (text != null ? !text.equals(xmlDTD.text) : xmlDTD.text != null) { return false; }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return text != null ? text.hashCode() : 0;
+ }
+
+ @Override
+ public String toString() {
+ return "XmlDTD{" +
+ "text='" + text + '\'' +
+ '}';
+ }
+
+}
diff --git a/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlDecoder.java b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlDecoder.java
new file mode 100644
index 0000000000..a5add5de0d
--- /dev/null
+++ b/codec-xml/src/main/java/io/netty/handler/codec/xml/XmlDecoder.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2014 The Netty Project
+ *
+ * The Netty Project 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.
+ */
+package io.netty.handler.codec.xml;
+
+import com.fasterxml.aalto.AsyncInputFeeder;
+import com.fasterxml.aalto.AsyncXMLInputFactory;
+import com.fasterxml.aalto.AsyncXMLStreamReader;
+import com.fasterxml.aalto.stax.InputFactoryImpl;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import java.util.List;
+
+/**
+ * Async XML decoder based on Aalto XML parser.
+ *
+ * Parses the incoming data into one of XML messages defined in this package.
+ */
+
+public class XmlDecoder extends ByteToMessageDecoder {
+
+ private static final AsyncXMLInputFactory XML_INPUT_FACTORY = new InputFactoryImpl();
+ private static final XmlDocumentEnd XML_DOCUMENT_END = XmlDocumentEnd.INSTANCE;
+
+ private final AsyncXMLStreamReader streamReader = XML_INPUT_FACTORY.createAsyncXMLStreamReader();
+ private final AsyncInputFeeder streamFeeder = streamReader.getInputFeeder();
+
+ @Override
+ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List