- valid.c: removed a state explosion exhibited by RSS
- test/valid/rss.xml result/valid/rss.xml*: added the testcase
  from bug #51872
Daniel
diff --git a/ChangeLog b/ChangeLog
index 9d557c0..42b3b08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Apr 20 15:46:04 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+	* valid.c: removed a state explosion exhibited by RSS
+	* test/valid/rss.xml result/valid/rss.xml*: added the testcase
+	  from bug #51872
+
 Fri Apr 20 14:52:44 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
 	* valid.[ch] tree.h: worked *hard* to get non-determinist content
diff --git a/result/valid/rss.xml b/result/valid/rss.xml
new file mode 100644
index 0000000..ee5145f
--- /dev/null
+++ b/result/valid/rss.xml
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE rss [
+<!--
+
+  Rich Site Summary (RSS) 0.91 official DTD, proposed.
+  
+  RSS is an XML vocabulary for describing
+  metadata about websites, and enabling the display of
+  "channels" on the "My Netscape" website.
+  
+  RSS Info can be found at http://my.netscape.com/publish/
+  XML Info can be found at http://www.w3.org/XML/ 
+  
+  copyright Netscape Communications, 1999
+
+  Dan Libby - danda@netscape.com
+  
+  Based on RSS DTD originally created by
+  Lars Marius Garshol - larsga@ifi.uio.no.
+  $Id: rss-0.91.dtd,v 1.1 1999/07/25 07:59:31 danda Exp $
+  
+--><!ELEMENT rss (channel)>
+<!ATTLIST rss version CDATA #REQUIRED>
+<!-- must be "0.91"> --><!ELEMENT channel (title | description | link | language | item+ | rating? | image? | textinput? | copyright? | pubDate? | lastBuildDate? | docs? | managingEditor? | webMaster? | skipHours? | skipDays?)*>
+<!ELEMENT title (#PCDATA)>
+<!ELEMENT description (#PCDATA)>
+<!ELEMENT link (#PCDATA)>
+<!ELEMENT image (title | url | link | width? | height? | description?)*>
+<!ELEMENT url (#PCDATA)>
+<!ELEMENT item (title | link | description)*>
+<!ELEMENT textinput (title | description | name | link)*>
+<!ELEMENT name (#PCDATA)>
+<!ELEMENT rating (#PCDATA)>
+<!ELEMENT language (#PCDATA)>
+<!ELEMENT width (#PCDATA)>
+<!ELEMENT height (#PCDATA)>
+<!ELEMENT copyright (#PCDATA)>
+<!ELEMENT pubDate (#PCDATA)>
+<!ELEMENT lastBuildDate (#PCDATA)>
+<!ELEMENT docs (#PCDATA)>
+<!ELEMENT managingEditor (#PCDATA)>
+<!ELEMENT webMaster (#PCDATA)>
+<!ELEMENT hour (#PCDATA)>
+<!ELEMENT day (#PCDATA)>
+<!ELEMENT skipHours (hour)+>
+<!ELEMENT skipDays (day)+>
+<!--
+     Copied from HTML 3.2 DTD, with modifications (removed CDATA)
+     http://www.w3.org/TR/REC-html32.html#dtd
+     =============== BEGIN ===================
+--><!-- 
+     Character Entities for ISO Latin-1
+     
+     (C) International Organization for Standardization 1986
+     Permission to copy in any form is granted for use with
+     conforming SGML systems and applications as defined in
+     ISO 8879, provided this notice is included in all copies.
+     This has been extended for use with HTML to cover the full
+     set of codes in the range 160-255 decimal.
+--><!-- Character entity set. Typical invocation:
+     <!ENTITY % ISOlat1 PUBLIC
+       "ISO 8879-1986//ENTITIES Added Latin 1//EN//HTML">
+     %ISOlat1;
+--><!ENTITY nbsp "&#160;">
+<!-- no-break space --><!ENTITY iexcl "&#161;">
+<!-- inverted exclamation mark --><!ENTITY cent "&#162;">
+<!-- cent sign --><!ENTITY pound "&#163;">
+<!-- pound sterling sign --><!ENTITY curren "&#164;">
+<!-- general currency sign --><!ENTITY yen "&#165;">
+<!-- yen sign --><!ENTITY brvbar "&#166;">
+<!-- broken (vertical) bar --><!ENTITY sect "&#167;">
+<!-- section sign --><!ENTITY uml "&#168;">
+<!-- umlaut (dieresis) --><!ENTITY copy "&#169;">
+<!-- copyright sign --><!ENTITY ordf "&#170;">
+<!-- ordinal indicator, feminine --><!ENTITY laquo "&#171;">
+<!-- angle quotation mark, left --><!ENTITY not "&#172;">
+<!-- not sign --><!ENTITY shy "&#173;">
+<!-- soft hyphen --><!ENTITY reg "&#174;">
+<!-- registered sign --><!ENTITY macr "&#175;">
+<!-- macron --><!ENTITY deg "&#176;">
+<!-- degree sign --><!ENTITY plusmn "&#177;">
+<!-- plus-or-minus sign --><!ENTITY sup2 "&#178;">
+<!-- superscript two --><!ENTITY sup3 "&#179;">
+<!-- superscript three --><!ENTITY acute "&#180;">
+<!-- acute accent --><!ENTITY micro "&#181;">
+<!-- micro sign --><!ENTITY para "&#182;">
+<!-- pilcrow (paragraph sign) --><!ENTITY middot "&#183;">
+<!-- middle dot --><!ENTITY cedil "&#184;">
+<!-- cedilla --><!ENTITY sup1 "&#185;">
+<!-- superscript one --><!ENTITY ordm "&#186;">
+<!-- ordinal indicator, masculine --><!ENTITY raquo "&#187;">
+<!-- angle quotation mark, right --><!ENTITY frac14 "&#188;">
+<!-- fraction one-quarter --><!ENTITY frac12 "&#189;">
+<!-- fraction one-half --><!ENTITY frac34 "&#190;">
+<!-- fraction three-quarters --><!ENTITY iquest "&#191;">
+<!-- inverted question mark --><!ENTITY Agrave "&#192;">
+<!-- capital A, grave accent --><!ENTITY Aacute "&#193;">
+<!-- capital A, acute accent --><!ENTITY Acirc "&#194;">
+<!-- capital A, circumflex accent --><!ENTITY Atilde "&#195;">
+<!-- capital A, tilde --><!ENTITY Auml "&#196;">
+<!-- capital A, dieresis or umlaut mark --><!ENTITY Aring "&#197;">
+<!-- capital A, ring --><!ENTITY AElig "&#198;">
+<!-- capital AE diphthong (ligature) --><!ENTITY Ccedil "&#199;">
+<!-- capital C, cedilla --><!ENTITY Egrave "&#200;">
+<!-- capital E, grave accent --><!ENTITY Eacute "&#201;">
+<!-- capital E, acute accent --><!ENTITY Ecirc "&#202;">
+<!-- capital E, circumflex accent --><!ENTITY Euml "&#203;">
+<!-- capital E, dieresis or umlaut mark --><!ENTITY Igrave "&#204;">
+<!-- capital I, grave accent --><!ENTITY Iacute "&#205;">
+<!-- capital I, acute accent --><!ENTITY Icirc "&#206;">
+<!-- capital I, circumflex accent --><!ENTITY Iuml "&#207;">
+<!-- capital I, dieresis or umlaut mark --><!ENTITY ETH "&#208;">
+<!-- capital Eth, Icelandic --><!ENTITY Ntilde "&#209;">
+<!-- capital N, tilde --><!ENTITY Ograve "&#210;">
+<!-- capital O, grave accent --><!ENTITY Oacute "&#211;">
+<!-- capital O, acute accent --><!ENTITY Ocirc "&#212;">
+<!-- capital O, circumflex accent --><!ENTITY Otilde "&#213;">
+<!-- capital O, tilde --><!ENTITY Ouml "&#214;">
+<!-- capital O, dieresis or umlaut mark --><!ENTITY times "&#215;">
+<!-- multiply sign --><!ENTITY Oslash "&#216;">
+<!-- capital O, slash --><!ENTITY Ugrave "&#217;">
+<!-- capital U, grave accent --><!ENTITY Uacute "&#218;">
+<!-- capital U, acute accent --><!ENTITY Ucirc "&#219;">
+<!-- capital U, circumflex accent --><!ENTITY Uuml "&#220;">
+<!-- capital U, dieresis or umlaut mark --><!ENTITY Yacute "&#221;">
+<!-- capital Y, acute accent --><!ENTITY THORN "&#222;">
+<!-- capital THORN, Icelandic --><!ENTITY szlig "&#223;">
+<!-- small sharp s, German (sz ligature) --><!ENTITY agrave "&#224;">
+<!-- small a, grave accent --><!ENTITY aacute "&#225;">
+<!-- small a, acute accent --><!ENTITY acirc "&#226;">
+<!-- small a, circumflex accent --><!ENTITY atilde "&#227;">
+<!-- small a, tilde --><!ENTITY auml "&#228;">
+<!-- small a, dieresis or umlaut mark --><!ENTITY aring "&#229;">
+<!-- small a, ring --><!ENTITY aelig "&#230;">
+<!-- small ae diphthong (ligature) --><!ENTITY ccedil "&#231;">
+<!-- small c, cedilla --><!ENTITY egrave "&#232;">
+<!-- small e, grave accent --><!ENTITY eacute "&#233;">
+<!-- small e, acute accent --><!ENTITY ecirc "&#234;">
+<!-- small e, circumflex accent --><!ENTITY euml "&#235;">
+<!-- small e, dieresis or umlaut mark --><!ENTITY igrave "&#236;">
+<!-- small i, grave accent --><!ENTITY iacute "&#237;">
+<!-- small i, acute accent --><!ENTITY icirc "&#238;">
+<!-- small i, circumflex accent --><!ENTITY iuml "&#239;">
+<!-- small i, dieresis or umlaut mark --><!ENTITY eth "&#240;">
+<!-- small eth, Icelandic --><!ENTITY ntilde "&#241;">
+<!-- small n, tilde --><!ENTITY ograve "&#242;">
+<!-- small o, grave accent --><!ENTITY oacute "&#243;">
+<!-- small o, acute accent --><!ENTITY ocirc "&#244;">
+<!-- small o, circumflex accent --><!ENTITY otilde "&#245;">
+<!-- small o, tilde --><!ENTITY ouml "&#246;">
+<!-- small o, dieresis or umlaut mark --><!ENTITY divide "&#247;">
+<!-- divide sign --><!ENTITY oslash "&#248;">
+<!-- small o, slash --><!ENTITY ugrave "&#249;">
+<!-- small u, grave accent --><!ENTITY uacute "&#250;">
+<!-- small u, acute accent --><!ENTITY ucirc "&#251;">
+<!-- small u, circumflex accent --><!ENTITY uuml "&#252;">
+<!-- small u, dieresis or umlaut mark --><!ENTITY yacute "&#253;">
+<!-- small y, acute accent --><!ENTITY thorn "&#254;">
+<!-- small thorn, Icelandic --><!ENTITY yuml "&#255;">
+<!-- small y, dieresis or umlaut mark --><!--
+     Copied from HTML 3.2 DTD, with modifications (removed CDATA)
+     http://www.w3.org/TR/REC-html32.html#dtd
+     ================= END ===================
+-->]>
+<rss>
+<channel>
+<image/>
+<title>PP</title>
+</channel>
+</rss>
diff --git a/result/valid/rss.xml.err b/result/valid/rss.xml.err
new file mode 100644
index 0000000..307a8cc
--- /dev/null
+++ b/result/valid/rss.xml.err
@@ -0,0 +1,3 @@
+./test/valid/rss.xml:178: validity error: Element rss doesn't carry attribute version
+</rss>
+     ^
diff --git a/test/valid/rss.xml b/test/valid/rss.xml
new file mode 100644
index 0000000..429e0fe
--- /dev/null
+++ b/test/valid/rss.xml
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE rss [
+<!--
+
+  Rich Site Summary (RSS) 0.91 official DTD, proposed.
+  
+  RSS is an XML vocabulary for describing
+  metadata about websites, and enabling the display of
+  "channels" on the "My Netscape" website.
+  
+  RSS Info can be found at http://my.netscape.com/publish/
+  XML Info can be found at http://www.w3.org/XML/ 
+  
+  copyright Netscape Communications, 1999
+
+  Dan Libby - danda@netscape.com
+  
+  Based on RSS DTD originally created by
+  Lars Marius Garshol - larsga@ifi.uio.no.
+  $Id: rss-0.91.dtd,v 1.1 1999/07/25 07:59:31 danda Exp $
+  
+-->
+<!ELEMENT rss (channel)>
+<!ATTLIST rss version CDATA #REQUIRED>
+<!-- must be "0.91"> --><!ELEMENT channel (title | description | link 
+| language | item+ | rating? | image? | textinput? | copyright? | 
+pubDate? | lastBuildDate? | docs? | managingEditor? | webMaster? | 
+skipHours? | skipDays?)*>
+<!ELEMENT title (#PCDATA)>
+<!ELEMENT description (#PCDATA)>
+<!ELEMENT link (#PCDATA)>
+<!ELEMENT image (title | url | link | width? | height? | description?)*>
+<!ELEMENT url (#PCDATA)>
+<!ELEMENT item (title | link | description)*>
+<!ELEMENT textinput (title | description | name | link)*>
+<!ELEMENT name (#PCDATA)>
+<!ELEMENT rating (#PCDATA)>
+<!ELEMENT language (#PCDATA)>
+<!ELEMENT width (#PCDATA)>
+<!ELEMENT height (#PCDATA)>
+<!ELEMENT copyright (#PCDATA)>
+<!ELEMENT pubDate (#PCDATA)>
+<!ELEMENT lastBuildDate (#PCDATA)>
+<!ELEMENT docs (#PCDATA)>
+<!ELEMENT managingEditor (#PCDATA)>
+<!ELEMENT webMaster (#PCDATA)>
+<!ELEMENT hour (#PCDATA)>
+<!ELEMENT day (#PCDATA)>
+<!ELEMENT skipHours (hour)+>
+<!ELEMENT skipDays (day)+>
+<!--
+     Copied from HTML 3.2 DTD, with modifications (removed CDATA)
+     http://www.w3.org/TR/REC-html32.html#dtd
+     =============== BEGIN ===================
+-->
+<!-- 
+     Character Entities for ISO Latin-1
+     
+     (C) International Organization for Standardization 1986
+     Permission to copy in any form is granted for use with
+     conforming SGML systems and applications as defined in
+     ISO 8879, provided this notice is included in all copies.
+     This has been extended for use with HTML to cover the full
+     set of codes in the range 160-255 decimal.
+-->
+<!-- Character entity set. Typical invocation:
+     <!ENTITY % ISOlat1 PUBLIC
+       "ISO 8879-1986//ENTITIES Added Latin 1//EN//HTML">
+     %ISOlat1;
+-->
+<!ENTITY nbsp "&#160;"> <!-- no-break space -->
+<!ENTITY iexcl "&#161;">
+<!-- inverted exclamation mark --><!ENTITY cent "&#162;">
+<!-- cent sign --><!ENTITY pound "&#163;">
+<!-- pound sterling sign --><!ENTITY curren "&#164;">
+<!-- general currency sign --><!ENTITY yen "&#165;">
+<!-- yen sign --><!ENTITY brvbar "&#166;">
+<!-- broken (vertical) bar --><!ENTITY sect "&#167;">
+<!-- section sign --><!ENTITY uml "&#168;">
+<!-- umlaut (dieresis) --><!ENTITY copy "&#169;">
+<!-- copyright sign --><!ENTITY ordf "&#170;">
+<!-- ordinal indicator, feminine --><!ENTITY laquo "&#171;">
+<!-- angle quotation mark, left --><!ENTITY not "&#172;">
+<!-- not sign --><!ENTITY shy "&#173;">
+<!-- soft hyphen --><!ENTITY reg "&#174;">
+<!-- registered sign --><!ENTITY macr "&#175;">
+<!-- macron --><!ENTITY deg "&#176;">
+<!-- degree sign --><!ENTITY plusmn "&#177;">
+<!-- plus-or-minus sign --><!ENTITY sup2 "&#178;">
+<!-- superscript two --><!ENTITY sup3 "&#179;">
+<!-- superscript three --><!ENTITY acute "&#180;">
+<!-- acute accent --><!ENTITY micro "&#181;">
+<!-- micro sign --><!ENTITY para "&#182;">
+<!-- pilcrow (paragraph sign) --><!ENTITY middot "&#183;">
+<!-- middle dot --><!ENTITY cedil "&#184;">
+<!-- cedilla --><!ENTITY sup1 "&#185;">
+<!-- superscript one --><!ENTITY ordm "&#186;">
+<!-- ordinal indicator, masculine --><!ENTITY raquo "&#187;">
+<!-- angle quotation mark, right --><!ENTITY frac14 "&#188;">
+<!-- fraction one-quarter --><!ENTITY frac12 "&#189;">
+<!-- fraction one-half --><!ENTITY frac34 "&#190;">
+<!-- fraction three-quarters --><!ENTITY iquest "&#191;">
+<!-- inverted question mark --><!ENTITY Agrave "&#192;">
+<!-- capital A, grave accent --><!ENTITY Aacute "&#193;">
+<!-- capital A, acute accent --><!ENTITY Acirc "&#194;">
+<!-- capital A, circumflex accent --><!ENTITY Atilde "&#195;">
+<!-- capital A, tilde --><!ENTITY Auml "&#196;">
+<!-- capital A, dieresis or umlaut mark --><!ENTITY Aring "&#197;">
+<!-- capital A, ring --><!ENTITY AElig "&#198;">
+<!-- capital AE diphthong (ligature) --><!ENTITY Ccedil "&#199;">
+<!-- capital C, cedilla --><!ENTITY Egrave "&#200;">
+<!-- capital E, grave accent --><!ENTITY Eacute "&#201;">
+<!-- capital E, acute accent --><!ENTITY Ecirc "&#202;">
+<!-- capital E, circumflex accent --><!ENTITY Euml "&#203;">
+<!-- capital E, dieresis or umlaut mark --><!ENTITY Igrave "&#204;">
+<!-- capital I, grave accent --><!ENTITY Iacute "&#205;">
+<!-- capital I, acute accent --><!ENTITY Icirc "&#206;">
+<!-- capital I, circumflex accent --><!ENTITY Iuml "&#207;">
+<!-- capital I, dieresis or umlaut mark --><!ENTITY ETH "&#208;">
+<!-- capital Eth, Icelandic --><!ENTITY Ntilde "&#209;">
+<!-- capital N, tilde --><!ENTITY Ograve "&#210;">
+<!-- capital O, grave accent --><!ENTITY Oacute "&#211;">
+<!-- capital O, acute accent --><!ENTITY Ocirc "&#212;">
+<!-- capital O, circumflex accent --><!ENTITY Otilde "&#213;">
+<!-- capital O, tilde --><!ENTITY Ouml "&#214;">
+<!-- capital O, dieresis or umlaut mark --><!ENTITY times "&#215;">
+<!-- multiply sign --><!ENTITY Oslash "&#216;">
+<!-- capital O, slash --><!ENTITY Ugrave "&#217;">
+<!-- capital U, grave accent --><!ENTITY Uacute "&#218;">
+<!-- capital U, acute accent --><!ENTITY Ucirc "&#219;">
+<!-- capital U, circumflex accent --><!ENTITY Uuml "&#220;">
+<!-- capital U, dieresis or umlaut mark --><!ENTITY Yacute "&#221;">
+<!-- capital Y, acute accent --><!ENTITY THORN "&#222;">
+<!-- capital THORN, Icelandic --><!ENTITY szlig "&#223;">
+<!-- small sharp s, German (sz ligature) --><!ENTITY agrave "&#224;">
+<!-- small a, grave accent --><!ENTITY aacute "&#225;">
+<!-- small a, acute accent --><!ENTITY acirc "&#226;">
+<!-- small a, circumflex accent --><!ENTITY atilde "&#227;">
+<!-- small a, tilde --><!ENTITY auml "&#228;">
+<!-- small a, dieresis or umlaut mark --><!ENTITY aring "&#229;">
+<!-- small a, ring --><!ENTITY aelig "&#230;">
+<!-- small ae diphthong (ligature) --><!ENTITY ccedil "&#231;">
+<!-- small c, cedilla --><!ENTITY egrave "&#232;">
+<!-- small e, grave accent --><!ENTITY eacute "&#233;">
+<!-- small e, acute accent --><!ENTITY ecirc "&#234;">
+<!-- small e, circumflex accent --><!ENTITY euml "&#235;">
+<!-- small e, dieresis or umlaut mark --><!ENTITY igrave "&#236;">
+<!-- small i, grave accent --><!ENTITY iacute "&#237;">
+<!-- small i, acute accent --><!ENTITY icirc "&#238;">
+<!-- small i, circumflex accent --><!ENTITY iuml "&#239;">
+<!-- small i, dieresis or umlaut mark --><!ENTITY eth "&#240;">
+<!-- small eth, Icelandic --><!ENTITY ntilde "&#241;">
+<!-- small n, tilde --><!ENTITY ograve "&#242;">
+<!-- small o, grave accent --><!ENTITY oacute "&#243;">
+<!-- small o, acute accent --><!ENTITY ocirc "&#244;">
+<!-- small o, circumflex accent --><!ENTITY otilde "&#245;">
+<!-- small o, tilde --><!ENTITY ouml "&#246;">
+<!-- small o, dieresis or umlaut mark --><!ENTITY divide "&#247;">
+<!-- divide sign --><!ENTITY oslash "&#248;">
+<!-- small o, slash --><!ENTITY ugrave "&#249;">
+<!-- small u, grave accent --><!ENTITY uacute "&#250;">
+<!-- small u, acute accent --><!ENTITY ucirc "&#251;">
+<!-- small u, circumflex accent --><!ENTITY uuml "&#252;">
+<!-- small u, dieresis or umlaut mark --><!ENTITY yacute "&#253;">
+<!-- small y, acute accent --><!ENTITY thorn "&#254;">
+<!-- small thorn, Icelandic --><!ENTITY yuml "&#255;">
+<!-- small y, dieresis or umlaut mark --><!--
+     Copied from HTML 3.2 DTD, with modifications (removed CDATA)
+     http://www.w3.org/TR/REC-html32.html#dtd
+     ================= END ===================
+-->
+]>
+<rss>
+<channel>
+<image/>
+<title>PP</title>
+</channel>
+</rss>
diff --git a/valid.c b/valid.c
index c36930f..b8077b4 100644
--- a/valid.c
+++ b/valid.c
@@ -3655,6 +3655,18 @@
 	    break;
 	case XML_ELEMENT_CONTENT_OR:
 	    /*
+	     * Small optimization.
+	     */
+	    if (CONT->c1->type == XML_ELEMENT_CONTENT_ELEMENT) {
+		if ((NODE == NULL) ||
+		    (!xmlStrEqual(NODE->name, CONT->c1->name))) {
+		    DEPTH++;
+		    CONT = CONT->c2;
+		    goto cont;
+		}
+	    }
+
+	    /*
 	     * save the second branch 'or' branch
 	     */
 	    DEBUG_VALID_MSG("saving 'or' branch");