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,197 @@
+<!--
+  ~ 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.
+  -->
+
+<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>ContinuumDatabase</name>
+      <version>1.0.9+</version>
+      <fields>
+        <field>
+          <name>projectGroups</name>
+          <version>1.0.9+</version>
+          <association>
+            <type>ProjectGroup</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+      </fields>
+    </class>
+
+    <class>
+      <name>ProjectGroup</name>
+      <version>1.0.9+</version>
+      <fields>
+        <field>
+          <name>id</name>
+          <version>1.0.9+</version>
+          <required>true</required>
+          <type>int</type>
+          <identifier>true</identifier>
+        </field>
+        <field>
+          <name>groupId</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>name</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>description</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>projects</name>
+          <version>1.0.9+</version>
+          <association>
+            <type>Project</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+      </fields>
+    </class>
+
+    <class>
+      <name>Project</name>
+      <version>1.0.9+</version>
+      <fields>
+        <field>
+          <name>id</name>
+          <required>true</required>
+          <identifier>true</identifier>
+          <version>1.0.9+</version>
+          <type>int</type>
+        </field>
+        <field>
+          <name>groupId</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>artifactId</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>executorId</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>name</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>description</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>url</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>scmUrl</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>scmTag</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>scmUsername</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>scmPassword</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>scmUseCache</name>
+          <version>1.1.0+</version>
+          <type>boolean</type>
+          <defaultValue>false</defaultValue>
+        </field>
+        <field>
+          <name>version</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>state</name>
+          <version>1.0.9</version>
+          <type>int</type>
+          <defaultValue>1</defaultValue>
+        </field>
+        <field>
+          <name>oldState</name>
+          <version>1.0.9+</version>
+          <type>int</type>
+        </field>
+        <field>
+          <name>latestBuildId</name>
+          <version>1.0.9+</version>
+          <type>int</type>
+        </field>
+        <field>
+          <name>buildNumber</name>
+          <version>1.0.9+</version>
+          <type>int</type>
+        </field>
+        <field>
+          <name>workingDirectory</name>
+          <version>1.0.9+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>relativePath</name>
+          <version>1.1.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>projectGroup</name>
+          <version>1.0.9+</version>
+          <required>true</required>
+          <association xml.reference="true">
+            <type>ProjectGroup</type>
+          </association>
+        </field>
+      </fields>
+    </class>    
+  </classes>
+</model>
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,38 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<continuumDatabase>
+  <projectGroups>
+    <projectGroup>
+      <id>1</id>
+      <groupId>default</groupId>
+      <name>Default Project Group</name>
+      <description>Contains all projects that do not have a group of their own</description>
+    </projectGroup>
+    <projectGroup>
+      <id>6</id>
+      <groupId>com.exist.apps</groupId>
+      <name>Maven Quick Start Archetype</name>
+      <projects>
+        <project>
+          <id>1</id>
+          <groupId>com.exist.apps</groupId>
+          <artifactId>quickstart</artifactId>
+          <executorId>maven2</executorId>
+          <name>Maven Quick Start Archetype</name>
+          <url>http://stan.manila.exist.com</url>
+          <scmUrl>scm:svn:http://stan.manila.exist.com/repos/quickstart/trunk</scmUrl>
+          <version>3.12-SNAPSHOT</version>
+          <state>2</state>
+          <oldState>10</oldState>
+          <latestBuildId>1</latestBuildId>
+          <buildNumber>1</buildNumber>
+          <workingDirectory>1</workingDirectory>
+          <projectGroup id="6"></projectGroup>
+          <scmResult>
+            <success>true</success>
+            <commandLine>/bin/sh -c cd /home/marica/maestro/maestro-2.1.1/project-server/data/continuum/working-directory/1 &amp;&amp; svn --non-interactive update /home/marica/maestro/maestro-2.1.1/project-server/data/continuum/working-directory/1</commandLine>
+          </scmResult>
+        </project>
+      </projects>
+    </projectGroup>
+  </projectGroups>
+</continuumDatabase>
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,59 @@
+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.ContinuumDatabase;
+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
+        {
+            ContinuumDatabase model = modelReader.read( reader, false );
+
+            Assert.assertEquals( 2, model.getProjectGroups().size() );
+        }
+        catch ( XMLStreamException e )
+        {
+            Assert.fail( "Should not have obtained any exception" );
+        }
+    }
+}
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();

