Index: src/test/java/org/codehaus/modello/generator/xml/stax/StaxGeneratorUnrecognizedTagTest.java
===================================================================
--- src/test/java/org/codehaus/modello/generator/xml/stax/StaxGeneratorUnrecognizedTagTest.java	(revision 0)
+++ src/test/java/org/codehaus/modello/generator/xml/stax/StaxGeneratorUnrecognizedTagTest.java	(revision 0)
@@ -0,0 +1,22 @@
+package org.codehaus.modello.generator.xml.stax;
+
+import org.codehaus.modello.model.Model;
+import org.codehaus.plexus.util.ReaderFactory;
+
+public class StaxGeneratorUnrecognizedTagTest
+    extends AbstractStaxGeneratorTestCase
+{
+    public StaxGeneratorUnrecognizedTagTest()
+    {
+        super( "stax-unrecognized-tag" );
+    }
+
+    public void testStaxReaderStrictUnrecognizedTag()
+        throws Throwable
+    {
+        Model model =
+            modello.loadModel( ReaderFactory.newXmlReader( getTestFile( "src/test/resources/unrecognized-tag.mdo" ) ) );
+
+        verifyModel( model, "org.codehaus.modello.generator.xml.stax.StaxVerifierUnrecognizedTag" );
+    }
+}
Index: src/test/resources/unrecognized-tag.mdo
===================================================================
--- src/test/resources/unrecognized-tag.mdo	(revision 0)
+++ src/test/resources/unrecognized-tag.mdo	(revision 0)
@@ -0,0 +1,54 @@
+<!--
+  ~ Copyright (c) 2006, Codehaus.org
+  ~
+  ~ Permission is hereby granted, free of charge, to any person obtaining a copy of
+  ~ this software and associated documentation files (the "Software"), to deal in
+  ~ the Software without restriction, including without limitation the rights to
+  ~ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+  ~ of the Software, and to permit persons to whom the Software is furnished to do
+  ~ so, subject to the following conditions:
+  ~
+  ~ The above copyright notice and this permission notice shall be included in all
+  ~ copies or substantial portions of the Software.
+  ~
+  ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+  ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+  ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+  ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+  ~ SOFTWARE.
+  -->
+
+<model>
+  <id>maven</id>
+  <name>UnrecognizedTag</name>
+  <defaults>
+    <default>
+      <key>package</key>
+      <value>org.codehaus.modello.test.model.ut</value>
+    </default>
+  </defaults>
+  <classes>
+    <class rootElement="true">
+      <name>Model</name>
+      <version>3.0.0+</version>
+      <fields>
+        <field>
+          <name>name</name>
+          <version>3.0.0+</version>
+          <required>true</required>
+          <description>Human readable name of the project.</description>
+          <type>String</type>
+        </field>
+        <field>
+          <name>description</name>
+          <version>3.0.0+</version>
+          <required>true</required>
+          <description>Human readable description of the project.</description>
+          <type>String</type>
+        </field>
+      </fields>
+    </class>
+  </classes>
+</model>
\ No newline at end of file
Index: src/test/verifiers/stax-unrecognized-tag/unrecognized-tag.xml
===================================================================
--- src/test/verifiers/stax-unrecognized-tag/unrecognized-tag.xml	(revision 0)
+++ src/test/verifiers/stax-unrecognized-tag/unrecognized-tag.xml	(revision 0)
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<model>
+  <description>Something out of place.</description>
+  <name>Maven</name>
+  <unrecognizedTag>
+    <modelVersion>4.0.0</modelVersion>
+  </unrecognizedTag>
+</model>
\ No newline at end of file
Index: src/test/verifiers/stax-unrecognized-tag/StaxVerifierUnrecognizedTag.java
===================================================================
--- src/test/verifiers/stax-unrecognized-tag/StaxVerifierUnrecognizedTag.java	(revision 0)
+++ src/test/verifiers/stax-unrecognized-tag/StaxVerifierUnrecognizedTag.java	(revision 0)
@@ -0,0 +1,72 @@
+package org.codehaus.modello.generator.xml.stax;
+
+/*
+ * Copyright (c) 2004, Codehaus.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import junit.framework.Assert;
+import org.codehaus.modello.test.model.ut.Model;
+import org.codehaus.modello.test.model.ut.io.stax.UnrecognizedTagStaxReader;
+import org.codehaus.modello.verifier.Verifier;
+import org.codehaus.plexus.util.ReaderFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import javax.xml.stream.XMLStreamException;
+
+public class StaxVerifierUnrecognizedTag
+    extends Verifier
+{
+    public void verify()
+        throws IOException, XMLStreamException
+    {
+        File file = new File( "src/test/verifiers/stax-unrecognized-tag/unrecognized-tag.xml" );
+
+        UnrecognizedTagStaxReader modelReader = new UnrecognizedTagStaxReader();
+
+        Reader reader = ReaderFactory.newXmlReader( file );
+
+        try
+        {
+            Model model = modelReader.read( reader, false );
+
+            Assert.assertEquals( "Maven", model.getName() );
+            Assert.assertEquals( "Something out of place.", model.getDescription() );
+        }
+        catch ( XMLStreamException e )
+        {
+            Assert.fail( "Should not have obtained any exception" );
+        }
+
+        try
+        {
+            reader = ReaderFactory.newXmlReader( file );
+            modelReader.read( reader );
+
+            Assert.fail( "Should have obtained an unrecognised tag error" );
+        }
+        catch ( XMLStreamException e )
+        {
+            Assert.assertTrue( e.getMessage().contains( "Unrecognised tag: 'unrecognizedTag'" ) );
+        }
+    }
+}
Index: src/main/java/org/codehaus/modello/plugin/stax/StaxReaderGenerator.java
===================================================================
--- src/main/java/org/codehaus/modello/plugin/stax/StaxReaderGenerator.java	(revision 1300)
+++ src/main/java/org/codehaus/modello/plugin/stax/StaxReaderGenerator.java	(working copy)
@@ -726,6 +726,35 @@
                                 + "\"'\", xmlStreamReader.getLocation() );" );
                 sc.add( "}" );
 
+                sc.add( "else" );
+
+                sc.add( "{" );
+
+                sc.addIndented( "int unrecognizedTagCtr = 1;" );
+                sc.addIndented( "while( unrecognizedTagCtr != 0 )" );
+
+                sc.indent();
+                sc.add( "{" );
+
+                sc.addIndented( "xmlStreamReader.next();" );
+                sc.addIndented( "if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )" );
+
+                sc.indent();
+                sc.add( "{" );
+                sc.addIndented( "unrecognizedTagCtr++;" );
+                sc.add( "}" );
+
+                sc.add( "else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )" );
+                sc.add( "{" );
+                sc.addIndented( "unrecognizedTagCtr--;" );
+                sc.add( "}" );
+
+                sc.unindent();
+                sc.add( "}" );
+
+                sc.unindent();
+                sc.add( "}" );
+
                 if ( addElse )
                 {
                     sc.unindent();
@@ -751,6 +780,30 @@
                                 + "\"'\", xmlStreamReader.getLocation() );" );
                 sc.add( "}" );
 
+                sc.add( "else" );
+
+                sc.add( "{" );
+
+                sc.addIndented( "int unrecognizedTagCtr = 1;" );
+                sc.addIndented( "while( unrecognizedTagCtr != 0 )" );
+
+                sc.indent();
+                sc.add( "{" );
+
+                sc.addIndented( "xmlStreamReader.next();" );
+                sc.addIndented( "if ( xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT )" );
+
+                sc.indent();
+
+                sc.add( "{" );
+                sc.addIndented( "unrecognizedTagCtr++;" );
+                sc.add( "}" );
+
+                sc.add( "else if ( xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT )" );
+                sc.add( "{" );
+                sc.addIndented( "unrecognizedTagCtr--;" );
+                sc.add( "}" );
+
                 sc.unindent();
                 sc.add( "}" );
 
@@ -759,6 +812,12 @@
 
                 sc.unindent();
                 sc.add( "}" );
+
+                sc.unindent();
+                sc.add( "}" );
+
+                sc.unindent();
+                sc.add( "}" );
             }
 
             sc.unindent();

