added code in xmlSchemaBuildAContentModel to handle element reference

* xmlschemas.c: added code in xmlSchemaBuildAContentModel to handle
  element reference within the xs:all construct (bug 139897)
diff --git a/xmlschemas.c b/xmlschemas.c
index 4aa9dc4..e9dfadb 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -4473,6 +4473,13 @@
                 start = ctxt->state;
                 while (subtypes != NULL) {
                     ctxt->state = start;
+		    /*
+		     * the following 'if' was needed to fix bug 139897
+		     * not quite sure why it only needs to be done for
+		     * elements with a 'ref', but it seems to work ok.
+		     */
+		    if (subtypes->ref != NULL)
+		        xmlSchemaBuildAContentModel(subtypes, ctxt, name);
                     elem = (xmlSchemaElementPtr) subtypes;		    
                     /* TODO : handle the namespace too */
                     if ((elem->minOccurs == 1) && (elem->maxOccurs == 1)) {