added new function xmlSchemaValidCtxtGetParserCtxt based on Holger

* include/libxml/xmlschemas.h xmlschemas.c: added new function
  xmlSchemaValidCtxtGetParserCtxt based on Holger Kaelberer patch
* doc/apibuild.py doc/*: regenerated the doc, chased why the new
  function didn't got any documentation, added more checking in the
  generator
* include/libxml/relaxng.h include/libxml/schematron.h
  include/libxml/xmlschemas.h include/libxml/c14n.h
  include/libxml/xmlregexp.h include/libxml/globals.h
  include/libxml/xmlreader.h threads.c xmlschemas.c: various changes
  and cleanups following the new reports
Daniel

svn path=/trunk/; revision=3738
diff --git a/xmlschemas.c b/xmlschemas.c
index f2d49f1..a0d0d72 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -90,7 +90,7 @@
  #ifndef DEBUG_IDC_NODE_TABLE
   #define DEBUG_IDC_NODE_TABLE
  #endif
-#endif   
+#endif
 
 /* #define ENABLE_PARTICLE_RESTRICTION 1 */
 
@@ -374,7 +374,7 @@
 #define XML_SCHEMA_SCHEMA_REDEFINE 3
 
 /**
- * xmlSchemaSchemaRelation: 
+ * xmlSchemaSchemaRelation:
  *
  * Used to create a graph of schema relationships.
  */
@@ -402,12 +402,12 @@
     int parsed;
     int imported;
     int preserveDoc;
-    xmlSchemaItemListPtr globals; /* Global components. */ 
+    xmlSchemaItemListPtr globals; /* Global components. */
     xmlSchemaItemListPtr locals; /* Local components. */
 };
 
 /**
- * xmlSchemaImport: 
+ * xmlSchemaImport:
  * (extends xmlSchemaBucket)
  *
  * Reflects a schema. Holds some information
@@ -422,9 +422,9 @@
     const xmlChar *schemaLocation; /* The URI of the schema document. */
     /* For chameleon includes, @origTargetNamespace will be NULL */
     const xmlChar *origTargetNamespace;
-    /* 
+    /*
     * For chameleon includes, @targetNamespace will be the
-    * targetNamespace of the including schema. 
+    * targetNamespace of the including schema.
     */
     const xmlChar *targetNamespace;
     xmlDocPtr doc; /* The schema node-tree. */
@@ -457,7 +457,7 @@
     int parsed;
     int imported;
     int preserveDoc;
-    xmlSchemaItemListPtr globals; /* Global components. */ 
+    xmlSchemaItemListPtr globals; /* Global components. */
     xmlSchemaItemListPtr locals; /* Local components. */
 
     /* The owning main or import schema bucket. */
@@ -517,7 +517,7 @@
     xmlSchemaTypeType type;
     xmlSchemaAnnotPtr annot;
     xmlSchemaAttributeUsePtr next; /* The next attr. use. */
-    /* 
+    /*
     * The attr. decl. OR a QName-ref. to an attr. decl. OR
     * a QName-ref. to an attribute group definition.
     */
@@ -573,7 +573,7 @@
     xmlDictPtr dict;
     xmlSchemaItemListPtr buckets; /* List of schema buckets. */
     /* xmlSchemaItemListPtr relations; */ /* List of schema relations. */
-    xmlSchemaBucketPtr bucket; /* The current schema bucket */    
+    xmlSchemaBucketPtr bucket; /* The current schema bucket */
     xmlSchemaItemListPtr pending; /* All Components of all schemas that
                                      need to be fixed. */
     xmlHashTablePtr substGroups;
@@ -629,7 +629,7 @@
     xmlSchemaBucketPtr redefined; /* The schema to be redefined. */
 
     xmlSchemaRedefPtr redef; /* Used for redefinitions. */
-    int redefCounter; /* Used for redefinitions. */ 
+    int redefCounter; /* Used for redefinitions. */
     xmlSchemaItemListPtr attrProhibs;
 };
 
@@ -783,7 +783,7 @@
     xmlNodePtr node;
     xmlSchemaPSVIIDCKeyPtr *keys;
     int nodeLine;
-    int nodeQNameID;    
+    int nodeQNameID;
 
 };
 
@@ -879,7 +879,7 @@
 struct _xmlSchemaNodeInfo {
     int nodeType;
     xmlNodePtr node;
-    int nodeLine;    
+    int nodeLine;
     const xmlChar *localName;
     const xmlChar *nsName;
     const xmlChar *value;
@@ -901,7 +901,7 @@
 
     const xmlChar **nsBindings; /* Namespace bindings on this element */
     int nbNsBindings;
-    int sizeNsBindings;    
+    int sizeNsBindings;
 
     int hasKeyrefs;
     int appliedXPath; /* Indicates that an XPath has been applied. */
@@ -938,7 +938,7 @@
 struct _xmlSchemaAttrInfo {
     int nodeType;
     xmlNodePtr node;
-    int nodeLine;    
+    int nodeLine;
     const xmlChar *localName;
     const xmlChar *nsName;
     const xmlChar *value;
@@ -1172,7 +1172,7 @@
 	    if (WXS_IS_COMPLEX(WXS_TYPE_CAST item))
 		return(BAD_CAST "complex type definition");
 	    else
-		return(BAD_CAST "simple type definition");	
+		return(BAD_CAST "simple type definition");
 	default:
 	    return(xmlSchemaItemTypeToStr(item->type));
     }
@@ -1300,11 +1300,11 @@
 	*buf = xmlStrcat(*buf, localName);
     } else {
 	*buf = xmlStrcat(*buf, BAD_CAST "(NULL)");
-    }    
+    }
     return ((const xmlChar *) *buf);
 }
 
-static const xmlChar*   
+static const xmlChar*
 xmlSchemaFormatQNameNs(xmlChar **buf, xmlNsPtr ns, const xmlChar *localName)
 {
     if (ns != NULL)
@@ -1480,16 +1480,16 @@
     int list;
     xmlSchemaValType valType;
     const xmlChar *value, *value2 = NULL;
-    
+
 
     if ((retValue == NULL) || (val == NULL))
 	return (-1);
     list = xmlSchemaValueGetNext(val) ? 1 : 0;
     *retValue = NULL;
     do {
-	value = NULL;	
-	valType = xmlSchemaGetValType(val);    
-	switch (valType) {	    
+	value = NULL;
+	valType = xmlSchemaGetValType(val);
+	switch (valType) {
 	    case XML_SCHEMAS_STRING:
 	    case XML_SCHEMAS_NORMSTRING:
 	    case XML_SCHEMAS_ANYSIMPLETYPE:
@@ -1502,7 +1502,7 @@
 		    if (value2 != NULL)
 			value = value2;
 		}
-		break;	   
+		break;
 	    default:
 		if (xmlSchemaGetCanonValue(val, &value2) == -1) {
 		    if (value2 != NULL)
@@ -1540,29 +1540,29 @@
  * @buf: the string buffer
  * @itemDes: the designation of the item
  * @itemName: the name of the item
- * @item: the item as an object 
+ * @item: the item as an object
  * @itemNode: the node of the item
  * @local: the local name
  * @parsing: if the function is used during the parse
  *
  * Returns a representation of the given item used
- * for error reports. 
+ * for error reports.
  *
- * The following order is used to build the resulting 
+ * The following order is used to build the resulting
  * designation if the arguments are not NULL:
  * 1a. If itemDes not NULL -> itemDes
  * 1b. If (itemDes not NULL) and (itemName not NULL)
  *     -> itemDes + itemName
  * 2. If the preceding was NULL and (item not NULL) -> item
  * 3. If the preceding was NULL and (itemNode not NULL) -> itemNode
- * 
+ *
  * If the itemNode is an attribute node, the name of the attribute
  * will be appended to the result.
  *
  * Returns the formatted string and sets @buf to the resulting value.
- */  
-static xmlChar*   
-xmlSchemaFormatItemForReport(xmlChar **buf,		     
+ */
+static xmlChar*
+xmlSchemaFormatItemForReport(xmlChar **buf,
 		     const xmlChar *itemDes,
 		     xmlSchemaBasicItemPtr item,
 		     xmlNodePtr itemNode)
@@ -1574,9 +1574,9 @@
 	xmlFree(*buf);
 	*buf = NULL;
     }
-            
+
     if (itemDes != NULL) {
-	*buf = xmlStrdup(itemDes);	
+	*buf = xmlStrdup(itemDes);
     } else if (item != NULL) {
 	switch (item->type) {
 	case XML_SCHEMA_TYPE_BASIC: {
@@ -1634,7 +1634,7 @@
 	    break;
 	case XML_SCHEMA_TYPE_ATTRIBUTE_USE: {
 		xmlSchemaAttributeUsePtr ause;
-	    
+
 		ause = WXS_ATTR_USE_CAST item;
 		*buf = xmlStrdup(BAD_CAST "attribute use ");
 		if (WXS_ATTRUSE_DECL(ause) != NULL) {
@@ -1650,7 +1650,7 @@
 	    break;
 	case XML_SCHEMA_TYPE_ATTRIBUTE: {
 		xmlSchemaAttributePtr attr;
-	    
+
 		attr = (xmlSchemaAttributePtr) item;
 		*buf = xmlStrdup(BAD_CAST "attribute decl.");
 		*buf = xmlStrcat(*buf, BAD_CAST " '");
@@ -1666,7 +1666,7 @@
 	case XML_SCHEMA_TYPE_ELEMENT: {
 		xmlSchemaElementPtr elem;
 
-		elem = (xmlSchemaElementPtr) item;	    
+		elem = (xmlSchemaElementPtr) item;
 		*buf = xmlStrdup(BAD_CAST "element decl.");
 		*buf = xmlStrcat(*buf, BAD_CAST " '");
 		*buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str,
@@ -1676,7 +1676,7 @@
 	    break;
 	case XML_SCHEMA_TYPE_IDC_UNIQUE:
 	case XML_SCHEMA_TYPE_IDC_KEY:
-	case XML_SCHEMA_TYPE_IDC_KEYREF:		
+	case XML_SCHEMA_TYPE_IDC_KEYREF:
 	    if (item->type == XML_SCHEMA_TYPE_IDC_UNIQUE)
 		*buf = xmlStrdup(BAD_CAST "unique '");
 	    else if (item->type == XML_SCHEMA_TYPE_IDC_KEY)
@@ -1732,7 +1732,7 @@
 	default:
 	    named = 0;
 	}
-    } else 
+    } else
 	named = 0;
 
     if ((named == 0) && (itemNode != NULL)) {
@@ -1740,7 +1740,7 @@
 
 	if (itemNode->type == XML_ATTRIBUTE_NODE)
 	    elem = itemNode->parent;
-	else 
+	else
 	    elem = itemNode;
 	*buf = xmlStrdup(BAD_CAST "Element '");
 	if (elem->ns != NULL) {
@@ -1750,7 +1750,7 @@
 	} else
 	    *buf = xmlStrcat(*buf, elem->name);
 	*buf = xmlStrcat(*buf, BAD_CAST "'");
-	
+
     }
     if ((itemNode != NULL) && (itemNode->type == XML_ATTRIBUTE_NODE)) {
 	*buf = xmlStrcat(*buf, BAD_CAST ", attribute '");
@@ -1763,7 +1763,7 @@
 	*buf = xmlStrcat(*buf, BAD_CAST "'");
     }
     FREE_AND_NULL(str)
-    
+
     return (*buf);
 }
 
@@ -1786,13 +1786,13 @@
     int res, found = 0;
 
     if (*buf != NULL)
-	xmlFree(*buf);    
+	xmlFree(*buf);
     *buf = NULL;
 
     do {
 	/*
 	* Use the whitespace type of the base type.
-	*/	
+	*/
 	ws = xmlSchemaGetWhiteSpaceFacetValue(type->baseType);
 	for (facet = type->facets; facet != NULL; facet = facet->next) {
 	    if (facet->type != XML_SCHEMA_FACET_ENUMERATION)
@@ -1881,7 +1881,7 @@
  * @msg: the error message
  * @str1: extra data
  * @str2: extra data
- * 
+ *
  * Handle a parser error
  */
 static void
@@ -1914,7 +1914,7 @@
  * @msg: the error message
  * @str1: extra data
  * @str2: extra data
- * 
+ *
  * Handle a parser error
  */
 static void
@@ -1933,7 +1933,7 @@
  * xmlSchemaPErrExt:
  * @ctxt: the parsing context
  * @node: the context node
- * @error: the error code 
+ * @error: the error code
  * @strData1: extra data
  * @strData2: extra data
  * @strData3: extra data
@@ -1943,13 +1943,13 @@
  * @str3:  extra parameter for the message display
  * @str4:  extra parameter for the message display
  * @str5:  extra parameter for the message display
- * 
+ *
  * Handle a parser error
  */
 static void
 xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
-		const xmlChar * strData1, const xmlChar * strData2, 
-		const xmlChar * strData3, const char *msg, const xmlChar * str1, 
+		const xmlChar * strData1, const xmlChar * strData2,
+		const xmlChar * strData3, const char *msg, const xmlChar * str1,
 		const xmlChar * str2, const xmlChar * str3, const xmlChar * str4,
 		const xmlChar * str5)
 {
@@ -1967,8 +1967,8 @@
     }
     __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP,
                     error, XML_ERR_ERROR, NULL, 0,
-                    (const char *) strData1, (const char *) strData2, 
-		    (const char *) strData3, 0, 0, msg, str1, str2, 
+                    (const char *) strData1, (const char *) strData2,
+		    (const char *) strData3, 0, 0, msg, str1, str2,
 		    str3, str4, str5);
 }
 
@@ -2016,7 +2016,7 @@
  * @str1: extra data
  * @str2: extra data
  * @str3: extra data
- * 
+ *
  * Handle a validation error
  */
 static void
@@ -2028,8 +2028,8 @@
 {
     xmlStructuredErrorFunc schannel = NULL;
     xmlGenericErrorFunc channel = NULL;
-    void *data = NULL;    
-    
+    void *data = NULL;
+
     if (ctxt != NULL) {
 	if (ctxt->type == XML_SCHEMA_CTXT_VALIDATOR) {
 	    xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctxt;
@@ -2037,7 +2037,7 @@
 	    if (errorLevel != XML_ERR_WARNING) {
 		vctxt->nberrors++;
 		vctxt->err = error;
-		channel = vctxt->error;		
+		channel = vctxt->error;
 	    } else {
 		channel = vctxt->warning;
 	    }
@@ -2077,7 +2077,7 @@
 		else if ((vctxt->parserCtxt != NULL) &&
 		    (vctxt->parserCtxt->input != NULL))
 		    file = vctxt->parserCtxt->input->filename;
-	    }	       
+	    }
 	    __xmlRaiseError(schannel, channel, data, ctxt,
 		node, XML_FROM_SCHEMASV,
 		error, errorLevel, file, line,
@@ -2089,7 +2089,7 @@
 	    if (errorLevel != XML_ERR_WARNING) {
 		pctxt->nberrors++;
 		pctxt->err = error;
-		channel = pctxt->error;		
+		channel = pctxt->error;
 	    } else {
 		channel = pctxt->warning;
 	    }
@@ -2115,11 +2115,11 @@
  * @str1: extra data
  * @str2: extra data
  * @str3: extra data
- * 
+ *
  * Handle a validation error
  */
 static void
-xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt,  
+xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt,
 	      int error, xmlNodePtr node, const char *msg,
 	      const xmlChar *str1, const xmlChar *str2, const xmlChar *str3)
 {
@@ -2128,7 +2128,7 @@
 }
 
 static void
-xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt,  
+xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt,
 	      int error, xmlNodePtr node, const char *msg,
 	      const xmlChar *str1, const xmlChar *str2,
 	      const xmlChar *str3, const xmlChar *str4)
@@ -2157,7 +2157,7 @@
 	(node->type != XML_ELEMENT_NODE) &&
 	(node->type != XML_ATTRIBUTE_NODE))
     {
-	/* 
+	/*
 	* Don't try to format other nodes than element and
 	* attribute nodes.
 	* Play save and return an empty string.
@@ -2171,7 +2171,7 @@
 	*/
 	if (node->type == XML_ATTRIBUTE_NODE) {
 	    xmlNodePtr elem = node->parent;
-	    
+
 	    *msg = xmlStrdup(BAD_CAST "Element '");
 	    if (elem->ns != NULL)
 		*msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str,
@@ -2181,7 +2181,7 @@
 		    NULL, elem->name));
 	    FREE_AND_NULL(str);
 	    *msg = xmlStrcat(*msg, BAD_CAST "', ");
-	    *msg = xmlStrcat(*msg, BAD_CAST "attribute '");	    
+	    *msg = xmlStrcat(*msg, BAD_CAST "attribute '");
 	} else {
 	    *msg = xmlStrdup(BAD_CAST "Element '");
 	}
@@ -2197,7 +2197,7 @@
 	xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) actxt;
 	/*
 	* Work on node infos.
-	*/	
+	*/
 	if (vctxt->inode->nodeType == XML_ATTRIBUTE_NODE) {
 	    xmlSchemaNodeInfoPtr ielem =
 		vctxt->elemInfos[vctxt->depth];
@@ -2207,7 +2207,7 @@
 		ielem->nsName, ielem->localName));
 	    FREE_AND_NULL(str);
 	    *msg = xmlStrcat(*msg, BAD_CAST "', ");
-	    *msg = xmlStrcat(*msg, BAD_CAST "attribute '");	    
+	    *msg = xmlStrcat(*msg, BAD_CAST "attribute '");
 	} else {
 	    *msg = xmlStrdup(BAD_CAST "Element '");
 	}
@@ -2216,7 +2216,7 @@
 	FREE_AND_NULL(str);
 	*msg = xmlStrcat(*msg, BAD_CAST "': ");
     } else if (actxt->type == XML_SCHEMA_CTXT_PARSER) {
-	/* 
+	/*
 	* Hmm, no node while parsing?
 	* Return an empty string, in case NULL will break something.
 	*/
@@ -2254,7 +2254,7 @@
         return;
     msg = xmlStrdup(BAD_CAST "Internal error: ");
     msg = xmlStrcat(msg, BAD_CAST funcName);
-    msg = xmlStrcat(msg, BAD_CAST ", ");    
+    msg = xmlStrcat(msg, BAD_CAST ", ");
     msg = xmlStrcat(msg, BAD_CAST message);
     msg = xmlStrcat(msg, BAD_CAST ".\n");
 
@@ -2262,7 +2262,7 @@
 	xmlSchemaErr(actxt, XML_SCHEMAV_INTERNAL, NULL,
 	    (const char *) msg, str1, str2);
 
-    else if (actxt->type == XML_SCHEMA_CTXT_PARSER)	
+    else if (actxt->type == XML_SCHEMA_CTXT_PARSER)
 	xmlSchemaErr(actxt, XML_SCHEMAP_INTERNAL, NULL,
 	    (const char *) msg, str1, str2);
 
@@ -2309,7 +2309,7 @@
     } else
 	xmlSchemaFormatNodeForError(&msg, actxt, node);
     msg = xmlStrcat(msg, (const xmlChar *) message);
-    msg = xmlStrcat(msg, BAD_CAST ".\n");   
+    msg = xmlStrcat(msg, BAD_CAST ".\n");
     xmlSchemaErr4(actxt, error, node,
 	(const char *) msg, str1, str2, str3, str4);
     FREE_AND_NULL(msg)
@@ -2325,7 +2325,7 @@
 		   const xmlChar *str2)
 {
     xmlSchemaCustomErr4(actxt, error, node, item,
-	message, str1, str2, NULL, NULL);    
+	message, str1, str2, NULL, NULL);
 }
 
 
@@ -2344,8 +2344,8 @@
 
     xmlSchemaFormatNodeForError(&msg, actxt, node);
     msg = xmlStrcat(msg, (const xmlChar *) message);
-    msg = xmlStrcat(msg, BAD_CAST ".\n"); 
-    
+    msg = xmlStrcat(msg, BAD_CAST ".\n");
+
     /* URGENT TODO: Set the error code to something sane. */
     xmlSchemaErr4Line(actxt, XML_ERR_WARNING, error, node, 0,
 	(const char *) msg, str1, str2, str3, NULL);
@@ -2365,15 +2365,15 @@
 		   const xmlChar *str2)
 {
     xmlChar *msg = NULL, *qname = NULL;
-    
-    msg = xmlStrdup(BAD_CAST "Element '%s': ");        
+
+    msg = xmlStrdup(BAD_CAST "Element '%s': ");
     msg = xmlStrcat(msg, (const xmlChar *) message);
     msg = xmlStrcat(msg, BAD_CAST ".\n");
     xmlSchemaErr4Line(ACTXT_CAST vctxt, XML_ERR_ERROR,
 	error, NULL, idcNode->nodeLine, (const char *) msg,
 	xmlSchemaFormatQName(&qname,
 	    vctxt->nodeQNames->items[idcNode->nodeQNameID +1],
-	    vctxt->nodeQNames->items[idcNode->nodeQNameID]), 
+	    vctxt->nodeQNames->items[idcNode->nodeQNameID]),
 	str1, str2, NULL);
     FREE_AND_NULL(qname);
     FREE_AND_NULL(msg);
@@ -2456,7 +2456,7 @@
 	if (type->builtInType != 0) {
 	    msg = xmlStrcat(msg, BAD_CAST "xs:");
 	    msg = xmlStrcat(msg, type->name);
-	} else 
+	} else
 	    msg = xmlStrcat(msg,
 		xmlSchemaFormatQName(&str,
 		    type->targetNamespace, type->name));
@@ -2494,12 +2494,12 @@
 			xmlNodePtr node)
 {
     xmlChar *msg = NULL, *str = NULL;
-    
+
     xmlSchemaFormatNodeForError(&msg, actxt, node);
     msg = xmlStrcat(msg, BAD_CAST "The attribute '%s' is not allowed.\n");
     xmlSchemaErr(actxt, error, node, (const char *) msg,
 	xmlSchemaFormatErrorNodeQName(&str, (xmlSchemaNodeInfoPtr) ni, node),
-	NULL);        
+	NULL);
     FREE_AND_NULL(str)
     FREE_AND_NULL(msg)
 }
@@ -2518,7 +2518,7 @@
     xmlChar *localName, *nsName;
     const xmlChar *cur, *end;
     int i;
-    
+
     xmlSchemaFormatNodeForError(&msg, actxt, node);
     msg = xmlStrcat(msg, (const xmlChar *) message);
     msg = xmlStrcat(msg, BAD_CAST ".");
@@ -2533,7 +2533,7 @@
 	} else
 	    str = xmlStrdup(BAD_CAST " Expected is ( ");
 	nsName = NULL;
-    	    
+
 	for (i = 0; i < nbval + nbneg; i++) {
 	    cur = values[i];
 	    if (cur == NULL)
@@ -2547,7 +2547,7 @@
 	    * Get the local name.
 	    */
 	    localName = NULL;
-	    
+
 	    end = cur;
 	    if (*end == '*') {
 		localName = xmlStrdup(BAD_CAST "*");
@@ -2556,8 +2556,8 @@
 		while ((*end != 0) && (*end != '|'))
 		    end++;
 		localName = xmlStrncat(localName, BAD_CAST cur, end - cur);
-	    }		
-	    if (*end != 0) {		    
+	    }
+	    if (*end != 0) {
 		end++;
 		/*
 		* Skip "*|*" if they come with negated expressions, since
@@ -2573,12 +2573,12 @@
 		    } else {
 			while (*end != 0)
 			    end++;
-			
+
 			if (i >= nbval)
 			    nsName = xmlStrdup(BAD_CAST "{##other:");
 			else
 			    nsName = xmlStrdup(BAD_CAST "{");
-			
+
 			nsName = xmlStrncat(nsName, BAD_CAST cur, end - cur);
 			nsName = xmlStrcat(nsName, BAD_CAST "}");
 		    }
@@ -2588,13 +2588,13 @@
 		    FREE_AND_NULL(localName);
 		    continue;
 		}
-	    }	        
+	    }
 	    str = xmlStrcat(str, BAD_CAST localName);
 	    FREE_AND_NULL(localName);
-		
+
 	    if (i < nbval + nbneg -1)
 		str = xmlStrcat(str, BAD_CAST ", ");
-	}	
+	}
 	str = xmlStrcat(str, BAD_CAST " ).\n");
 	msg = xmlStrcat(msg, BAD_CAST str);
 	FREE_AND_NULL(str)
@@ -2626,8 +2626,8 @@
 	/*
 	* If enumerations are validated, one must not expect the
 	* facet to be given.
-	*/	
-    } else	
+	*/
+    } else
 	facetType = facet->type;
     msg = xmlStrcat(msg, BAD_CAST "[");
     msg = xmlStrcat(msg, BAD_CAST "facet '");
@@ -2655,31 +2655,31 @@
 	    snprintf(actLen, 24, "%lu", length);
 
 	    if (facetType == XML_SCHEMA_FACET_LENGTH)
-		msg = xmlStrcat(msg, 
-		BAD_CAST "this differs from the allowed length of '%s'.\n");     
+		msg = xmlStrcat(msg,
+		BAD_CAST "this differs from the allowed length of '%s'.\n");
 	    else if (facetType == XML_SCHEMA_FACET_MAXLENGTH)
-		msg = xmlStrcat(msg, 
+		msg = xmlStrcat(msg,
 		BAD_CAST "this exceeds the allowed maximum length of '%s'.\n");
 	    else if (facetType == XML_SCHEMA_FACET_MINLENGTH)
-		msg = xmlStrcat(msg, 
+		msg = xmlStrcat(msg,
 		BAD_CAST "this underruns the allowed minimum length of '%s'.\n");
-	    
+
 	    if (nodeType == XML_ATTRIBUTE_NODE)
 		xmlSchemaErr3(actxt, error, node, (const char *) msg,
 		    value, (const xmlChar *) actLen, (const xmlChar *) len);
-	    else 
+	    else
 		xmlSchemaErr(actxt, error, node, (const char *) msg,
 		    (const xmlChar *) actLen, (const xmlChar *) len);
-	
+
 	} else if (facetType == XML_SCHEMA_FACET_ENUMERATION) {
 	    msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not an element "
 		"of the set {%s}.\n");
-	    xmlSchemaErr(actxt, error, node, (const char *) msg, value, 
+	    xmlSchemaErr(actxt, error, node, (const char *) msg, value,
 		xmlSchemaFormatFacetEnumSet(actxt, &str, type));
 	} else if (facetType == XML_SCHEMA_FACET_PATTERN) {
 	    msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not accepted "
 		"by the pattern '%s'.\n");
-	    xmlSchemaErr(actxt, error, node, (const char *) msg, value, 
+	    xmlSchemaErr(actxt, error, node, (const char *) msg, value,
 		facet->value);
 	} else if (facetType == XML_SCHEMA_FACET_MININCLUSIVE) {
 	    msg = xmlStrcat(msg, BAD_CAST "The value '%s' is less than the "
@@ -2711,10 +2711,10 @@
 		"digits than are allowed ('%s').\n");
 	    xmlSchemaErr(actxt, error, node, (const char*) msg, value,
 		facet->value);
-	} else if (nodeType == XML_ATTRIBUTE_NODE) {		
+	} else if (nodeType == XML_ATTRIBUTE_NODE) {
 	    msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not facet-valid.\n");
-	    xmlSchemaErr(actxt, error, node, (const char *) msg, value, NULL);	
-	} else {	    
+	    xmlSchemaErr(actxt, error, node, (const char *) msg, value, NULL);
+	} else {
 	    msg = xmlStrcat(msg, BAD_CAST "The value is not facet-valid.\n");
 	    xmlSchemaErr(actxt, error, node, (const char *) msg, NULL, NULL);
 	}
@@ -2722,7 +2722,7 @@
 	msg = xmlStrcat(msg, (const xmlChar *) message);
 	msg = xmlStrcat(msg, BAD_CAST ".\n");
 	xmlSchemaErr(actxt, error, node, (const char *) msg, str1, str2);
-    }        
+    }
     FREE_AND_NULL(str)
     xmlFree(msg);
 }
@@ -2967,9 +2967,9 @@
 		    const xmlChar *str3,const xmlChar *str4)
 {
     xmlChar *str = NULL, *msg = NULL;
-    
+
     xmlSchemaFormatItemForReport(&msg, NULL, ownerItem, NULL);
-    msg = xmlStrcat(msg, BAD_CAST ", ");    
+    msg = xmlStrcat(msg, BAD_CAST ", ");
     msg = xmlStrcat(msg,
 	BAD_CAST xmlSchemaFormatItemForReport(&str, NULL,
 	WXS_BASIC_CAST attruse, NULL));
@@ -2977,7 +2977,7 @@
     msg = xmlStrcat(msg, BAD_CAST ": ");
     msg = xmlStrcat(msg, (const xmlChar *) message);
     msg = xmlStrcat(msg, BAD_CAST ".\n");
-    xmlSchemaErr4(ACTXT_CAST ctxt, error, node, 
+    xmlSchemaErr4(ACTXT_CAST ctxt, error, node,
 	(const char *) msg, str1, str2, str3, str4);
     xmlFree(msg);
 }
@@ -3071,7 +3071,7 @@
  * @error: the error code
  * @type: the type specifier
  * @ownerDes: the designation of the owner
- * @ownerItem: the schema object if existent 
+ * @ownerItem: the schema object if existent
  * @node: the validated node
  * @value: the validated value
  *
@@ -3079,7 +3079,7 @@
  * TODO: Should this report the value of an element as well?
  */
 static void
-xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, 
+xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt,
 			xmlParserErrors error,
 			xmlSchemaBasicItemPtr ownerItem ATTRIBUTE_UNUSED,
 			xmlNodePtr node,
@@ -3091,37 +3091,37 @@
 			const xmlChar *str2)
 {
     xmlChar *msg = NULL;
-    
+
     xmlSchemaFormatNodeForError(&msg, ACTXT_CAST ctxt, node);
     if (message == NULL) {
 	/*
 	* Use default messages.
-	*/	
+	*/
 	if (type != NULL) {
 	    if (node->type == XML_ATTRIBUTE_NODE)
 		msg = xmlStrcat(msg, BAD_CAST "'%s' is not a valid value of ");
 	    else
 		msg = xmlStrcat(msg, BAD_CAST "The character content is not a "
-		"valid value of ");	
+		"valid value of ");
 	    if (! xmlSchemaIsGlobalItem(type))
 		msg = xmlStrcat(msg, BAD_CAST "the local ");
 	    else
 		msg = xmlStrcat(msg, BAD_CAST "the ");
-	    
+
 	    if (WXS_IS_ATOMIC(type))
 		msg = xmlStrcat(msg, BAD_CAST "atomic type");
 	    else if (WXS_IS_LIST(type))
 		msg = xmlStrcat(msg, BAD_CAST "list type");
 	    else if (WXS_IS_UNION(type))
 		msg = xmlStrcat(msg, BAD_CAST "union type");
-	    
+
 	    if (xmlSchemaIsGlobalItem(type)) {
 		xmlChar *str = NULL;
 		msg = xmlStrcat(msg, BAD_CAST " '");
 		if (type->builtInType != 0) {
 		    msg = xmlStrcat(msg, BAD_CAST "xs:");
 		    msg = xmlStrcat(msg, type->name);
-		} else 
+		} else
 		    msg = xmlStrcat(msg,
 			xmlSchemaFormatQName(&str,
 			    type->targetNamespace, type->name));
@@ -3134,7 +3134,7 @@
 	    else
 		msg = xmlStrcat(msg, BAD_CAST "The character content is not "
 		"valid.");
-	}	
+	}
 	if (expected) {
 	    msg = xmlStrcat(msg, BAD_CAST " Expected is '");
 	    msg = xmlStrcat(msg, BAD_CAST expected);
@@ -3151,7 +3151,7 @@
 	xmlSchemaPErrExt(ctxt, node, error, NULL, NULL, NULL,
 	     (const char*) msg, str1, str2, NULL, NULL, NULL);
     }
-    /* Cleanup. */    
+    /* Cleanup. */
     FREE_AND_NULL(msg)
 }
 
@@ -3372,7 +3372,7 @@
 
 static int
 xmlSchemaItemListInsert(xmlSchemaItemListPtr list, void *item, int idx)
-{    
+{
     if (list->items == NULL) {
 	list->items = (void **) xmlMalloc(
 	    20 * sizeof(void *));
@@ -3412,7 +3412,7 @@
 			    int initialSize,
 			    void *item,
 			    int idx)
-{    
+{
     if (list->items == NULL) {
 	if (initialSize <= 0)
 	    initialSize = 1;
@@ -3467,7 +3467,7 @@
 	list->sizeItems = 0;
     } else if (list->nbItems -1 == idx) {
 	list->nbItems--;
-    } else {	
+    } else {
 	for (i = idx; i < list->nbItems -1; i++)
 	    list->items[i] = list->items[i+1];
 	list->nbItems--;
@@ -3502,19 +3502,19 @@
     }
     if (bucket->locals != NULL) {
 	xmlSchemaComponentListFree(bucket->locals);
-	xmlSchemaItemListFree(bucket->locals);	
+	xmlSchemaItemListFree(bucket->locals);
     }
     if (bucket->relations != NULL) {
 	xmlSchemaSchemaRelationPtr prev, cur = bucket->relations;
 	do {
-	    prev = cur;	    
+	    prev = cur;
 	    cur = cur->next;
 	    xmlFree(prev);
 	} while (cur != NULL);
     }
     if ((! bucket->preserveDoc) && (bucket->doc != NULL)) {
 	xmlFreeDoc(bucket->doc);
-    } 
+    }
     if (bucket->type == XML_SCHEMA_SCHEMA_IMPORT) {
 	if (WXS_IMPBUCKET(bucket)->schema != NULL)
 	    xmlSchemaFree(WXS_IMPBUCKET(bucket)->schema);
@@ -3559,7 +3559,7 @@
 	xmlFree(ret);
 	return(NULL);
     }
-    /* 
+    /*
     * The following will assure that only the first bucket is marked as
     * XML_SCHEMA_SCHEMA_MAIN and it points to the *main* schema.
     * For each following import buckets an xmlSchema will be created.
@@ -3573,7 +3573,7 @@
 	    xmlSchemaBucketFree(ret);
 	    return(NULL);
 	}
-	/* Force the type to be XML_SCHEMA_SCHEMA_MAIN. */ 
+	/* Force the type to be XML_SCHEMA_SCHEMA_MAIN. */
 	ret->type = XML_SCHEMA_SCHEMA_MAIN;
 	/* Point to the *main* schema. */
 	WXS_CONSTRUCTOR(pctxt)->mainBucket = ret;
@@ -3583,12 +3583,12 @@
 	*/
 	mainSchema->targetNamespace = targetNamespace;
     } else {
-	if (type == XML_SCHEMA_SCHEMA_MAIN) {	    
+	if (type == XML_SCHEMA_SCHEMA_MAIN) {
 	    PERROR_INT("xmlSchemaBucketCreate",
 		"main bucket but it's not the first one");
 	    xmlSchemaBucketFree(ret);
 	    return(NULL);
-	} else if (type == XML_SCHEMA_SCHEMA_IMPORT) {	    
+	} else if (type == XML_SCHEMA_SCHEMA_IMPORT) {
 	    /*
 	    * Create a schema for imports and assign the
 	    * targetNamespace.
@@ -3600,7 +3600,7 @@
 	    }
 	    WXS_IMPBUCKET(ret)->schema->targetNamespace = targetNamespace;
 	}
-    }    
+    }
     if (WXS_IS_BUCKET_IMPMAIN(type)) {
 	int res;
 	/*
@@ -3643,11 +3643,11 @@
 	    if (mainSchema->includes == NULL) {
 		xmlSchemaBucketFree(ret);
 		return(NULL);
-	    }	    
+	    }
 	}
 	xmlSchemaItemListAdd(mainSchema->includes, ret);
     }
-    /* 
+    /*
     * Add to list of all buckets; this is used for lookup
     * during schema construction time only.
     */
@@ -4015,7 +4015,7 @@
 	for (i = 0; i < list->nbItems; i++) {
 	    item = items[i];
 	    if (item == NULL)
-		continue;	    
+		continue;
 	    switch (item->type) {
 		case XML_SCHEMA_TYPE_SIMPLE:
 		case XML_SCHEMA_TYPE_COMPLEX:
@@ -4122,7 +4122,7 @@
 	xmlSchemaItemListPtr list = (xmlSchemaItemListPtr) schema->includes;
 	int i;
 	for (i = 0; i < list->nbItems; i++) {
-	    xmlSchemaBucketFree((xmlSchemaBucketPtr) list->items[i]);	
+	    xmlSchemaBucketFree((xmlSchemaBucketPtr) list->items[i]);
 	}
 	xmlSchemaItemListFree(list);
     }
@@ -4330,7 +4330,7 @@
 /**
  * xmlSchemaAttrUsesDump:
  * @uses:  attribute uses list
- * @output:  the file output 
+ * @output:  the file output
  *
  * Dumps a list of attribute use components.
  */
@@ -4347,7 +4347,7 @@
     if ((uses == NULL) || (uses->nbItems == 0))
         return;
 
-    fprintf(output, "  attributes:\n");    
+    fprintf(output, "  attributes:\n");
     for (i = 0; i < uses->nbItems; i++) {
 	use = uses->items[i];
 	if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {
@@ -4533,7 +4533,7 @@
 	return;
     do {
 	fprintf(output, "IDC:   BINDING '%s' (%d)\n",
-	    xmlSchemaGetComponentQName(&str, 
+	    xmlSchemaGetComponentQName(&str,
 		bind->definition), bind->nbNodes);
 	FREE_AND_NULL(str)
 	for (i = 0; i < bind->nbNodes; i++) {
@@ -4634,7 +4634,7 @@
     xmlAttrPtr prop;
 
     if ((node == NULL) || (name == NULL))
-	return(NULL);    
+	return(NULL);
     prop = node->properties;
     while (prop != NULL) {
 	if ((prop->ns != NULL) &&
@@ -4729,12 +4729,12 @@
                  const xmlChar * nsName)
 {
     xmlSchemaElementPtr ret = NULL;
-    
+
     if ((name == NULL) || (schema == NULL))
         return(NULL);
     if (schema != NULL) {
 	WXS_FIND_GLOBAL_ITEM(elemDecl)
-    }   
+    }
 exit:
 #ifdef DEBUG
     if (ret == NULL) {
@@ -4765,9 +4765,9 @@
     xmlSchemaTypePtr ret = NULL;
 
     if (name == NULL)
-        return (NULL);    
+        return (NULL);
     /* First try the built-in types. */
-    if ((nsName != NULL) && xmlStrEqual(nsName, xmlSchemaNs)) {	
+    if ((nsName != NULL) && xmlStrEqual(nsName, xmlSchemaNs)) {
 	ret = xmlSchemaGetPredefinedType(name, nsName);
 	if (ret != NULL)
 	    goto exit;
@@ -4780,7 +4780,7 @@
     }
     if (schema != NULL) {
 	WXS_FIND_GLOBAL_ITEM(typeDecl)
-    } 
+    }
 exit:
 
 #ifdef DEBUG
@@ -4891,7 +4891,7 @@
 	WXS_FIND_GLOBAL_ITEM(groupDecl)
     }
 exit:
-    
+
 #ifdef DEBUG
     if (ret == NULL) {
         if (nsName == NULL)
@@ -5000,7 +5000,7 @@
 	str++;
 	len--;
     }
-    
+
     return (1);
 }
 
@@ -5061,7 +5061,7 @@
 		default:
 		    /* Should not be hit. */
 		    return(NULL);
-	    }		
+	    }
 	}
     }
 subschemas:
@@ -5209,7 +5209,7 @@
 * resolve references to the redefined components and to check constraints.
 */
 static xmlSchemaRedefPtr
-xmlSchemaAddRedef(xmlSchemaParserCtxtPtr pctxt,		  
+xmlSchemaAddRedef(xmlSchemaParserCtxtPtr pctxt,
 		  xmlSchemaBucketPtr targetBucket,
 		  void *item,
 		  const xmlChar *refName,
@@ -5272,7 +5272,7 @@
     ret->type = XML_SCHEMA_TYPE_ATTRIBUTEGROUP;
     ret->name = name;
     ret->targetNamespace = nsName;
-    ret->node = node;   
+    ret->node = node;
 
     /* TODO: Remove the flag. */
     ret->flags |= XML_SCHEMAS_ATTRGROUP_GLOBAL;
@@ -5282,7 +5282,7 @@
 	if (pctxt->redef == NULL) {
 	    xmlFree(ret);
 	    return(NULL);
-	}	    
+	}
 	pctxt->redefCounter = 0;
     }
     WXS_ADD_GLOBAL(pctxt, ret);
@@ -5371,13 +5371,13 @@
 	    if (ctxt->redef == NULL) {
 		xmlFree(ret);
 		return(NULL);
-	    }	    
+	    }
 	    ctxt->redefCounter = 0;
 	}
 	WXS_ADD_GLOBAL(ctxt, ret);
     } else
 	WXS_ADD_LOCAL(ctxt, ret);
-    WXS_ADD_PENDING(ctxt, ret);    
+    WXS_ADD_PENDING(ctxt, ret);
     return (ret);
 }
 
@@ -5509,7 +5509,7 @@
     ret->children = NULL;
 
     WXS_ADD_LOCAL(ctxt, ret);
-    /* 
+    /*
     * Note that addition to pending components will be done locally
     * to the specific parsing function, since the most particles
     * need not to be fixed up (i.e. the reference to be resolved).
@@ -5558,7 +5558,7 @@
 	if (ctxt->redef == NULL) {
 	    xmlFree(ret);
 	    return(NULL);
-	}	    
+	}
 	ctxt->redefCounter = 0;
     }
     WXS_ADD_GLOBAL(ctxt, ret);
@@ -5595,7 +5595,7 @@
                   const xmlChar *name, const xmlChar *nsName,
 		  int category, xmlNodePtr node)
 {
-    xmlSchemaIDCPtr ret = NULL;    
+    xmlSchemaIDCPtr ret = NULL;
 
     if ((ctxt == NULL) || (schema == NULL) || (name == NULL))
         return (NULL);
@@ -5611,8 +5611,8 @@
     ret->targetNamespace = nsName;
     ret->name = name;
     ret->type = category;
-    ret->node = node;        
-    
+    ret->node = node;
+
     WXS_ADD_GLOBAL(ctxt, ret);
     /*
     * Only keyrefs need to be fixup up.
@@ -5648,7 +5648,7 @@
     }
     memset(ret, 0, sizeof(xmlSchemaWildcard));
     ret->type = type;
-    ret->node = node;    
+    ret->node = node;
     WXS_ADD_LOCAL(ctxt, ret);
     return (ret);
 }
@@ -5704,7 +5704,7 @@
 static xmlSchemaSubstGroupPtr
 xmlSchemaSubstGroupGet(xmlSchemaParserCtxtPtr pctxt,
 		       xmlSchemaElementPtr head)
-{   
+{
     if (WXS_SUBST_GROUPS(pctxt) == NULL)
 	return(NULL);
     return(xmlHashLookup2(WXS_SUBST_GROUPS(pctxt),
@@ -6288,7 +6288,7 @@
 	    ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
 	else
 	    ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
-	xmlSchemaPSimpleTypeErr(pctxt, 
+	xmlSchemaPSimpleTypeErr(pctxt,
 	    ret, ownerItem, (xmlNodePtr) attr,
 	    type, NULL, value, NULL, NULL, NULL);
     }
@@ -6352,7 +6352,7 @@
  * number otherwise and -1 in case of an internal or API error.
  */
 static int
-xmlSchemaPValAttr(xmlSchemaParserCtxtPtr ctxt,		       
+xmlSchemaPValAttr(xmlSchemaParserCtxtPtr ctxt,
 		       xmlSchemaBasicItemPtr ownerItem,
 		       xmlNodePtr ownerElem,
 		       const char *name,
@@ -6442,7 +6442,7 @@
  * @type:  the hosting type where the attributes will be anchored
  *
  * Parses attribute uses and attribute declarations and
- * attribute group references. 
+ * attribute group references.
  */
 static int
 xmlSchemaParseLocalAttributes(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
@@ -7085,7 +7085,7 @@
 			     int parentType)
 {
     const xmlChar *attrValue, *name = NULL, *ns = NULL;
-    xmlSchemaAttributeUsePtr use = NULL;    
+    xmlSchemaAttributeUsePtr use = NULL;
     xmlNodePtr child = NULL;
     xmlAttrPtr attr;
     const xmlChar *tmpNs = NULL, *tmpName = NULL, *defValue = NULL;
@@ -7139,7 +7139,7 @@
 		    /*
 		    * Evaluate the target namespace
 		    */
-		    hasForm = 1;		    
+		    hasForm = 1;
 		    attrValue = xmlSchemaGetNodeContent(pctxt,
 			(xmlNodePtr) attr);
 		    if (xmlStrEqual(attrValue, BAD_CAST "qualified")) {
@@ -7210,7 +7210,7 @@
 
 attr_next:
 	attr = attr->next;
-    }        
+    }
     /*
     * 3.2.3 : 2
     * If default and use are both present, use must have
@@ -7236,7 +7236,7 @@
 
 	/* TODO: move XML_SCHEMAS_QUALIF_ATTR to the parser. */
 	if ((! hasForm) && (schema->flags & XML_SCHEMAS_QUALIF_ATTR))
-	    ns = pctxt->targetNamespace;		
+	    ns = pctxt->targetNamespace;
 	/*
 	* 3.2.6 Schema Component Constraint: xsi: Not Allowed
 	* TODO: Move this to the component layer.
@@ -7293,7 +7293,7 @@
 	use->attrDecl = attrDecl;
 	/*
 	* Value constraint.
-	*/	
+	*/
 	if (defValue != NULL) {
 	    attrDecl->defValue = defValue;
 	    if (defValueType == WXS_ATTR_DEF_VAL_FIXED)
@@ -7333,14 +7333,14 @@
 	    if (defValueType == WXS_ATTR_DEF_VAL_FIXED)
 		use->flags |= XML_SCHEMA_ATTR_USE_FIXED;
     }
-    
+
 check_children:
     /*
     * And now for the children...
     */
     child = node->children;
     if (occurs == XML_SCHEMAS_ATTR_USE_PROHIBITED) {
-	xmlSchemaAttributeUseProhibPtr prohib;	
+	xmlSchemaAttributeUseProhibPtr prohib;
 
 	if (IS_SCHEMA(child, "annotation")) {
 	    xmlSchemaParseAnnotation(pctxt, child, 0);
@@ -7355,7 +7355,7 @@
 	/*
 	* Check for pointlessness of attribute prohibitions.
 	*/
-	if (parentType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP) {		
+	if (parentType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP) {
 	    xmlSchemaCustomWarning(ACTXT_CAST pctxt,
 		XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH,
 		node, NULL,
@@ -7373,7 +7373,7 @@
 	    return(NULL);
 	}
 	if (! isRef) {
-	    tmpName = name; 
+	    tmpName = name;
 	    tmpNs = ns;
 	}
 	/*
@@ -7381,7 +7381,7 @@
 	*/
 	if (uses) {
 	    int i;
-	    
+
 	    for (i = 0; i < uses->nbItems; i++) {
 		use = uses->items[i];
 		if ((use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) &&
@@ -7389,16 +7389,16 @@
 		    (tmpNs == (WXS_ATTR_PROHIB_CAST use)->targetNamespace))
 		{
 		    xmlChar *str = NULL;
-		    
+
 		    xmlSchemaCustomWarning(ACTXT_CAST pctxt,
 			XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH,
 			node, NULL,
 			"Skipping duplicate attribute use prohibition '%s'",
 			xmlSchemaFormatQName(&str, tmpNs, tmpName),
 			NULL, NULL);
-		    FREE_AND_NULL(str)			
+		    FREE_AND_NULL(str)
 		    return(NULL);
-		}	
+		}
 	    }
 	}
 	/*
@@ -7417,7 +7417,7 @@
 	    WXS_ADD_PENDING(pctxt, prohib);
 	}
 	return(WXS_BASIC_CAST prohib);
-    } else {        
+    } else {
 	if (IS_SCHEMA(child, "annotation")) {
 	    /*
 	    * TODO: Should this go into the attr decl?
@@ -7464,7 +7464,7 @@
 		NULL, node, child, NULL,
 		"(annotation?, simpleType?)");
 	}
-    }   
+    }
     return (WXS_BASIC_CAST use);
 }
 
@@ -7486,7 +7486,7 @@
      * 3.2.3 Constraints on XML Representations of Attribute Declarations
      */
     if ((pctxt == NULL) || (schema == NULL) || (node == NULL))
-        return (NULL);        
+        return (NULL);
     /*
     * 3.2.3 : 3.1
     * One of ref or name must be present, but not both
@@ -7532,7 +7532,7 @@
     if (ret == NULL)
 	return (NULL);
     ret->flags |= XML_SCHEMAS_ATTR_GLOBAL;
-	
+
     /*
     * Check for illegal attributes.
     */
@@ -7546,7 +7546,7 @@
 		(!xmlStrEqual(attr->name, BAD_CAST "type")))
 	    {
 		xmlSchemaPIllegalAttrErr(pctxt,
-		    XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);		
+		    XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
 	    }
 	} else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) {
 	    xmlSchemaPIllegalAttrErr(pctxt,
@@ -7556,7 +7556,7 @@
     }
     xmlSchemaPValAttrQName(pctxt, schema, NULL,
 	node, "type", &ret->typeNs, &ret->typeName);
-    
+
     xmlSchemaPValAttrID(pctxt, node, BAD_CAST "id");
     /*
     * Attribute "fixed".
@@ -7641,12 +7641,12 @@
 	    XML_SCHEMAP_S4S_ATTR_MISSING,
 	    NULL, node, "ref", NULL);
 	return (NULL);
-    }	
+    }
     xmlSchemaPValAttrNodeQName(pctxt, schema,
 	NULL, attr, &refNs, &ref);
     if (xmlSchemaCheckReference(pctxt, schema, node, attr, refNs) != 0)
 	return(NULL);
-   
+
     /*
     * Check for illegal attributes.
     */
@@ -7704,7 +7704,7 @@
 	*/
 	if (pctxt->redefCounter != 0) {
 	    xmlChar *str = NULL;
-	    
+
 	    xmlSchemaCustomErr(ACTXT_CAST pctxt,
 		XML_SCHEMAP_SRC_REDEFINE, node, NULL,
 		"The redefining attribute group definition "
@@ -7738,7 +7738,7 @@
 	ret->node = node;
 	/* Add to pending items, to be able to resolve the reference. */
 	WXS_ADD_PENDING(pctxt, ret);
-    }    
+    }
     return (ret);
 }
 
@@ -7785,7 +7785,7 @@
     ret = xmlSchemaAddAttributeGroupDefinition(pctxt, schema,
 	name, pctxt->targetNamespace, node);
     if (ret == NULL)
-	return (NULL);	
+	return (NULL);
     /*
     * Check for illegal attributes.
     */
@@ -8185,7 +8185,7 @@
  * Returns the parsed identity-constraint definition.
  */
 static xmlSchemaIDCSelectPtr
-xmlSchemaParseIDCSelectorAndField(xmlSchemaParserCtxtPtr ctxt,			  
+xmlSchemaParseIDCSelectorAndField(xmlSchemaParserCtxtPtr ctxt,
 			  xmlSchemaIDCPtr idc,
 			  xmlNodePtr node,
 			  int isField)
@@ -9195,7 +9195,7 @@
 	    if (attr->ns == NULL) {
 		if (!xmlStrEqual(attr->name, BAD_CAST "id")) {
 		    xmlSchemaPIllegalAttrErr(ctxt,
-			XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); 
+			XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
 		}
 	    } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) {
 		    xmlSchemaPIllegalAttrErr(ctxt,
@@ -9266,9 +9266,9 @@
     * And now for the children...
     */
     oldCtxtType = ctxt->ctxtType;
-    
+
     ctxt->ctxtType = type;
-    
+
     child = node->children;
     if (IS_SCHEMA(child, "annotation")) {
         type->annot = xmlSchemaParseAnnotation(ctxt, child, 1);
@@ -9278,10 +9278,10 @@
 	xmlSchemaPContentErr(ctxt, XML_SCHEMAP_S4S_ELEM_MISSING,
 	    NULL, node, child, NULL,
 	    "(annotation?, (restriction | list | union))");
-    } else if (IS_SCHEMA(child, "restriction")) {	
+    } else if (IS_SCHEMA(child, "restriction")) {
         xmlSchemaParseRestriction(ctxt, schema, child,
-	    XML_SCHEMA_TYPE_SIMPLE);	
-	hasRestriction = 1;	
+	    XML_SCHEMA_TYPE_SIMPLE);
+	hasRestriction = 1;
         child = child->next;
     } else if (IS_SCHEMA(child, "list")) {
         xmlSchemaParseList(ctxt, schema, child);
@@ -9307,7 +9307,7 @@
 	    NULL, node, "This is a redefinition, thus the "
 	    "<simpleType> must have a <restriction> child", NULL);
     }
-    
+
     ctxt->ctxtType = oldCtxtType;
     return (type);
 }
@@ -9373,13 +9373,13 @@
     xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id");
     item = xmlSchemaAddParticle(ctxt, node, min, max);
     if (item == NULL)
-	return (NULL);    
+	return (NULL);
     /*
     * Create a qname-reference and set as the term; it will be substituted
     * for the model group after the reference has been resolved.
     */
     item->children = (xmlSchemaTreeItemPtr)
-	xmlSchemaNewQNameRef(ctxt, XML_SCHEMA_TYPE_GROUP, ref, refNs);    
+	xmlSchemaNewQNameRef(ctxt, XML_SCHEMA_TYPE_GROUP, ref, refNs);
     xmlSchemaPCheckParticleCorrect_2(ctxt, item, node, min, max);
     /*
     * And now for the children...
@@ -9419,7 +9419,7 @@
  * Note that the contraint src-redefine (6.2) can't be applied until
  * references have been resolved. So we will do this at the
  * component fixup level.
- *    
+ *
  * *WARNING* this interface is highly subject to change
  *
  * Returns -1 in case of error, 0 if the declaration is improper and
@@ -9493,7 +9493,7 @@
 	child = child->next;
     }
 
-   
+
 
     if (child != NULL) {
 	xmlSchemaPContentErr(ctxt,
@@ -9631,7 +9631,7 @@
     attr = xmlSchemaGetPropNode(node, "version");
     if (attr != NULL) {
 	res = xmlSchemaPValAttrNode(ctxt, NULL, NULL, attr,
-	    xmlSchemaGetBuiltInType(XML_SCHEMAS_TOKEN), &val);    
+	    xmlSchemaGetBuiltInType(XML_SCHEMAS_TOKEN), &val);
 	HFAILURE;
     }
     */
@@ -9691,7 +9691,7 @@
     }
     attr = xmlSchemaGetPropNode(node, "blockDefault");
     if (attr != NULL) {
-	val = xmlSchemaGetNodeContent(ctxt, (xmlNodePtr) attr);	
+	val = xmlSchemaGetNodeContent(ctxt, (xmlNodePtr) attr);
 	res = xmlSchemaPValAttrBlockFinal(val, &(schema->flags), -1,
 	    XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION,
 	    XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION,
@@ -9752,14 +9752,14 @@
 	    HFAILURE;
 	    HSTOP(ctxt);
 	    if (tmpOldErrs != ctxt->nberrors)
-		goto exit;	    
+		goto exit;
 	} else if (IS_SCHEMA(child, "include")) {
 	    tmpOldErrs = ctxt->nberrors;
 	    res = xmlSchemaParseInclude(ctxt, schema, child);
 	    HFAILURE;
 	    HSTOP(ctxt);
 	    if (tmpOldErrs != ctxt->nberrors)
-		goto exit;	    
+		goto exit;
 	} else if (IS_SCHEMA(child, "redefine")) {
 	    tmpOldErrs = ctxt->nberrors;
 	    res = xmlSchemaParseRedefine(ctxt, schema, child);
@@ -9884,7 +9884,7 @@
     xmlFree(con);
 }
 
-static xmlSchemaConstructionCtxtPtr 
+static xmlSchemaConstructionCtxtPtr
 xmlSchemaConstructionCtxtCreate(xmlDictPtr dict)
 {
     xmlSchemaConstructionCtxtPtr ret;
@@ -9954,10 +9954,10 @@
     xmlSchemaParserCtxtPtr ret;
 
     ret = xmlSchemaParserCtxtCreate();
-    if (ret == NULL)        
+    if (ret == NULL)
         return (NULL);
     ret->dict = dict;
-    xmlDictReference(dict);    
+    xmlDictReference(dict);
     if (URL != NULL)
 	ret->URL = xmlDictLookup(dict, (const xmlChar *) URL, -1);
     return (ret);
@@ -10082,8 +10082,8 @@
     xmlNodePtr node;
     int ret, oldErrs;
     xmlSchemaBucketPtr oldbucket = pctxt->constructor->bucket;
-    
-    /* 
+
+    /*
     * Save old values; reset the *main* schema.
     * URGENT TODO: This is not good; move the per-document information
     * to the parser. Get rid of passing the main schema to the
@@ -10093,9 +10093,9 @@
     oldDoc = schema->doc;
     if (schema->flags != 0)
 	xmlSchemaClearSchemaDefaults(schema);
-    schema->doc = bucket->doc;    
+    schema->doc = bucket->doc;
     pctxt->schema = schema;
-    /* 
+    /*
     * Keep the current target namespace on the parser *not* on the
     * main schema.
     */
@@ -10108,7 +10108,7 @@
 	* We are parsing the schema for schemas!
 	*/
 	pctxt->isS4S = 1;
-    }    
+    }
     /* Mark it as parsed, even if parsing fails. */
     bucket->parsed++;
     /* Compile the schema doc. */
@@ -10132,7 +10132,7 @@
 	ret = pctxt->err;
 	goto exit;
     }
-    
+
 exit:
     WXS_CONSTRUCTOR(pctxt)->bucket = oldbucket;
     /* Restore schema values. */
@@ -10165,7 +10165,7 @@
 	PERROR_INT("xmlSchemaParseNewDoc",
 	    "no constructor");
 	return(-1);
-    }    
+    }
     /* Create and init the temporary parser context. */
     newpctxt = xmlSchemaNewParserCtxtUseDict(
 	(const char *) bucket->schemaLocation, pctxt->dict);
@@ -10173,7 +10173,7 @@
 	return(-1);
     newpctxt->constructor = pctxt->constructor;
     /*
-    * TODO: Can we avoid that the parser knows about the main schema? 
+    * TODO: Can we avoid that the parser knows about the main schema?
     * It would be better if he knows about the current schema bucket
     * only.
     */
@@ -10183,16 +10183,16 @@
     xmlSchemaSetParserStructuredErrors(newpctxt, pctxt->serror,
 	pctxt->errCtxt);
     newpctxt->counter = pctxt->counter;
-    
+
 
     res = xmlSchemaParseNewDocWithContext(newpctxt, schema, bucket);
-    
+
     /* Channel back errors and cleanup the temporary parser context. */
     if (res != 0)
 	pctxt->err = res;
     pctxt->nberrors += newpctxt->nberrors;
     pctxt->counter = newpctxt->counter;
-    newpctxt->constructor = NULL;    
+    newpctxt->constructor = NULL;
     /* Free the parser context. */
     xmlSchemaFreeParserCtxt(newpctxt);
     return(res);
@@ -10217,11 +10217,11 @@
 static const xmlChar *
 xmlSchemaBuildAbsoluteURI(xmlDictPtr dict, const xmlChar* location,
 			  xmlNodePtr ctxtNode)
-{    
+{
     /*
     * Build an absolue location URI.
     */
-    if (location != NULL) {	
+    if (location != NULL) {
 	if (ctxtNode == NULL)
 	    return(location);
 	else {
@@ -10244,7 +10244,7 @@
     }
     return(NULL);
 }
-    
+
 
 
 /**
@@ -10267,8 +10267,8 @@
 		const char *schemaBuffer,
 		int schemaBufferLen,
 		xmlNodePtr invokingNode,
-		const xmlChar *sourceTargetNamespace,		
-		const xmlChar *importNamespace,	
+		const xmlChar *sourceTargetNamespace,
+		const xmlChar *importNamespace,
 		xmlSchemaBucketPtr *bucket)
 {
     const xmlChar *targetNamespace = NULL;
@@ -10279,7 +10279,7 @@
 
     if (bucket != NULL)
 	*bucket = NULL;
-    
+
     switch (type) {
 	case XML_SCHEMA_SCHEMA_IMPORT:
 	case XML_SCHEMA_SCHEMA_MAIN:
@@ -10291,23 +10291,23 @@
 	case XML_SCHEMA_SCHEMA_REDEFINE:
 	    err = XML_SCHEMAP_SRC_REDEFINE;
 	    break;
-    }    
-       
+    }
+
 
     /* Special handling for the main schema:
     * skip the location and relation logic and just parse the doc.
     * We need just a bucket to be returned in this case.
-    */    
+    */
     if ((type == XML_SCHEMA_SCHEMA_MAIN) || (! WXS_HAS_BUCKETS(pctxt)))
-	goto doc_load;	
+	goto doc_load;
 
-    /* Note that we expect the location to be an absulute URI. */ 
+    /* Note that we expect the location to be an absulute URI. */
     if (schemaLocation != NULL) {
 	bkt = xmlSchemaGetSchemaBucket(pctxt, schemaLocation);
 	if ((bkt != NULL) &&
 	    (pctxt->constructor->bucket == bkt)) {
 	    /* Report self-imports/inclusions/redefinitions. */
-	    
+
 	    xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
 		invokingNode, NULL,
 		"The schema must not import/include/redefine itself",
@@ -10320,7 +10320,7 @@
     */
     relation = xmlSchemaSchemaRelationCreate();
     if (relation == NULL)
-	return(-1);    
+	return(-1);
     xmlSchemaSchemaRelationAddChild(pctxt->constructor->bucket,
 	relation);
     relation->type = type;
@@ -10329,7 +10329,7 @@
     * Save the namespace import information.
     */
     if (WXS_IS_BUCKET_IMPMAIN(type)) {
-	relation->importNamespace = importNamespace;	
+	relation->importNamespace = importNamespace;
 	if (schemaLocation == NULL) {
 	    /*
 	    * No location; this is just an import of the namespace.
@@ -10342,7 +10342,7 @@
     }
 
     /* Did we already fetch the doc? */
-    if (bkt != NULL) {		
+    if (bkt != NULL) {
 	/* TODO: The following nasty cases will produce an error. */
 	if ((WXS_IS_BUCKET_IMPMAIN(type)) && (! bkt->imported)) {
 	    /* We included/redefined and then try to import a schema. */
@@ -10364,9 +10364,9 @@
 		"redefined, since it was already imported",
 		schemaLocation, NULL);
 	    goto exit;
-	}	
+	}
     }
-    	
+
     if (WXS_IS_BUCKET_IMPMAIN(type)) {
 	/*
 	* Given that the schemaLocation [attribute] is only a hint, it is open
@@ -10387,7 +10387,7 @@
 	* 5 Attempt to resolve the namespace name to locate such a resource.
 	*
 	* NOTE: (3) and (5) are not supported.
-	*/	
+	*/
 	if (bkt != NULL) {
 	    relation->bucket = bkt;
 	    goto exit;
@@ -10395,7 +10395,7 @@
 	bkt = xmlSchemaGetSchemaBucketByTNS(pctxt,
 	    importNamespace, 1);
 
-	if (bkt != NULL) {	    
+	if (bkt != NULL) {
 	    relation->bucket = bkt;
 	    if (bkt->schemaLocation == NULL) {
 		/* First given location of the schema; load the doc. */
@@ -10421,19 +10421,19 @@
 		}
 		goto exit;
 	    }
-	}	
-	/* 
+	}
+	/*
 	* No bucket + first location: load the doc and create a
 	* bucket.
 	*/
     } else {
 	/* <include> and <redefine> */
 	if (bkt != NULL) {
-	    	    
+
 	    if ((bkt->origTargetNamespace == NULL) &&
 		(bkt->targetNamespace != sourceTargetNamespace)) {
 		xmlSchemaBucketPtr chamel;
-		
+
 		/*
 		* Chameleon include/redefine: skip loading only if it was
 		* aleady build for the targetNamespace of the including
@@ -10458,7 +10458,7 @@
 		    relation->bucket = chamel;
 		    goto exit;
 		}
-		/* 
+		/*
 		* We need to parse the chameleon again for a different
 		* targetNamespace.
 		* CHAMELEON TODO: Optimize this by only parsing the
@@ -10469,7 +10469,7 @@
 	    } else {
 		relation->bucket = bkt;
 		goto exit;
-	    }	    
+	    }
 	}
     }
     if ((bkt != NULL) && (bkt->doc != NULL)) {
@@ -10521,7 +10521,7 @@
 		NULL, NULL, SCHEMAS_PARSE_OPTIONS);
 	    schemaLocation = xmlStrdup(BAD_CAST "in_memory_buffer");
 	    if (doc != NULL)
-		doc->URL = schemaLocation;	    
+		doc->URL = schemaLocation;
 	}
 	/*
 	* For <import>:
@@ -10575,11 +10575,11 @@
     if (doc != NULL) {
 	xmlNodePtr docElem = NULL;
 
-	located = 1;	
+	located = 1;
 	docElem = xmlDocGetRootElement(doc);
 	if (docElem == NULL) {
 	    xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_NOROOT,
-		invokingNode, NULL, 
+		invokingNode, NULL,
 		"The document '%s' has no document element",
 		schemaLocation, NULL);
 	    goto exit_error;
@@ -10598,14 +10598,14 @@
 		schemaLocation, NULL);
 	    goto exit_error;
 	}
-	/* 
+	/*
 	* Note that we don't apply a type check for the
 	* targetNamespace value here.
 	*/
 	targetNamespace = xmlSchemaGetProp(pctxt, docElem,
 	    "targetNamespace");
     }
-    
+
 /* after_doc_loading: */
     if ((bkt == NULL) && located) {
 	/* Only create a bucket if the schema was located. */
@@ -10632,14 +10632,14 @@
 	if (relation != NULL)
 	    relation->bucket = bkt;
     }
-  
+
 exit:
     /*
     * Return the bucket explicitely; this is needed for the
     * main schema.
     */
     if (bucket != NULL)
-	*bucket = bkt;    
+	*bucket = bkt;
     return (0);
 
 exit_error:
@@ -10655,7 +10655,7 @@
 	xmlFreeDoc(doc);
 	if (bkt != NULL)
 	    bkt->doc = NULL;
-    }    
+    }
     return (-1);
 }
 
@@ -10810,11 +10810,11 @@
 	    "Failed to locate a schema at location '%s'. "
 	    "Skipping the import", schemaLocation, NULL, NULL);
     }
-    
-    if ((bucket != NULL) && CAN_PARSE_SCHEMA(bucket)) {	
+
+    if ((bucket != NULL) && CAN_PARSE_SCHEMA(bucket)) {
 	ret = xmlSchemaParseNewDoc(pctxt, schema, bucket);
     }
-    
+
     return (ret);
 }
 
@@ -10896,7 +10896,7 @@
 		XML_SCHEMAP_SRC_REDEFINE,
 		NULL, node,
 		"The schema document '%s' cannot redefine itself.",
-		*schemaLocation);	    
+		*schemaLocation);
 	} else {
 	    xmlSchemaPCustomErr(pctxt,
 		XML_SCHEMAP_SRC_INCLUDE,
@@ -10906,7 +10906,7 @@
 	}
 	goto exit_error;
     }
-    
+
     return(0);
 exit_error:
     return(pctxt->err);
@@ -10936,19 +10936,19 @@
     res = xmlSchemaParseIncludeOrRedefineAttrs(pctxt, schema,
 	node, (xmlChar **) (&schemaLocation), type);
     if (res != 0)
-	return(res);    	   
+	return(res);
     /*
     * Load and add the schema document.
     */
     res = xmlSchemaAddSchemaDoc(pctxt, type, schemaLocation, NULL,
 	NULL, 0, node, pctxt->targetNamespace, NULL, &bucket);
     if (res != 0)
-	return(res);    
+	return(res);
     /*
     * If we get no schema bucket back, then this means that the schema
     * document could not be located or was broken XML or was not
     * a schema document.
-    */    
+    */
     if ((bucket == NULL) || (bucket->doc == NULL)) {
 	if (type == XML_SCHEMA_SCHEMA_INCLUDE) {
 	    /*
@@ -10990,8 +10990,8 @@
 	* Check targetNamespace sanity before parsing the new schema.
 	* TODO: Note that we won't check further content if the
 	* targetNamespace was bad.
-	*/    
-	if (bucket->origTargetNamespace != NULL) {	    
+	*/
+	if (bucket->origTargetNamespace != NULL) {
 	    /*
 	    * SPEC src-include (2.1)
 	    * "SII has a targetNamespace [attribute], and its ·actual
@@ -11020,7 +11020,7 @@
 		    pctxt->targetNamespace);
 		goto exit_error;
 	    }
-	} else if (pctxt->targetNamespace != NULL) {	    
+	} else if (pctxt->targetNamespace != NULL) {
 	    /*
 	    * Chameleons: the original target namespace will
 	    * differ from the resulting namespace.
@@ -11038,10 +11038,10 @@
 	    }
 	    bucket->targetNamespace = pctxt->targetNamespace;
 	}
-    }    
+    }
     /*
     * Parse the schema.
-    */   
+    */
     if (bucket && (!bucket->parsed) && (bucket->doc != NULL)) {
 	if (isChameleon) {
 	    /* TODO: Get rid of this flag on the schema itself. */
@@ -11058,8 +11058,8 @@
     /*
     * And now for the children...
     */
-    child = node->children;    
-    if (type == XML_SCHEMA_SCHEMA_REDEFINE) {	
+    child = node->children;
+    if (type == XML_SCHEMA_SCHEMA_REDEFINE) {
 	/*
 	* Parse (simpleType | complexType | group | attributeGroup))*
 	*/
@@ -11082,7 +11082,7 @@
 	    } else if (IS_SCHEMA(child, "complexType")) {
 		xmlSchemaParseComplexType(pctxt, schema, child, 1);
 		/* hasRedefinitions = 1; */
-	    } else if (IS_SCHEMA(child, "group")) {		
+	    } else if (IS_SCHEMA(child, "group")) {
 		/* hasRedefinitions = 1; */
 		xmlSchemaParseModelGroupDefinition(pctxt,
 		    schema, child);
@@ -11102,7 +11102,7 @@
 	    */
 	    child = child->next;
 	}
-    }    
+    }
     if (child != NULL) {
 	res = XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED;
 	if (type == XML_SCHEMA_SCHEMA_REDEFINE) {
@@ -11113,8 +11113,8 @@
 	     xmlSchemaPContentErr(pctxt, res,
 		NULL, node, child, NULL,
 		"(annotation?)");
-	}	
-    }       
+	}
+    }
     return(res);
 
 exit_error:
@@ -11164,7 +11164,7 @@
  *     Redefinition Constraints and Semantics (src-redefine)
  *     (6.1), (6.1.1), (6.1.2)
  *
- *   Schema Component Constraint: 
+ *   Schema Component Constraint:
  *     All Group Limited (cos-all-limited) (2)
  *     TODO: Actually this should go to component-level checks,
  *     but is done here due to performance. Move it to an other layer
@@ -11388,7 +11388,7 @@
 			}
 			ctxt->redef->reference = WXS_BASIC_CAST part;
 			ctxt->redefCounter++;
-		    }		        		   
+		    }
 		}
 	    } else if (IS_SCHEMA(child, "any")) {
 		part = (xmlSchemaTreeItemPtr)
@@ -11425,7 +11425,7 @@
 	WXS_ADD_PENDING(ctxt, item);
     }
     if (withParticle)
-	return ((xmlSchemaTreeItemPtr) particle);	
+	return ((xmlSchemaTreeItemPtr) particle);
     else
 	return ((xmlSchemaTreeItemPtr) item);
 }
@@ -11477,7 +11477,7 @@
     */
     xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id");
     /*
-    * Attribute 
+    * Attribute
     */
     /*
     * Extract the base type. The "base" attribute is mandatory if inside
@@ -11526,7 +11526,7 @@
 		type->base = NULL;
 		type->baseNs = NULL;
 	    }
-	}		
+	}
     }
     /*
     * And now for the children...
@@ -11593,7 +11593,7 @@
 	/*
 	* Model group reference <group>.
 	*/
-	} else if (IS_SCHEMA(child, "group")) {	    
+	} else if (IS_SCHEMA(child, "group")) {
 	    type->subtypes = (xmlSchemaTypePtr)
 		xmlSchemaParseModelGroupDefRef(ctxt, schema, child);
 	    /*
@@ -11931,13 +11931,13 @@
 	xmlSchemaPContentErr(ctxt,
 	    XML_SCHEMAP_S4S_ELEM_MISSING,
 	    NULL, node, NULL, NULL,
-	    "(annotation?, (restriction | extension))");	
+	    "(annotation?, (restriction | extension))");
     }
     if (child == NULL) {
 	xmlSchemaPContentErr(ctxt,
 	    XML_SCHEMAP_S4S_ELEM_MISSING,
 	    NULL, node, NULL, NULL,
-	    "(annotation?, (restriction | extension))");	
+	    "(annotation?, (restriction | extension))");
     }
     if (IS_SCHEMA(child, "restriction")) {
         xmlSchemaParseRestriction(ctxt, schema, child,
@@ -12094,7 +12094,7 @@
 	} else if (xmlSchemaPValAttrNode(ctxt, NULL, attr,
 	    xmlSchemaGetBuiltInType(XML_SCHEMAS_NCNAME), &name) != 0) {
 	    return (NULL);
-	}	
+	}
     }
 
     if (topLevel == 0) {
@@ -12183,7 +12183,7 @@
 			    NULL, (xmlNodePtr) attr, NULL,
 			    "(#all | List of (extension | restriction))",
 			    attrValue, NULL, NULL, NULL);
-		    } else 
+		    } else
 			final = 1;
 		} else if (xmlStrEqual(attr->name, BAD_CAST "block")) {
 		    /*
@@ -12201,7 +12201,7 @@
 			    NULL, (xmlNodePtr) attr, NULL,
 			    "(#all | List of (extension | restriction)) ",
 			    attrValue, NULL, NULL, NULL);
-		    } else 
+		    } else
 			block = 1;
 		} else {
 			xmlSchemaPIllegalAttrErr(ctxt,
@@ -12212,7 +12212,7 @@
 		    XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
 	    }
 	} else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) {
-	    xmlSchemaPIllegalAttrErr(ctxt, 
+	    xmlSchemaPIllegalAttrErr(ctxt,
 		XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
 	}
 	attr = attr->next;
@@ -12448,7 +12448,7 @@
 	return(NULL);
     ret->buffer = buffer;
     ret->size = size;
-    ret->dict = xmlDictCreate();    
+    ret->dict = xmlDictCreate();
     return (ret);
 }
 
@@ -12491,7 +12491,7 @@
     if (ctxt == NULL)
         return;
     if (ctxt->doc != NULL && !ctxt->preserve)
-        xmlFreeDoc(ctxt->doc);    
+        xmlFreeDoc(ctxt->doc);
     if (ctxt->vctxt != NULL) {
 	xmlSchemaFreeValidCtxt(ctxt->vctxt);
     }
@@ -12573,7 +12573,7 @@
 	    *  was incorrectly used instead of xmlAutomataNewTransition2()
 	    *  (seems like a copy&paste bug from the XML_SCHEMA_TYPE_ALL
 	    *  section in xmlSchemaBuildAContentModel() ).
-	    * TODO: Check if xmlAutomataNewOnceTrans2() was instead 
+	    * TODO: Check if xmlAutomataNewOnceTrans2() was instead
 	    *  intended for the above "counter" section originally. I.e.,
 	    *  check xs:all with subst-groups.
 	    *
@@ -12582,7 +12582,7 @@
 	    *		       1, 1, member);
 	    */
 	    tmp = xmlAutomataNewTransition2(pctxt->am, start, NULL,
-		member->name, member->targetNamespace, member);	    
+		member->name, member->targetNamespace, member);
 	    xmlAutomataNewEpsilon(pctxt->am, tmp, end);
 	}
     } else {
@@ -12645,11 +12645,11 @@
 	} else if ((particle->maxOccurs >= UNBOUNDED) &&
 	           (particle->minOccurs < 2)) {
 	    /* Special case. */
-	    start = ctxt->state;	    
+	    start = ctxt->state;
 	    ctxt->state = xmlAutomataNewTransition2(ctxt->am, start, NULL,
-		elemDecl->name, elemDecl->targetNamespace, elemDecl);	    
+		elemDecl->name, elemDecl->targetNamespace, elemDecl);
 	    ctxt->state = xmlAutomataNewTransition2(ctxt->am, ctxt->state, ctxt->state,
-		elemDecl->name, elemDecl->targetNamespace, elemDecl);	    
+		elemDecl->name, elemDecl->targetNamespace, elemDecl);
 	} else {
 	    int counter;
 	    int maxOccurs = particle->maxOccurs == UNBOUNDED ?
@@ -12684,7 +12684,7 @@
 			    xmlSchemaParticlePtr particle)
 {
     if (particle == NULL) {
-	PERROR_INT("xmlSchemaBuildAContentModel", "particle is NULL");	    
+	PERROR_INT("xmlSchemaBuildAContentModel", "particle is NULL");
 	return;
     }
     if (particle->children == NULL) {
@@ -13937,7 +13937,7 @@
     if (val != 0)
 	*val = NULL;
 
-    if (attruse->defValue != NULL) {	    
+    if (attruse->defValue != NULL) {
 	*value = attruse->defValue;
 	if (val != NULL)
 	    *val = attruse->defVal;
@@ -14017,12 +14017,12 @@
 				       xmlSchemaItemListPtr baseUses,
 				       xmlSchemaWildcardPtr wild,
 				       xmlSchemaWildcardPtr baseWild)
-{        
+{
     xmlSchemaAttributeUsePtr cur = NULL, bcur;
     int i, j, found; /* err = 0; */
     const xmlChar *bEffValue;
     int effFixed;
-    
+
     if (uses != NULL) {
 	for (i = 0; i < uses->nbItems; i++) {
 	    cur = uses->items[i];
@@ -14030,7 +14030,7 @@
 	    if (baseUses == NULL)
 		goto not_found;
 	    for (j = 0; j < baseUses->nbItems; j++) {
-		bcur = baseUses->items[j];	
+		bcur = baseUses->items[j];
 		if ((WXS_ATTRUSE_DECL_NAME(cur) ==
 			WXS_ATTRUSE_DECL_NAME(bcur)) &&
 		    (WXS_ATTRUSE_DECL_TNS(cur) ==
@@ -14043,7 +14043,7 @@
 		    * namespace}, then  all of the following must be true:"
 		    */
 		    found = 1;
-		    
+
 		    if ((cur->occurs == XML_SCHEMAS_ATTR_USE_OPTIONAL) &&
 			(bcur->occurs == XML_SCHEMAS_ATTR_USE_REQUIRED))
 		    {
@@ -14069,7 +14069,7 @@
 			WXS_ATTRUSE_TYPEDEF(bcur), 0) != 0)
 		    {
 			xmlChar *strA = NULL, *strB = NULL, *strC = NULL;
-			
+
 			/*
 			* SPEC (2.1.2) "R's {attribute declaration}'s
 			* {type definition} must be validly derived from
@@ -14112,7 +14112,7 @@
 			if ((bEffValue != NULL) &&
 			    (effFixed == 1)) {
 			    const xmlChar *rEffValue = NULL;
-			    
+
 			    xmlSchemaGetEffectiveValueConstraint(bcur,
 				&effFixed, &rEffValue, NULL);
 			    /*
@@ -14126,7 +14126,7 @@
 				(! WXS_ARE_DEFAULT_STR_EQUAL(rEffValue, bEffValue)))
 			    {
 				xmlChar *str = NULL;
-				
+
 				xmlSchemaPAttrUseErr4(pctxt,
 				    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3,
 				    WXS_ITEM_NODE(item), item, cur,
@@ -14145,7 +14145,7 @@
 		    break;
 		}
 	    }
-not_found:	
+not_found:
 	    if (!found) {
 		/*
 		* (2.2) "otherwise the {base type definition} must have an
@@ -14159,7 +14159,7 @@
 		    (WXS_ATTRUSE_DECL(cur))->targetNamespace) != 0))
 		{
 		    xmlChar *str = NULL;
-		    
+
 		    xmlSchemaPAttrUseErr4(pctxt,
 			XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2,
 			WXS_ITEM_NODE(item), item, cur,
@@ -14175,7 +14175,7 @@
 	}
     }
     /*
-    * SPEC derivation-ok-restriction (3):    
+    * SPEC derivation-ok-restriction (3):
     * (3) "For each attribute use in the {attribute uses} of the {base type
     * definition} whose {required} is true, there must be an attribute
     * use with an {attribute declaration} with the same {name} and
@@ -14190,7 +14190,7 @@
 	    found = 0;
 	    if (uses != NULL) {
 		for (i = 0; i < uses->nbItems; i++) {
-		    cur = uses->items[i];	
+		    cur = uses->items[i];
 		    if ((WXS_ATTRUSE_DECL_NAME(cur) ==
 			WXS_ATTRUSE_DECL_NAME(bcur)) &&
 			(WXS_ATTRUSE_DECL_TNS(cur) ==
@@ -14202,7 +14202,7 @@
 	    }
 	    if (!found) {
 		xmlChar *strA = NULL, *strB = NULL;
-		
+
 		xmlSchemaCustomErr4(ACTXT_CAST pctxt,
 		    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3,
 		    NULL, item,
@@ -14224,19 +14224,19 @@
 	/*
 	* (4) "If there is an {attribute wildcard}, all of the
 	* following must be true:"
-	*/   
+	*/
 	if (baseWild == NULL) {
 	    xmlChar *str = NULL;
 
 	    /*
 	    * (4.1) "The {base type definition} must also have one."
-	    */	    
+	    */
 	    xmlSchemaCustomErr4(ACTXT_CAST pctxt,
 		XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1,
 		NULL, item,
 		"The %s has an attribute wildcard, "
 		"but the %s %s '%s' does not have one",
-		WXS_ITEM_TYPE_NAME(item),		    
+		WXS_ITEM_TYPE_NAME(item),
 		WXS_ACTION_STR(action),
 		WXS_ITEM_TYPE_NAME(baseItem),
 		xmlSchemaGetComponentQName(&str, baseItem));
@@ -14316,7 +14316,7 @@
 				  xmlSchemaTypePtr type)
 {
     xmlSchemaTypePtr baseType = NULL;
-    xmlSchemaAttributeUsePtr use;    
+    xmlSchemaAttributeUsePtr use;
     xmlSchemaItemListPtr uses, baseUses, prohibs = NULL;
 
     if (type->baseType == NULL) {
@@ -14324,7 +14324,7 @@
 	    "no base type");
         return (-1);
     }
-    baseType = type->baseType;        
+    baseType = type->baseType;
     if (WXS_IS_TYPE_NOT_FIXED(baseType))
 	if (xmlSchemaTypeFixup(baseType, ACTXT_CAST pctxt) == -1)
 	    return(-1);
@@ -14336,7 +14336,7 @@
     * wildcard, i.e. intersect multiple wildcards.
     * Move attribute prohibitions into a separate list.
     */
-    if (uses != NULL) {	
+    if (uses != NULL) {
 	if (WXS_IS_RESTRICTION(type)) {
 	    /*
 	    * This one will transfer all attr. prohibitions
@@ -14370,7 +14370,7 @@
 
 	if (WXS_IS_RESTRICTION(type)) {
 	    int usesCount;
-	    xmlSchemaAttributeUsePtr tmp; 
+	    xmlSchemaAttributeUsePtr tmp;
 
 	    if (uses != NULL)
 		usesCount = uses->nbItems;
@@ -14420,15 +14420,15 @@
 	    }
 	} else {
 	    /* Extension. */
-	    for (i = 0; i < baseUses->nbItems; i++) {	    
-		use = baseUses->items[i];		
+	    for (i = 0; i < baseUses->nbItems; i++) {
+		use = baseUses->items[i];
 		if (uses == NULL) {
 		    type->attrUses = xmlSchemaItemListCreate();
 		    if (type->attrUses == NULL)
 			goto exit_failure;
 		    uses = type->attrUses;
 		}
-		xmlSchemaItemListAddSize(uses, baseUses->nbItems, use); 
+		xmlSchemaItemListAddSize(uses, baseUses->nbItems, use);
 	    }
 	}
     }
@@ -14448,7 +14448,7 @@
     /*
     * Compute the complete wildcard.
     */
-    if (WXS_IS_EXTENSION(type)) {	
+    if (WXS_IS_EXTENSION(type)) {
 	if (baseType->attributeWildcard != NULL) {
 	    /*
 	    * (3.2.2.1) "If the ·base wildcard· is non-·absent·, then
@@ -14467,14 +14467,14 @@
 		*/
 		if (xmlSchemaUnionWildcards(pctxt, type->attributeWildcard,
 		    baseType->attributeWildcard) == -1)
-		    goto exit_failure;		
+		    goto exit_failure;
 	    } else {
 		/*
 		* (3.2.2.1.1) "If the ·complete wildcard· is ·absent·,
 		* then the ·base wildcard·."
 		*/
 		type->attributeWildcard = baseType->attributeWildcard;
-	    }	 
+	    }
 	} else {
 	    /*
 	    * (3.2.2.2) "otherwise (the ·base wildcard· is ·absent·) the
@@ -14490,7 +14490,7 @@
 	* NOOP
 	*/
     }
-    
+
     return (0);
 
 exit_failure:
@@ -14865,10 +14865,10 @@
 xmlSchemaCheckUnionTypeDefCircularRecur(xmlSchemaParserCtxtPtr pctxt,
 					xmlSchemaTypePtr ctxType,
 					xmlSchemaTypeLinkPtr members)
-{    
+{
     xmlSchemaTypeLinkPtr member;
     xmlSchemaTypePtr memberType;
-    
+
     member = members;
     while (member != NULL) {
 	memberType = member->type;
@@ -14969,7 +14969,7 @@
 	    }
 	    return;
 	}
-    } 
+    }
     /*
     * The ball of letters below means, that if we have a particle
     * which has a QName-helper component as its {term}, we want
@@ -15012,7 +15012,7 @@
 	    * particle's {term}.
 	    */
 	    WXS_TYPE_PARTICLE_TERM(typeDef) = WXS_MODELGROUPDEF_MODEL(groupDef);
-	    
+
 	    if (WXS_MODELGROUPDEF_MODEL(groupDef)->type == XML_SCHEMA_TYPE_ALL) {
 		/*
 		* SPEC cos-all-limited (1.2)
@@ -15609,7 +15609,7 @@
  * @ctxt:  the schema parser context
  * @type:  the simple type definition
  *
- * Checks crc-simple-type constraints. 
+ * Checks crc-simple-type constraints.
  *
  * Returns 0 if the constraints are satisfied,
  * if not a positive error code and -1 on internal
@@ -15624,7 +15624,7 @@
     * src-simple-type.1 The corresponding simple type definition, if any,
     * must satisfy the conditions set out in Constraints on Simple Type
     * Definition Schema Components (§3.14.6).
-    */    
+    */
     if (WXS_IS_RESTRICTION(type)) {
 	/*
 	* src-simple-type.2 "If the <restriction> alternative is chosen,
@@ -15633,7 +15633,7 @@
 	* NOTE: This is checked in the parse function of <restriction>.
 	*/
 	/*
-	* 
+	*
 	*/
     } else if (WXS_IS_LIST(type)) {
 	/* src-simple-type.3 "If the <list> alternative is chosen, either it must have
@@ -15642,8 +15642,8 @@
 	*
 	* NOTE: This is checked in the parse function of <list>.
 	*/
-    } else if (WXS_IS_UNION(type)) {	
-	/* 
+    } else if (WXS_IS_UNION(type)) {
+	/*
 	* src-simple-type.4 is checked in xmlSchemaCheckUnionTypeDefCircular().
 	*/
     }
@@ -15798,7 +15798,7 @@
 	*/
 	xmlSchemaCustomErr(ACTXT_CAST pctxt,
 	    XML_SCHEMAP_SRC_CT_1,
-	    NULL, WXS_BASIC_CAST type, 
+	    NULL, WXS_BASIC_CAST type,
 	    "If the base type is a simple type, the derivation method must be "
 	    "'extension'", NULL, NULL);
 	return (XML_SCHEMAP_SRC_CT_1);
@@ -15815,7 +15815,7 @@
     *   - attribute uses need to be already inherited (apply attr. prohibitions)
     *   - attribute group references need to be expanded already
     *   - simple types need to be typefixed already
-    */    
+    */
     if (type->attrUses &&
 	(((xmlSchemaItemListPtr) type->attrUses)->nbItems > 1))
     {
@@ -15825,8 +15825,8 @@
 
 	for (i = uses->nbItems -1; i >= 0; i--) {
 	    use = uses->items[i];
-	    
-	    /* 
+
+	    /*
 	    * SPEC ct-props-correct
 	    * (4) "Two distinct attribute declarations in the
 	    * {attribute uses} must not have identical {name}s and
@@ -15867,10 +15867,10 @@
 	    if (WXS_ATTRUSE_TYPEDEF(use) != NULL) {
 		if (xmlSchemaIsDerivedFromBuiltInType(
 		    WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID))
-		{		
+		{
 		    if (hasId) {
 			xmlChar *str = NULL;
-			
+
 			xmlSchemaCustomErr(ACTXT_CAST pctxt,
 			    XML_SCHEMAP_AG_PROPS_CORRECT,
 			    NULL, WXS_BASIC_CAST type,
@@ -15884,7 +15884,7 @@
 			if (xmlSchemaItemListRemove(uses, i) == -1)
 			    goto exit_failure;
 		    }
-		    
+
 		    hasId = 1;
 		}
 	    }
@@ -16037,7 +16037,7 @@
     * SPEC (1) "If the {base type definition} is a complex type definition,
     * then all of the following must be true:"
     */
-    if (WXS_IS_COMPLEX(base)) {	
+    if (WXS_IS_COMPLEX(base)) {
 	/*
 	* SPEC (1.1) "The {final} of the {base type definition} must not
 	* contain extension."
@@ -16050,7 +16050,7 @@
 		"contains 'extension'", NULL);
 	    return (XML_SCHEMAP_COS_CT_EXTENDS_1_1);
 	}
-	
+
 	/*
 	* ATTENTION: The constrains (1.2) and (1.3) are not applied,
 	* since they are automatically satisfied through the
@@ -16094,11 +16094,11 @@
 		}
 		if (! found) {
 		    xmlChar *str = NULL;
-		
+
 		    xmlSchemaCustomErr(ACTXT_CAST ctxt,
 			XML_SCHEMAP_COS_CT_EXTENDS_1_2,
 			NULL, WXS_BASIC_CAST type,
-			/* 
+			/*
 			* TODO: The report does not indicate that also the
 			* type needs to be the same.
 			*/
@@ -16118,7 +16118,7 @@
 	* of the complex  type definition's {attribute wildcard}'s {namespace
 	* constraint}, as defined by Wildcard Subset (§3.10.6)."
 	*/
-  
+
 	/*
 	* MAYBE TODO: Enable if ever needed. But this will be needed only
 	* if created the type via a schema construction API.
@@ -16126,7 +16126,7 @@
 	if (base->attributeWildcard != NULL) {
 	    if (type->attributeWilcard == NULL) {
 		xmlChar *str = NULL;
-		
+
 		xmlSchemaCustomErr(ACTXT_CAST pctxt,
 		    XML_SCHEMAP_COS_CT_EXTENDS_1_3,
 		    NULL, type,
@@ -16139,7 +16139,7 @@
 		base->attributeWildcard, type->attributeWildcard))
 	    {
 		xmlChar *str = NULL;
-		
+
 		xmlSchemaCustomErr(ACTXT_CAST pctxt,
 		    XML_SCHEMAP_COS_CT_EXTENDS_1_3,
 		    NULL, type,
@@ -16293,7 +16293,7 @@
     */
     base = type->baseType;
     if (! WXS_IS_COMPLEX(base)) {
-	xmlSchemaCustomErr(ACTXT_CAST ctxt,	    
+	xmlSchemaCustomErr(ACTXT_CAST ctxt,
 	    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1,
 	    type->node, WXS_BASIC_CAST type,
 	    "The base type must be a complex type", NULL, NULL);
@@ -16304,7 +16304,7 @@
 	* SPEC (1) "The {base type definition} must be a complex type
 	* definition whose {final} does not contain restriction."
 	*/
-	xmlSchemaCustomErr(ACTXT_CAST ctxt,	    
+	xmlSchemaCustomErr(ACTXT_CAST ctxt,
 	    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1,
 	    type->node, WXS_BASIC_CAST type,
 	    "The 'final' of the base type definition "
@@ -16355,7 +16355,7 @@
 	    *
 	    * ATTENTION TODO: This seems not needed if the type implicitely
 	    * derived from the base type.
-	    * 
+	    *
 	    */
 	    err = xmlSchemaCheckCOSSTDerivedOK(ACTXT_CAST ctxt,
 		type->contentTypeDef, base->contentTypeDef, 0);
@@ -16429,7 +16429,7 @@
 	/*
 	* SPEC (5.4.1.1) "The {content type} of the complex type definition
 	* itself must be element-only"
-	*/	 
+	*/
 	if (WXS_HAS_MIXED_CONTENT(type) && (! WXS_HAS_MIXED_CONTENT(base))) {
 	    /*
 	    * SPEC (5.4.1.2) "The {content type} of the complex type
@@ -16586,11 +16586,11 @@
 		if (! xmlSchemaIsParticleEmptiable(
 		    (xmlSchemaParticlePtr) base->subtypes)) {
 		    ret = XML_SCHEMAP_SRC_CT_1;
-		} else 
+		} else
 		    /*
 		    * Attention: at this point the <simpleType> child is in
 		    * ->contentTypeDef (put there during parsing).
-		    */		    
+		    */
 		    if (type->contentTypeDef == NULL) {
 		    xmlChar *str = NULL;
 		    /*
@@ -17131,7 +17131,7 @@
 
     /*
     * SPEC st-restrict-facets 1:
-    * "The {variety} of R is the same as that of B."    
+    * "The {variety} of R is the same as that of B."
     */
     /*
     * SPEC st-restrict-facets 2:
@@ -17704,7 +17704,7 @@
 
 static void
 xmlSchemaTypeFixupOptimFacets(xmlSchemaTypePtr type)
-{       
+{
     int has = 0, needVal = 0, normVal = 0;
 
     has	= (type->baseType->flags & XML_SCHEMAS_TYPE_HAS_FACETS) ? 1 : 0;
@@ -17716,7 +17716,7 @@
     }
     if (type->facets != NULL) {
 	xmlSchemaFacetPtr fac;
-	
+
 	for (fac = type->facets; fac != NULL; fac = fac->next) {
 	    switch (fac->type) {
 		case XML_SCHEMA_FACET_WHITESPACE:
@@ -17734,7 +17734,7 @@
 		    has = 1;
 		    break;
 	    }
-	}	
+	}
     }
     if (normVal)
 	type->flags |= XML_SCHEMAS_TYPE_NORMVALUENEEDED;
@@ -17751,24 +17751,24 @@
 	if ((prim->builtInType != XML_SCHEMAS_ANYSIMPLETYPE) &&
 	    (prim->builtInType != XML_SCHEMAS_STRING)) {
 	    type->flags |= XML_SCHEMAS_TYPE_FACETSNEEDVALUE;
-	} 	
-    }       
+	}
+    }
 }
 
 static int
 xmlSchemaTypeFixupWhitespace(xmlSchemaTypePtr type)
 {
-    
-    
+
+
     /*
     * Evaluate the whitespace-facet value.
-    */    
+    */
     if (WXS_IS_LIST(type)) {
 	type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE;
 	return (0);
     } else if (WXS_IS_UNION(type))
 	return (0);
-    
+
     if (type->facetSet != NULL) {
 	xmlSchemaFacetLinkPtr lin;
 
@@ -17792,23 +17792,23 @@
 	}
     }
     /*
-    * For all ·atomic· datatypes other than string (and types ·derived· 
-    * by ·restriction· from it) the value of whiteSpace is fixed to 
+    * For all ·atomic· datatypes other than string (and types ·derived·
+    * by ·restriction· from it) the value of whiteSpace is fixed to
     * collapse
     */
     {
 	xmlSchemaTypePtr anc;
 
-	for (anc = type->baseType; anc != NULL && 
+	for (anc = type->baseType; anc != NULL &&
 		anc->builtInType != XML_SCHEMAS_ANYTYPE;
 		anc = anc->baseType) {
 
 	    if (anc->type == XML_SCHEMA_TYPE_BASIC) {
-		if (anc->builtInType == XML_SCHEMAS_NORMSTRING) {	    
+		if (anc->builtInType == XML_SCHEMAS_NORMSTRING) {
 		    type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_REPLACE;
 
 		} else if ((anc->builtInType == XML_SCHEMAS_STRING) ||
-		    (anc->builtInType == XML_SCHEMAS_ANYSIMPLETYPE)) {		    
+		    (anc->builtInType == XML_SCHEMAS_ANYSIMPLETYPE)) {
 		    type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE;
 
 		} else
@@ -17845,7 +17845,7 @@
     } else if (WXS_IS_UNION(type)) {
 	/*
 	* Corresponds to <simpleType><union>...
-	*/	
+	*/
 	if (type->memberTypes == NULL) {
 	    /*
 	    * This one is really needed, so get out.
@@ -17853,8 +17853,8 @@
 	    PERROR_INT("xmlSchemaFixupSimpleTypeStageOne",
 		"union type has no member-types assigned");
 	    return(-1);
-	}	    
-    } else {    
+	}
+    } else {
 	/*
 	* Corresponds to <simpleType><restriction>...
 	*/
@@ -17969,7 +17969,7 @@
     }
     if (WXS_IS_TYPE_NOT_FIXED(type->baseType))
 	xmlSchemaTypeFixup(type->baseType, ACTXT_CAST pctxt);
-    /* 
+    /*
     * If a member type of a union is a union itself, we need to substitute
     * that member type for its member types.
     * NOTE that this might change in WXS 1.1; i.e. we will keep the union
@@ -17977,9 +17977,9 @@
     */
     if ((type->memberTypes != NULL) &&
 	(xmlSchemaFinishMemberTypeDefinitionsProperty(pctxt, type) == -1))
-	return(-1);        
+	return(-1);
     /*
-    * SPEC src-simple-type 1 
+    * SPEC src-simple-type 1
     * "The corresponding simple type definition, if any, must satisfy
     * the conditions set out in Constraints on Simple Type Definition
     * Schema Components (§3.14.6)."
@@ -17990,7 +17990,7 @@
     */
     res = xmlSchemaCheckSTPropsCorrect(pctxt, type);
     HFAILURE HERROR
-    /* 
+    /*
     * Schema Component Constraint: Derivation Valid (Restriction, Simple)
     * (cos-st-restricts)
     */
@@ -18023,7 +18023,7 @@
     */
     res = xmlSchemaTypeFixupWhitespace(type);
     HFAILURE HERROR
-    xmlSchemaTypeFixupOptimFacets(type);    
+    xmlSchemaTypeFixupOptimFacets(type);
 
 exit_error:
 #ifdef DEBUG_TYPE
@@ -18054,7 +18054,7 @@
 	PERROR_INT("xmlSchemaFixupComplexType",
 	    "missing baseType");
 	goto exit_failure;
-    }    
+    }
     /*
     * Fixup the base type.
     */
@@ -18066,12 +18066,12 @@
 	* TODO: Generate a warning!
 	*/
 	return(0);
-    }	
+    }
     /*
     * This basically checks if the base type can be derived.
     */
     res = xmlSchemaCheckSRCCT(pctxt, type);
-    HFAILURE HERROR   
+    HFAILURE HERROR
     /*
     * Fixup the content type.
     */
@@ -18145,7 +18145,7 @@
 	    type->facets = NULL;
 	    content->facetSet = type->facetSet;
 	    type->facetSet = NULL;
-	    
+
 	    type->contentTypeDef = content;
 	    if (WXS_IS_TYPE_NOT_FIXED(contentBase))
 		xmlSchemaTypeFixup(contentBase, ACTXT_CAST pctxt);
@@ -18154,10 +18154,10 @@
 	    * for circularity here.
 	    */
 	    res = xmlSchemaFixupSimpleTypeStageOne(pctxt, content);
-	    HFAILURE HERROR 
+	    HFAILURE HERROR
 	    res = xmlSchemaFixupSimpleTypeStageTwo(pctxt, content);
-	    HFAILURE HERROR 
-		
+	    HFAILURE HERROR
+
 	} else if ((WXS_IS_COMPLEX(baseType)) &&
 	    (baseType->contentType == XML_SCHEMA_CONTENT_MIXED) &&
 	    (WXS_IS_RESTRICTION(type))) {
@@ -18267,7 +18267,7 @@
 			XML_SCHEMA_TYPE_SEQUENCE, type->node);
 		    if (particle->children == NULL)
 			goto exit_failure;
-		    
+
 		    type->subtypes = (xmlSchemaTypePtr) particle;
 		}
 		dummySequence = 1;
@@ -18580,11 +18580,11 @@
 		    }
 		} else
 		    base = typeDecl;
-	                 
+
 		if (! ctxtGiven) {
 		    /*
 		    * A context is needed if called from RelaxNG.
-		    */		    
+		    */
 		    pctxt = xmlSchemaNewParserCtxt("*");
 		    if (pctxt == NULL)
 			return (-1);
@@ -18595,17 +18595,17 @@
 		* facet->node is just the node holding the facet
 		* definition, *not* the attribute holding the *value*
 		* of the facet.
-		*/		
+		*/
 		ret = xmlSchemaVCheckCVCSimpleType(
 		    ACTXT_CAST pctxt, facet->node, base,
 		    facet->value, &(facet->val), 1, 1, 0);
                 if (ret != 0) {
 		    if (ret < 0) {
 			/* No error message for RelaxNG. */
-			if (ctxtGiven) {			    
+			if (ctxtGiven) {
 			    xmlSchemaCustomErr(ACTXT_CAST pctxt,
 				XML_SCHEMAP_INTERNAL, facet->node, NULL,
-				"Internal error: xmlSchemaCheckFacet, " 
+				"Internal error: xmlSchemaCheckFacet, "
 				"failed to validate the value '%s' of the "
 				"facet '%s' against the base type",
 				facet->value, xmlSchemaFacetTypeToString(facet->type));
@@ -18680,17 +18680,17 @@
 		    /* error code */
 		    xmlSchemaCustomErr4(ACTXT_CAST pctxt,
 			ret, facet->node, WXS_BASIC_CAST typeDecl,
-			"The value '%s' of the facet '%s' is not a valid '%s'",			
+			"The value '%s' of the facet '%s' is not a valid '%s'",
 			facet->value,
 			xmlSchemaFacetTypeToString(facet->type),
-			(facet->type != XML_SCHEMA_FACET_TOTALDIGITS) ? 
+			(facet->type != XML_SCHEMA_FACET_TOTALDIGITS) ?
 			    BAD_CAST "nonNegativeInteger" :
 			    BAD_CAST "positiveInteger",
 			NULL);
 		}
 	    }
 	    break;
-            
+
         case XML_SCHEMA_FACET_WHITESPACE:{
                 if (xmlStrEqual(facet->value, BAD_CAST "preserve")) {
                     facet->whitespace = XML_SCHEMAS_FACET_PRESERVE;
@@ -18903,7 +18903,7 @@
 	{
 	    particle = WXS_PTC_CAST particle->next;
 	    continue;
-	} 
+	}
 	if (WXS_MODELGROUPDEF_MODEL(WXS_PARTICLE_TERM(particle)) == NULL) {
 	    /*
 	    * TODO: Remove the particle.
@@ -18953,7 +18953,7 @@
 	    if (gr == ctxtGr)
 		return(ref);
 	    if (gr->flags & XML_SCHEMAS_ATTRGROUP_MARKED)
-		continue;	    
+		continue;
 	    /*
 	    * Mark as visited to avoid infinite recursion on
 	    * circular references not yet examined.
@@ -18963,12 +18963,12 @@
 	    {
 		gr->flags |= XML_SCHEMAS_ATTRGROUP_MARKED;
 		circ = xmlSchemaCheckAttrGroupCircularRecur(ctxtGr,
-		    (xmlSchemaItemListPtr) gr->attrUses);		
+		    (xmlSchemaItemListPtr) gr->attrUses);
 		gr->flags ^= XML_SCHEMAS_ATTRGROUP_MARKED;
 		if (circ != NULL)
 		    return (circ);
 	    }
-	    
+
 	}
     }
     return (NULL);
@@ -19006,9 +19006,9 @@
 	return(0);
     else {
 	xmlSchemaQNameRefPtr circ;
-	
+
 	circ = xmlSchemaCheckAttrGroupCircularRecur(attrGr,
-	    (xmlSchemaItemListPtr) attrGr->attrUses);	
+	    (xmlSchemaItemListPtr) attrGr->attrUses);
 	if (circ != NULL) {
 	    xmlChar *str = NULL;
 	    /*
@@ -19040,7 +19040,7 @@
  * xmlSchemaExpandAttributeGroupRefs:
  * @pctxt: the parser context
  * @node: the node of the component holding the attribute uses
- * @completeWild: the intersected wildcard to be returned 
+ * @completeWild: the intersected wildcard to be returned
  * @list: the attribute uses
  *
  * Substitutes contained attribute group references
@@ -19069,7 +19069,7 @@
     for (i = 0; i < list->nbItems; i++) {
 	use = list->items[i];
 
-	if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {	    
+	if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {
 	    if (prohibs == NULL) {
 		PERROR_INT("xmlSchemaExpandAttributeGroupRefs",
 		    "unexpected attr prohibition found");
@@ -19084,7 +19084,7 @@
 	    /*
 	    * Note that duplicate prohibitions were already
 	    * handled at parsing time.
-	    */	    
+	    */
 	    /*
 	    * Add to list of prohibitions.
 	    */
@@ -19137,7 +19137,7 @@
 			*completeWild = tmpWild;
 			created = 1;
 		    }
-		    
+
 		    if (xmlSchemaIntersectWildcards(pctxt, *completeWild,
 			gr->attributeWildcard) == -1)
 			return(-1);
@@ -19211,7 +19211,7 @@
 /**
  * xmlSchemaAttributeGroupExpandRefs:
  * @pctxt:  the parser context
- * @attrGr:  the attribute group definition 
+ * @attrGr:  the attribute group definition
  *
  * Computation of:
  * {attribute uses} property
@@ -19223,7 +19223,7 @@
 static int
 xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt,
 				  xmlSchemaAttributeGroupPtr attrGr)
-{  
+{
     if ((attrGr->attrUses == NULL) ||
 	(attrGr->flags & XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED))
 	return(0);
@@ -19231,25 +19231,25 @@
     attrGr->flags |= XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED;
     if (xmlSchemaExpandAttributeGroupRefs(pctxt, WXS_BASIC_CAST attrGr,
 	&(attrGr->attributeWildcard), attrGr->attrUses, NULL) == -1)
-	return(-1);    
+	return(-1);
     return(0);
 }
 
 /**
  * xmlSchemaAttributeGroupExpandRefs:
  * @pctxt:  the parser context
- * @attrGr:  the attribute group definition 
+ * @attrGr:  the attribute group definition
  *
  * Substitutes contained attribute group references
  * for their attribute uses. Wilcards are intersected.
- * 
+ *
  * Schema Component Constraint:
- *    Attribute Group Definition Properties Correct (ag-props-correct) 
+ *    Attribute Group Definition Properties Correct (ag-props-correct)
  */
 static int
 xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
 				  xmlSchemaAttributeGroupPtr attrGr)
-{  
+{
     /*
     * SPEC ag-props-correct
     * (1) "The values of the properties of an attribute group definition
@@ -19257,7 +19257,7 @@
     * Group Definition Schema Component (§3.6.1), modulo the impact of
     * Missing Sub-components (§5.3);"
     */
-    
+
     if ((attrGr->attrUses != NULL) &&
 	(WXS_LIST_CAST attrGr->attrUses)->nbItems > 1)
     {
@@ -19266,7 +19266,7 @@
 	int i, j, hasId = 0;
 
 	for (i = uses->nbItems -1; i >= 0; i--) {
-	    use = uses->items[i];	    
+	    use = uses->items[i];
 	    /*
 	    * SPEC ag-props-correct
 	    * (2) "Two distinct members of the {attribute uses} must not have
@@ -19282,7 +19282,7 @@
 			WXS_ATTRUSE_DECL_TNS(tmp)))
 		    {
 			xmlChar *str = NULL;
-			
+
 			xmlSchemaCustomErr(ACTXT_CAST pctxt,
 			    XML_SCHEMAP_AG_PROPS_CORRECT,
 			    attrGr->node, WXS_BASIC_CAST attrGr,
@@ -19306,13 +19306,13 @@
 	    * are derived from ID."
 	    * TODO: Does 'derived' include member-types of unions?
 	    */
-	    if (WXS_ATTRUSE_TYPEDEF(use) != NULL) {		
+	    if (WXS_ATTRUSE_TYPEDEF(use) != NULL) {
 		if (xmlSchemaIsDerivedFromBuiltInType(
 		    WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID))
-		{		
+		{
 		    if (hasId) {
 			xmlChar *str = NULL;
-			
+
 			xmlSchemaCustomErr(ACTXT_CAST pctxt,
 			    XML_SCHEMAP_AG_PROPS_CORRECT,
 			    attrGr->node, WXS_BASIC_CAST attrGr,
@@ -19325,7 +19325,7 @@
 			FREE_AND_NULL(str);
 			if (xmlSchemaItemListRemove(uses, i) == -1)
 			    return(-1);
-		    }		    
+		    }
 		    hasId = 1;
 		}
 	    }
@@ -19392,7 +19392,7 @@
     * Declaration Schema Component (§3.2.1), modulo the impact of
     * Missing Sub-components (§5.3)."
     */
-    
+
     if (WXS_ATTR_TYPEDEF(attr) == NULL)
 	return(0);
 
@@ -19441,7 +19441,7 @@
 	    return(pctxt->err);
 	}
     }
-   
+
     return(0);
 }
 
@@ -19767,12 +19767,12 @@
  * @ctxtParticle: the first particle of the context component
  * @searchParticle: the element declaration particle to be analysed
  *
- * Schema Component Constraint: Element Declarations Consistent 
+ * Schema Component Constraint: Element Declarations Consistent
  */
 static int
 xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt,
 				    xmlSchemaBasicItemPtr ctxtComponent,
-				    xmlSchemaParticlePtr ctxtParticle,				    
+				    xmlSchemaParticlePtr ctxtParticle,
 				    xmlSchemaParticlePtr searchParticle,
 				    xmlSchemaParticlePtr curParticle,
 				    int search)
@@ -19781,7 +19781,7 @@
 
     int ret = 0;
     xmlSchemaParticlePtr cur = curParticle;
-    if (curParticle == NULL) {	
+    if (curParticle == NULL) {
 	return(0);
     }
     if (WXS_PARTICLE_TERM(curParticle) == NULL) {
@@ -19790,7 +19790,7 @@
 	* might arise due to an invalid "term" component.
 	*/
 	return(0);
-    }    
+    }
     while (cur != NULL) {
 	switch (WXS_PARTICLE_TERM(cur)->type) {
 	    case XML_SCHEMA_TYPE_ANY:
@@ -19800,7 +19800,7 @@
 		    ret = xmlSchemaCheckElementDeclConsistent(pctxt,
 			ctxtComponent, ctxtParticle, cur, ctxtParticle, 1);
 		    if (ret != 0)
-			return(ret);		    
+			return(ret);
 		} else {
 		    xmlSchemaElementPtr elem =
 			WXS_ELEM_CAST(WXS_PARTICLE_TERM(cur));
@@ -19820,7 +19820,7 @@
 			    WXS_PARTICLE_TERM_AS_ELEM(searchParticle)->targetNamespace))
 		    {
 			xmlChar *strA = NULL, *strB = NULL;
-			
+
 			xmlSchemaCustomErr(ACTXT_CAST pctxt,
 			    /* TODO: error code */
 			    XML_SCHEMAP_COS_NONAMBIG,
@@ -19837,16 +19837,16 @@
 			FREE_AND_NULL(strB);
 			return(XML_SCHEMAP_COS_NONAMBIG);
 		    }
-		}	    
+		}
 		break;
-	    case XML_SCHEMA_TYPE_SEQUENCE: {		
+	    case XML_SCHEMA_TYPE_SEQUENCE: {
 		break;
 		}
 	    case XML_SCHEMA_TYPE_CHOICE:{
 		/*
 		xmlSchemaTreeItemPtr sub;
-		
-		sub = WXS_PARTICLE_TERM(particle)->children;  (xmlSchemaParticlePtr) 
+
+		sub = WXS_PARTICLE_TERM(particle)->children;  (xmlSchemaParticlePtr)
 		while (sub != NULL) {
 		    ret = xmlSchemaCheckElementDeclConsistent(pctxt, ctxtComponent,
 			ctxtParticle, ctxtElem);
@@ -19883,7 +19883,7 @@
  * @name:  the name of the attribute
  *
  * Validates the value constraints of an element declaration.
- * Adds substitution group members. 
+ * Adds substitution group members.
  */
 static void
 xmlSchemaCheckElementDeclComponent(xmlSchemaElementPtr elemDecl,
@@ -19898,7 +19898,7 @@
 	/*
 	* Adds substitution group members.
 	*/
-	xmlSchemaCheckElemSubstGroup(ctxt, elemDecl);	
+	xmlSchemaCheckElemSubstGroup(ctxt, elemDecl);
     }
 }
 
@@ -19928,7 +19928,7 @@
 		XML_SCHEMA_EXTRA_QNAMEREF))
 	{
 	    goto next_particle;
-	} 
+	}
 	ref = WXS_QNAME_CAST WXS_PARTICLE_TERM(particle);
 	/*
 	* Resolve the reference.
@@ -19944,7 +19944,7 @@
 		ref->targetNamespace, ref->itemType, NULL);
 	    /* TODO: remove the particle. */
 	    goto next_particle;
-	} 
+	}
 	if (refItem->type == XML_SCHEMA_TYPE_GROUP) {
 	    if (WXS_MODELGROUPDEF_MODEL(refItem) == NULL)
 		/* TODO: remove the particle. */
@@ -19994,9 +19994,9 @@
 
 static int
 xmlSchemaAreValuesEqual(xmlSchemaValPtr x,
-		       xmlSchemaValPtr y) 
-{   
-    xmlSchemaTypePtr tx, ty, ptx, pty;    
+		       xmlSchemaValPtr y)
+{
+    xmlSchemaTypePtr tx, ty, ptx, pty;
     int ret;
 
     while (x != NULL) {
@@ -20042,7 +20042,7 @@
 	if (x != NULL) {
 	    y = xmlSchemaValueGetNext(y);
 	    if (y == NULL)
-		return (0);	    
+		return (0);
 	} else if (xmlSchemaValueGetNext(y) != NULL)
 	    return (0);
 	else
@@ -20092,11 +20092,11 @@
 /**
  * xmlSchemaCheckAttrUsePropsCorrect:
  * @ctxt:  a parser context
- * @use:  an attribute use 
+ * @use:  an attribute use
  *
  * Schema Component Constraint:
  * Attribute Use Correct (au-props-correct)
- * 
+ *
  */
 static int
 xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt,
@@ -20106,7 +20106,7 @@
 	return(-1);
     if ((use->defValue == NULL) || (WXS_ATTRUSE_DECL(use) == NULL) ||
 	((WXS_ATTRUSE_DECL(use))->type != XML_SCHEMA_TYPE_ATTRIBUTE))
-	return(0);	
+	return(0);
 
     /*
     * SPEC au-props-correct (1)
@@ -20115,7 +20115,7 @@
     * Component (§3.5.1), modulo the impact of Missing
     * Sub-components (§5.3)."
     */
-    
+
     if (((WXS_ATTRUSE_DECL(use))->defValue != NULL) &&
 	((WXS_ATTRUSE_DECL(use))->flags & XML_SCHEMAS_ATTR_FIXED) &&
         ((use->flags & XML_SCHEMA_ATTR_USE_FIXED) == 0))
@@ -20135,7 +20135,7 @@
     if ((use->defVal != NULL) && (WXS_ATTRUSE_TYPEDEF(use) != NULL)) {
 	int ret;
 	/*
-	* TODO: The spec seems to be missing a check of the 
+	* TODO: The spec seems to be missing a check of the
 	* value constraint of the attribute use. We will do it here.
 	*/
 	/*
@@ -20152,7 +20152,7 @@
 		NULL, NULL);
 	    return(ctxt->err);
 	}
-	
+
 	ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST ctxt,
 	    use->node, WXS_ATTRUSE_TYPEDEF(use),
 	    use->defValue, &(use->defVal),
@@ -20203,7 +20203,7 @@
 /**
  * xmlSchemaResolveAttrTypeReferences:
  * @item:  an attribute declaration
- * @ctxt:  a parser context 
+ * @ctxt:  a parser context
  *
  * Resolves the referenced type definition component.
  */
@@ -20294,7 +20294,7 @@
 		((xmlSchemaIDCPtr) idc->ref->item)->nbFields) {
 		xmlChar *str = NULL;
 		xmlSchemaIDCPtr refer;
-		
+
 		refer = (xmlSchemaIDCPtr) idc->ref->item;
 		/*
 		* SPEC c-props-correct(2)
@@ -20353,7 +20353,7 @@
     int wasRedefined;
 
     if (redef == NULL)
-	return(0);   	
+	return(0);
 
     do {
 	item = redef->item;
@@ -20368,7 +20368,7 @@
 	*   <redefine>d schema. Currenlty we latter approach is used.
 	*   SUPPLEMENT: It seems that the WG moves towards the latter
 	*   approach, so we are doing it right.
-	*   
+	*
 	*/
 	prev = xmlSchemaFindRedefCompInGraph(
 	    redef->targetBucket, item->type,
@@ -20400,7 +20400,7 @@
 		/*
 		* TODO: error code.
 		* Probably XML_SCHEMAP_SRC_RESOLVE, if this is using the
-		* reference kind.		
+		* reference kind.
 		*/
 		XML_SCHEMAP_SRC_REDEFINE, node, NULL,
 		"The %s '%s' to be redefined could not be found in "
@@ -20408,7 +20408,7 @@
 		WXS_ITEM_TYPE_NAME(item),
 		xmlSchemaFormatQName(&str, redef->refTargetNs,
 		    redef->refName));
-	    FREE_AND_NULL(str);	    
+	    FREE_AND_NULL(str);
 	    err = pctxt->err;
 	    redef = redef->next;
 	    continue;
@@ -20434,7 +20434,7 @@
 		* base type of the redefining type.
 		* TODO: How
 		*/
-		((xmlSchemaTypePtr) item)->baseType = 
+		((xmlSchemaTypePtr) item)->baseType =
 		    (xmlSchemaTypePtr) prev;
 		break;
 	    case XML_SCHEMA_TYPE_GROUP:
@@ -20489,7 +20489,7 @@
 	    default:
 		PERROR_INT("xmlSchemaResolveRedefReferences",
 		    "Unexpected redefined component type");
-		return(-1);	
+		return(-1);
 	}
 	if (wasRedefined) {
 	    xmlChar *str = NULL;
@@ -20499,7 +20499,7 @@
 		node = WXS_ITEM_NODE(redef->reference);
 	    else
 		node = WXS_ITEM_NODE(redef->item);
-	    
+
 	    xmlSchemaCustomErr(ACTXT_CAST pctxt,
 		/* TODO: error code. */
 		XML_SCHEMAP_SRC_REDEFINE,
@@ -20508,12 +20508,12 @@
 		"redefinition of the same component is not supported",
 		xmlSchemaGetComponentDesignation(&str, prev),
 		NULL);
-	    FREE_AND_NULL(str)	    
+	    FREE_AND_NULL(str)
 	    err = pctxt->err;
 	    redef = redef->next;
 	    continue;
 	}
-	redef = redef->next;	
+	redef = redef->next;
     } while (redef != NULL);
 
     return(err);
@@ -20527,7 +20527,7 @@
     xmlSchemaBasicItemPtr item;
 
     if (redef == NULL)
-	return(0);   	
+	return(0);
 
     do {
 	if (redef->target == NULL) {
@@ -20535,7 +20535,7 @@
 	    continue;
 	}
 	item = redef->item;
-		
+
 	switch (item->type) {
 	    case XML_SCHEMA_TYPE_SIMPLE:
 	    case XML_SCHEMA_TYPE_COMPLEX:
@@ -20544,7 +20544,7 @@
 		* type to be 'absent', we'll NULL it.
 		*/
 		(WXS_TYPE_CAST redef->target)->name = NULL;
-		
+
 		/*
 		* TODO: Seems like there's nothing more to do. The normal
 		* inheritance mechanism is used. But not 100% sure.
@@ -20593,7 +20593,7 @@
     } while (redef != NULL);
     return(0);
 }
-	
+
 
 static int
 xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt,
@@ -20627,8 +20627,8 @@
 	return(-1);
     if (bucket->flags & XML_SCHEMA_BUCKET_COMPS_ADDED)
 	return(0);
-    bucket->flags |= XML_SCHEMA_BUCKET_COMPS_ADDED; 
-    
+    bucket->flags |= XML_SCHEMA_BUCKET_COMPS_ADDED;
+
     for (i = 0; i < bucket->globals->nbItems; i++) {
 	item = bucket->globals->items[i];
 	table = NULL;
@@ -20669,12 +20669,12 @@
 	    case XML_SCHEMA_TYPE_NOTATION:
 		name = ((xmlSchemaNotationPtr) item)->name;
 		WXS_GET_GLOBAL_HASH(bucket, notaDecl)
-		break;	    
+		break;
 	    default:
 		PERROR_INT("xmlSchemaAddComponents",
 		    "Unexpected global component type");
-		continue;    		
-	}	
+		continue;
+	}
 	if (*table == NULL) {
 	    *table = xmlHashCreateDict(10, pctxt->dict);
 	    if (*table == NULL) {
@@ -20682,11 +20682,11 @@
 		    "failed to create a component hash table");
 		return(-1);
 	    }
-	}	
+	}
 	err = xmlHashAddEntry(*table, name, item);
-	if (err != 0) {	
+	if (err != 0) {
 	    xmlChar *str = NULL;
-	    
+
 	    xmlSchemaCustomErr(ACTXT_CAST pctxt,
 		XML_SCHEMAP_REDEFINED_TYPE,
 		WXS_ITEM_NODE(item),
@@ -20694,7 +20694,7 @@
 		"A global %s '%s' does already exist",
 		WXS_ITEM_TYPE_NAME(item),
 		xmlSchemaGetComponentQName(&str, item));
-	    FREE_AND_NULL(str);	 
+	    FREE_AND_NULL(str);
 	}
     }
     /*
@@ -20728,23 +20728,23 @@
 
     if ((con->pending == NULL) ||
 	(con->pending->nbItems == 0))
-	return(0);    
+	return(0);
 
     /*
     * Since xmlSchemaFixupComplexType() will create new particles
     * (local components), and those particle components need a bucket
     * on the constructor, we'll assure here that the constructor has
     * a bucket.
-    * TODO: Think about storing locals _only_ on the main bucket.    
-    */    
+    * TODO: Think about storing locals _only_ on the main bucket.
+    */
     if (con->bucket == NULL)
-	con->bucket = rootBucket;    
+	con->bucket = rootBucket;
 
     /* TODO:
     * SPEC (src-redefine):
     * (6.2) "If it has no such self-reference, then all of the
     * following must be true:"
-    
+
     * (6.2.2) The {model group} of the model group definition which
     * corresponds to it per XML Representation of Model Group
     * Definition Schema Components (§3.7.2) must be a ·valid
@@ -20755,7 +20755,7 @@
 
     /*
     * Add global components to the schemata's hash tables.
-    */    
+    */
     xmlSchemaAddComponents(pctxt, rootBucket);
 
     pctxt->ctxtType = NULL;
@@ -20765,7 +20765,7 @@
     * Now that we have parsed *all* the schema document(s) and converted
     * them to schema components, we can resolve references, apply component
     * constraints, create the FSA from the content model, etc.
-    */    
+    */
     /*
     * Resolve references of..
     *
@@ -20786,7 +20786,7 @@
     * 6. IDC key-references:
     *   - the referenced IDC 'key' or 'unique' definition
     * 7. Attribute prohibitions which had a "ref" attribute.
-    */        
+    */
     for (i = 0; i < nbItems; i++) {
 	item = items[i];
 	switch (item->type) {
@@ -20812,7 +20812,7 @@
 		FIXHFAILURE;
 		break;
 	    case XML_SCHEMA_EXTRA_QNAMEREF:
-		if ((WXS_QNAME_CAST item)->itemType == 
+		if ((WXS_QNAME_CAST item)->itemType ==
 		    XML_SCHEMA_TYPE_ATTRIBUTEGROUP)
 		{
 		    xmlSchemaResolveAttrGroupReferences(
@@ -20849,11 +20849,11 @@
     }
     if (pctxt->nberrors != 0)
 	goto exit_error;
-    
+
     /*
     * Now that all references are resolved we
     * can check for circularity of...
-    * 1. the base axis of type definitions 
+    * 1. the base axis of type definitions
     * 2. nested model group definitions
     * 3. nested attribute group definitions
     * TODO: check for circual substitution groups.
@@ -20888,7 +20888,7 @@
 		break;
 	    default:
 		break;
-	}	
+	}
     }
     if (pctxt->nberrors != 0)
 	goto exit_error;
@@ -20904,7 +20904,7 @@
 	item = items[i];
 	switch (item->type) {
 	    case XML_SCHEMA_TYPE_SEQUENCE:
-	    case XML_SCHEMA_TYPE_CHOICE:	
+	    case XML_SCHEMA_TYPE_CHOICE:
 		xmlSchemaModelGroupToModelGroupDefFixup(pctxt,
 		    WXS_MODEL_GROUP_CAST item);
 		break;
@@ -20935,7 +20935,7 @@
     }
     if (pctxt->nberrors != 0)
 	goto exit_error;
-    /* 
+    /*
     * First compute the variety of simple types. This is needed as
     * a seperate step, since otherwise we won't be able to detect
     * circular union types in all cases.
@@ -20965,7 +20965,7 @@
 	switch (item->type) {
             case XML_SCHEMA_TYPE_SIMPLE:
 		if (((xmlSchemaTypePtr) item)->memberTypes != NULL) {
-		    xmlSchemaCheckUnionTypeDefCircular(pctxt,	
+		    xmlSchemaCheckUnionTypeDefCircular(pctxt,
 			(xmlSchemaTypePtr) item);
 		    FIXHFAILURE;
 		}
@@ -20976,7 +20976,7 @@
     }
     if (pctxt->nberrors != 0)
 	goto exit_error;
-    
+
     /*
     * Do the complete type fixup for simple types.
     */
@@ -21004,10 +21004,10 @@
     for (i = 0; i < nbItems; i++) {
 	item = items[i];
 	switch (item->type) {
-	    case XML_SCHEMA_TYPE_ATTRIBUTE:		
+	    case XML_SCHEMA_TYPE_ATTRIBUTE:
 		xmlSchemaCheckAttrPropsCorrect(pctxt, WXS_ATTR_CAST item);
 		FIXHFAILURE;
-		break;	    
+		break;
 	    default:
 		break;
 	}
@@ -21016,7 +21016,7 @@
 	goto exit_error;
     /*
     * Apply constraints for attribute uses.
-    */    
+    */
     for (i = 0; i < nbItems; i++) {
 	item = items[i];
 	switch (item->type) {
@@ -21063,7 +21063,7 @@
     if (pctxt->nberrors != 0)
 	goto exit_error;
 
-    /*    
+    /*
     * Complex types are builded and checked.
     */
     for (i = 0; i < nbItems; i++) {
@@ -21087,8 +21087,8 @@
     * will create particles and model groups in some cases.
     */
     items = (xmlSchemaTreeItemPtr *) con->pending->items;
-    nbItems = con->pending->nbItems;    
-    
+    nbItems = con->pending->nbItems;
+
     /*
     * Apply some constraints for element declarations.
     */
@@ -21097,7 +21097,7 @@
 	switch (item->type) {
 	    case XML_SCHEMA_TYPE_ELEMENT:
 		elemDecl = (xmlSchemaElementPtr) item;
-		
+
 		if ((elemDecl->flags & XML_SCHEMAS_ELEM_INTERNAL_CHECKED) == 0)
 		{
 		    xmlSchemaCheckElementDeclComponent(
@@ -21127,7 +21127,7 @@
     }
     if (pctxt->nberrors != 0)
 	goto exit_error;
- 
+
     /*
     * Finally we can build the automaton from the content model of
     * complex types.
@@ -21148,10 +21148,10 @@
 	goto exit_error;
     /*
     * URGENT TODO: cos-element-consistent
-    */        
-    goto exit;    
+    */
+    goto exit;
 
-exit_error:    
+exit_error:
     ret = pctxt->err;
     goto exit;
 
@@ -21165,12 +21165,12 @@
     * if not cleared here.
     */
     con->bucket = oldbucket;
-    con->pending->nbItems = 0;    
+    con->pending->nbItems = 0;
     if (con->substGroups != NULL) {
 	xmlHashFree(con->substGroups,
 	    (xmlHashDeallocator) xmlSchemaSubstGroupFree);
 	con->substGroups = NULL;
-    }    
+    }
     if (con->redefs != NULL) {
 	xmlSchemaRedefListFree(con->redefs);
 	con->redefs = NULL;
@@ -21233,11 +21233,11 @@
     if (res == -1)
 	goto exit_failure;
     if (res != 0)
-	goto exit;   
+	goto exit;
 
     if (bucket == NULL) {
 	/* TODO: Error code, actually we failed to *locate* the schema. */
-	if (ctxt->URL) 
+	if (ctxt->URL)
 	    xmlSchemaCustomErr(ACTXT_CAST ctxt, XML_SCHEMAP_FAILED_LOAD,
 		NULL, NULL,
 		"Failed to locate the main schema resource at '%s'",
@@ -21248,16 +21248,16 @@
 		"Failed to locate the main schema resource",
 		    NULL, NULL);
 	goto exit;
-    }        
+    }
     /* Then do the parsing for good. */
     if (xmlSchemaParseNewDocWithContext(ctxt, mainSchema, bucket) == -1)
 	goto exit_failure;
     if (ctxt->nberrors != 0)
 	goto exit;
-    
+
     mainSchema->doc = bucket->doc;
     mainSchema->preserve = ctxt->preserve;
-    
+
     ctxt->schema = mainSchema;
 
     if (xmlSchemaFixupComponents(ctxt, WXS_CONSTRUCTOR(ctxt)->mainBucket) == -1)
@@ -21267,8 +21267,8 @@
     * TODO: This is not nice, since we cannot distinguish from the
     * result if there was an internal error or not.
     */
-exit:       
-    if (ctxt->nberrors != 0) {	
+exit:
+    if (ctxt->nberrors != 0) {
 	if (mainSchema) {
 	    xmlSchemaFree(mainSchema);
 	    mainSchema = NULL;
@@ -21282,7 +21282,7 @@
     ctxt->schema = NULL;
     return(mainSchema);
 exit_failure:
-    /* 
+    /*
     * Quite verbose, but should catch internal errors, which were
     * not communitated.
     */
@@ -21296,7 +21296,7 @@
 	ctxt->ownsConstructor = 0;
     }
     PERROR_INT2("xmlSchemaParse",
-	"An internal error occured");    
+	"An internal error occured");
     ctxt->schema = NULL;
     return(NULL);
 }
@@ -21521,11 +21521,11 @@
     * XML_SCHEMA_SCHEMA_MAIN if it is the first schema document.
     */
     ret = xmlSchemaAddSchemaDoc(pctxt, XML_SCHEMA_SCHEMA_IMPORT,
-	location, NULL, NULL, 0, node, NULL, nsName, 
+	location, NULL, NULL, 0, node, NULL, nsName,
 	&bucket);
     if (ret != 0)
-	return(ret);    
-    if (bucket == NULL) {	
+	return(ret);
+    if (bucket == NULL) {
 	/*
 	* Generate a warning that the document could not be located.
 	*/
@@ -21555,17 +21555,17 @@
     pctxt->nberrors = 0;
     pctxt->err = 0;
     pctxt->doc = bucket->doc;
-    
-    ret = xmlSchemaParseNewDocWithContext(pctxt, schema, bucket);        
+
+    ret = xmlSchemaParseNewDocWithContext(pctxt, schema, bucket);
     if (ret == -1) {
 	pctxt->doc = NULL;
 	goto exit_failure;
     }
     /* Paranoid error channelling. */
     if ((ret == 0) && (pctxt->nberrors != 0))
-	ret = pctxt->err;    
-    if (pctxt->nberrors == 0) {	
-	/* 
+	ret = pctxt->err;
+    if (pctxt->nberrors == 0) {
+	/*
 	* Only bother to fixup pending components, if there was
 	* no error yet.
 	* For every XSI acquired schema (and its sub-schemata) we will
@@ -21581,7 +21581,7 @@
 	    vctxt->err = ret;
 	vctxt->nberrors += pctxt->nberrors;
     } else {
-	/* Add to validation error sum. */ 
+	/* Add to validation error sum. */
 	vctxt->nberrors += pctxt->nberrors;
     }
     pctxt->doc = NULL;
@@ -21592,7 +21592,7 @@
 }
 
 static xmlSchemaAttrInfoPtr
-xmlSchemaGetMetaAttrInfo(xmlSchemaValidCtxtPtr vctxt,		      
+xmlSchemaGetMetaAttrInfo(xmlSchemaValidCtxtPtr vctxt,
 			 int metaType)
 {
     if (vctxt->nbAttrInfos == 0)
@@ -21682,7 +21682,7 @@
 		/*
 		* If using @schemaLocation then tuples are expected.
 		* I.e. the namespace name *and* the document's URI.
-		*/		
+		*/
 		xmlSchemaCustomWarning(ACTXT_CAST vctxt, XML_SCHEMAV_MISC,
 		    iattr->node, NULL,
 		    "The value must consist of tuples: the target namespace "
@@ -21711,7 +21711,7 @@
     if (vctxt->sax != NULL) {
 	int i, j;
 	xmlSchemaNodeInfoPtr inode;
-	
+
 	for (i = vctxt->depth; i >= 0; i--) {
 	    if (vctxt->elemInfos[i]->nbNsBindings != 0) {
 		inode = vctxt->elemInfos[i];
@@ -21725,7 +21725,7 @@
 			* Note that the namespace bindings are already
 			* in a string dict.
 			*/
-			return (inode->nsBindings[j+1]);			
+			return (inode->nsBindings[j+1]);
 		    }
 		}
 	    }
@@ -21734,7 +21734,7 @@
 #ifdef LIBXML_WRITER_ENABLED
     } else if (vctxt->reader != NULL) {
 	xmlChar *nsName;
-	
+
 	nsName = xmlTextReaderLookupNamespace(vctxt->reader, prefix);
 	if (nsName != NULL) {
 	    const xmlChar *ret;
@@ -21766,7 +21766,7 @@
 * This one works on the schema of the validation context.
 */
 static int
-xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt, 			  
+xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt,
 			  xmlSchemaPtr schema,
 			  xmlNodePtr node,
 			  const xmlChar *value,
@@ -21791,7 +21791,7 @@
 	if (prefix != NULL) {
 	    const xmlChar *nsName = NULL;
 
-	    if (vctxt != NULL) 
+	    if (vctxt != NULL)
 		nsName = xmlSchemaLookupNamespace(vctxt, BAD_CAST prefix);
 	    else if (node != NULL) {
 		xmlNsPtr ns = xmlSearchNs(node->doc, node, prefix);
@@ -22143,7 +22143,7 @@
     if (bind->nodeTable != NULL)
 	xmlFree(bind->nodeTable);
     if (bind->dupls != NULL)
-	xmlSchemaItemListFree(bind->dupls);	
+	xmlSchemaItemListFree(bind->dupls);
     xmlFree(bind);
 }
 
@@ -22178,12 +22178,12 @@
 
     while (matcher != NULL) {
 	next = matcher->next;
-	if (matcher->keySeqs != NULL) {	    
+	if (matcher->keySeqs != NULL) {
 	    int i;
 	    for (i = 0; i < matcher->sizeKeySeqs; i++)
 		if (matcher->keySeqs[i] != NULL)
 		    xmlFree(matcher->keySeqs[i]);
-	    xmlFree(matcher->keySeqs);	    
+	    xmlFree(matcher->keySeqs);
 	}
 	if (matcher->targets != NULL) {
 	    if (matcher->idcType == XML_SCHEMA_TYPE_IDC_KEYREF) {
@@ -22223,7 +22223,7 @@
 
     while (matcher != NULL) {
 	next = matcher->next;
-	if (matcher->keySeqs != NULL) {	    
+	if (matcher->keySeqs != NULL) {
 	    int i;
 	    /*
 	    * Don't free the array, but only the content.
@@ -22252,7 +22252,7 @@
 	    }
 	    xmlSchemaItemListFree(matcher->targets);
 	    matcher->targets = NULL;
-	}	
+	}
 	matcher->next = NULL;
 	/*
 	* Cache the matcher.
@@ -22294,7 +22294,7 @@
 	sto = vctxt->xpathStatePool;
 	vctxt->xpathStatePool = sto->next;
 	sto->next = NULL;
-    } else {	
+    } else {
 	/*
 	* Create a new state object.
 	*/
@@ -22305,10 +22305,10 @@
 	    return (-1);
 	}
 	memset(sto, 0, sizeof(xmlSchemaIDCStateObj));
-    }	
+    }
     /*
-    * Add to global list. 
-    */	
+    * Add to global list.
+    */
     if (vctxt->xpathStates != NULL)
 	sto->next = vctxt->xpathStates;
     vctxt->xpathStates = sto;
@@ -22328,13 +22328,13 @@
 	VERROR_INT("xmlSchemaIDCAddStateObject",
 	    "failed to create an XPath validation context");
 	return (-1);
-    }    
+    }
     sto->type = type;
     sto->depth = vctxt->depth;
     sto->matcher = matcher;
     sto->sel = sel;
     sto->nbHistory = 0;
-    
+
 #ifdef DEBUG_IDC
     xmlGenericError(xmlGenericErrorContext, "IDC:   STO push '%s'\n",
 	sto->sel->xpath);
@@ -22358,7 +22358,7 @@
 {
     xmlSchemaIDCStateObjPtr sto, head = NULL, first;
     int res, resolved = 0, depth = vctxt->depth;
-        
+
     if (vctxt->xpathStates == NULL)
 	return (0);
 
@@ -22367,8 +22367,8 @@
 #ifdef DEBUG_IDC
     {
 	xmlChar *str = NULL;
-	xmlGenericError(xmlGenericErrorContext, 
-	    "IDC: EVAL on %s, depth %d, type %d\n",	    
+	xmlGenericError(xmlGenericErrorContext,
+	    "IDC: EVAL on %s, depth %d, type %d\n",
 	    xmlSchemaFormatQName(&str, vctxt->inode->nsName,
 		vctxt->inode->localName), depth, nodeType);
 	FREE_AND_NULL(str)
@@ -22382,10 +22382,10 @@
     while (sto != head) {
 #ifdef DEBUG_IDC
 	if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR)
-	    xmlGenericError(xmlGenericErrorContext, "IDC:   ['%s'] selector '%s'\n", 
+	    xmlGenericError(xmlGenericErrorContext, "IDC:   ['%s'] selector '%s'\n",
 		sto->matcher->aidc->def->name, sto->sel->xpath);
 	else
-	    xmlGenericError(xmlGenericErrorContext, "IDC:   ['%s'] field '%s'\n", 
+	    xmlGenericError(xmlGenericErrorContext, "IDC:   ['%s'] field '%s'\n",
 		sto->matcher->aidc->def->name, sto->sel->xpath);
 #endif
 	if (nodeType == XML_ELEMENT_NODE)
@@ -22415,7 +22415,7 @@
 	if (sto->history == NULL) {
 	    sto->history = (int *) xmlMalloc(5 * sizeof(int));
 	    if (sto->history == NULL) {
-		xmlSchemaVErrMemory(NULL, 
+		xmlSchemaVErrMemory(NULL,
 		    "allocating the state object history", NULL);
 		return(-1);
 	    }
@@ -22425,11 +22425,11 @@
 	    sto->history = (int *) xmlRealloc(sto->history,
 		sto->sizeHistory * sizeof(int));
 	    if (sto->history == NULL) {
-		xmlSchemaVErrMemory(NULL, 
+		xmlSchemaVErrMemory(NULL,
 		    "re-allocating the state object history", NULL);
 		return(-1);
 	    }
-	}		
+	}
 	sto->history[sto->nbHistory++] = depth;
 
 #ifdef DEBUG_IDC
@@ -22498,7 +22498,7 @@
     *buf = xmlStrdup(BAD_CAST "[");
     for (i = 0; i < count; i++) {
 	*buf = xmlStrcat(*buf, BAD_CAST "'");
-	res = xmlSchemaGetCanonValueWhtspExt(seq[i]->val, 
+	res = xmlSchemaGetCanonValueWhtspExt(seq[i]->val,
 	    xmlSchemaGetWhiteSpaceFacetValue(seq[i]->type),
 	    &value);
 	if (res == 0)
@@ -22556,7 +22556,7 @@
  *
  * Processes and pops the history items of the IDC state objects.
  * IDC key-sequences are validated/created on IDC bindings.
- * 
+ *
  * Returns 0 on success and -1 on internal errors.
  */
 static int
@@ -22575,13 +22575,13 @@
 #ifdef DEBUG_IDC
     {
 	xmlChar *str = NULL;
-	xmlGenericError(xmlGenericErrorContext, 
+	xmlGenericError(xmlGenericErrorContext,
 	    "IDC: BACK on %s, depth %d\n",
 	    xmlSchemaFormatQName(&str, vctxt->inode->nsName,
 		vctxt->inode->localName), vctxt->depth);
 	FREE_AND_NULL(str)
     }
-#endif    
+#endif
     /*
     * Evaluate the state objects.
     */
@@ -22607,14 +22607,14 @@
 	if (matchDepth != depth) {
 	    sto = sto->next;
 	    continue;
-	}	
+	}
 	if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_FIELD) {
 	    /*
 	    * NOTE: According to
 	    *   http://www.w3.org/Bugs/Public/show_bug.cgi?id=2198
 	    *   ... the simple-content of complex types is also allowed.
 	    */
-	    
+
 	    if (WXS_IS_COMPLEX(type)) {
 		if (WXS_HAS_SIMPLE_CONTENT(type)) {
 		    /*
@@ -22629,17 +22629,17 @@
 		    }
 		} else
 		    simpleType = NULL;
-	    } else 
+	    } else
 		simpleType = type;
 	    if (simpleType == NULL) {
 		xmlChar *str = NULL;
-	
+
 		/*
 		* Not qualified if the field resolves to a node of non
 		* simple type.
-		*/	
+		*/
 		xmlSchemaCustomErr(ACTXT_CAST vctxt,
-		    XML_SCHEMAV_CVC_IDC, NULL,		    
+		    XML_SCHEMAV_CVC_IDC, NULL,
 		    WXS_BASIC_CAST sto->matcher->aidc->def,
 		    "The XPath '%s' of a field of %s does evaluate to a node of "
 		    "non-simple type",
@@ -22649,7 +22649,7 @@
 		sto->nbHistory--;
 		goto deregister_check;
 	    }
-	    
+
 	    if ((key == NULL) && (vctxt->inode->val == NULL)) {
 		/*
 		* Failed to provide the normalized value; maybe
@@ -22665,13 +22665,13 @@
 		xmlSchemaIDCMatcherPtr matcher = sto->matcher;
 		xmlSchemaPSVIIDCKeyPtr *keySeq;
 		int pos, idx;
-		
+
 		/*
 		* The key will be anchored on the matcher's list of
 		* key-sequences. The position in this list is determined
 		* by the target node's depth relative to the matcher's
 		* depth of creation (i.e. the depth of the scope element).
-		* 
+		*
 		* Element        Depth    Pos   List-entries
 		* <scope>          0              NULL
 		*   <bar>          1              NULL
@@ -22682,23 +22682,23 @@
 		* The size of the list is only dependant on the depth of
 		* the tree.
 		* An entry will be NULLed in selector_leave, i.e. when
-		* we hit the target's 
-		*/		    
+		* we hit the target's
+		*/
 		pos = sto->depth - matcher->depth;
 		idx = sto->sel->index;
-		
+
 		/*
 		* Create/grow the array of key-sequences.
 		*/
 		if (matcher->keySeqs == NULL) {
-		    if (pos > 9) 
+		    if (pos > 9)
 			matcher->sizeKeySeqs = pos * 2;
 		    else
 			matcher->sizeKeySeqs = 10;
-		    matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **) 
+		    matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **)
 			xmlMalloc(matcher->sizeKeySeqs *
-			sizeof(xmlSchemaPSVIIDCKeyPtr *));			
-		    if (matcher->keySeqs == NULL) {		
+			sizeof(xmlSchemaPSVIIDCKeyPtr *));
+		    if (matcher->keySeqs == NULL) {
 			xmlSchemaVErrMemory(NULL,
 			    "allocating an array of key-sequences",
 			    NULL);
@@ -22707,9 +22707,9 @@
 		    memset(matcher->keySeqs, 0,
 			matcher->sizeKeySeqs *
 			sizeof(xmlSchemaPSVIIDCKeyPtr *));
-		} else if (pos >= matcher->sizeKeySeqs) {	
+		} else if (pos >= matcher->sizeKeySeqs) {
 		    int i = matcher->sizeKeySeqs;
-		    
+
 		    matcher->sizeKeySeqs *= 2;
 		    matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **)
 			xmlRealloc(matcher->keySeqs,
@@ -22725,15 +22725,15 @@
 		    * The array needs to be NULLed.
 		    * TODO: Use memset?
 		    */
-		    for (; i < matcher->sizeKeySeqs; i++) 
-			matcher->keySeqs[i] = NULL;			
+		    for (; i < matcher->sizeKeySeqs; i++)
+			matcher->keySeqs[i] = NULL;
 		}
-		
+
 		/*
 		* Get/create the key-sequence.
 		*/
-		keySeq = matcher->keySeqs[pos];		    
-		if (keySeq == NULL) {	
+		keySeq = matcher->keySeqs[pos];
+		if (keySeq == NULL) {
 		    goto create_sequence;
 		} else if (keySeq[idx] != NULL) {
 		    xmlChar *str = NULL;
@@ -22744,10 +22744,10 @@
 		    * node, evaluate to either an empty node-set or
 		    * a node-set with exactly one member, which must
 		    * have a simple type.
-		    * 
+		    *
 		    * The key was already set; report an error.
 		    */
-		    xmlSchemaCustomErr(ACTXT_CAST vctxt, 
+		    xmlSchemaCustomErr(ACTXT_CAST vctxt,
 			XML_SCHEMAV_CVC_IDC, NULL,
 			WXS_BASIC_CAST matcher->aidc->def,
 			"The XPath '%s' of a field of %s evaluates to a "
@@ -22758,27 +22758,27 @@
 		    sto->nbHistory--;
 		    goto deregister_check;
 		} else
-		    goto create_key;		
-		
+		    goto create_key;
+
 create_sequence:
 		/*
 		* Create a key-sequence.
 		*/
 		keySeq = (xmlSchemaPSVIIDCKeyPtr *) xmlMalloc(
-		    matcher->aidc->def->nbFields * 
+		    matcher->aidc->def->nbFields *
 		    sizeof(xmlSchemaPSVIIDCKeyPtr));
 		if (keySeq == NULL) {
-		    xmlSchemaVErrMemory(NULL, 
+		    xmlSchemaVErrMemory(NULL,
 			"allocating an IDC key-sequence", NULL);
-		    return(-1);			
-		}	
-		memset(keySeq, 0, matcher->aidc->def->nbFields * 
+		    return(-1);
+		}
+		memset(keySeq, 0, matcher->aidc->def->nbFields *
 		    sizeof(xmlSchemaPSVIIDCKeyPtr));
 		matcher->keySeqs[pos] = keySeq;
 create_key:
 		/*
 		* Create a key once per node only.
-		*/  
+		*/
 		if (key == NULL) {
 		    key = (xmlSchemaPSVIIDCKeyPtr) xmlMalloc(
 			sizeof(xmlSchemaPSVIIDCKey));
@@ -22787,7 +22787,7 @@
 			    "allocating a IDC key", NULL);
 			xmlFree(keySeq);
 			matcher->keySeqs[pos] = NULL;
-			return(-1);			
+			return(-1);
 		    }
 		    /*
 		    * Consume the compiled value.
@@ -22803,10 +22803,10 @@
 			return (-1);
 		    }
 		}
-		keySeq[idx] = key;		    
+		keySeq[idx] = key;
 	    }
 	} else if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) {
-		
+
 	    xmlSchemaPSVIIDCKeyPtr **keySeq = NULL;
 	    /* xmlSchemaPSVIIDCBindingPtr bind; */
 	    xmlSchemaPSVIIDCNodePtr ntItem;
@@ -22817,22 +22817,22 @@
 	    /*
 	    * Here we have the following scenario:
 	    * An IDC 'selector' state object resolved to a target node,
-	    * during the time this target node was in the 
-	    * ancestor-or-self axis, the 'field' state object(s) looked 
-	    * out for matching nodes to create a key-sequence for this 
+	    * during the time this target node was in the
+	    * ancestor-or-self axis, the 'field' state object(s) looked
+	    * out for matching nodes to create a key-sequence for this
 	    * target node. Now we are back to this target node and need
-	    * to put the key-sequence, together with the target node 
-	    * itself, into the node-table of the corresponding IDC 
+	    * to put the key-sequence, together with the target node
+	    * itself, into the node-table of the corresponding IDC
 	    * binding.
 	    */
 	    matcher = sto->matcher;
 	    idc = matcher->aidc->def;
 	    nbKeys = idc->nbFields;
-	    pos = depth - matcher->depth;		
+	    pos = depth - matcher->depth;
 	    /*
 	    * Check if the matcher has any key-sequences at all, plus
 	    * if it has a key-sequence for the current target node.
-	    */		
+	    */
 	    if ((matcher->keySeqs == NULL) ||
 		(matcher->sizeKeySeqs <= pos)) {
 		if (idc->type == XML_SCHEMA_TYPE_IDC_KEY)
@@ -22840,15 +22840,15 @@
 		else
 		    goto selector_leave;
 	    }
-	    
-	    keySeq = &(matcher->keySeqs[pos]);		
+
+	    keySeq = &(matcher->keySeqs[pos]);
 	    if (*keySeq == NULL) {
 		if (idc->type == XML_SCHEMA_TYPE_IDC_KEY)
 		    goto selector_key_error;
 		else
 		    goto selector_leave;
 	    }
-	    
+
 	    for (i = 0; i < nbKeys; i++) {
 		if ((*keySeq)[i] == NULL) {
 		    /*
@@ -22859,14 +22859,14 @@
 			* All fields of a "key" IDC must resolve.
 			*/
 			goto selector_key_error;
-		    }		    
+		    }
 		    goto selector_leave;
 		}
 	    }
 	    /*
 	    * All fields did resolve.
 	    */
-	    
+
 	    /*
 	    * 4.1 If the {identity-constraint category} is unique(/key),
 	    * then no two members of the ·qualified node set· have
@@ -22880,10 +22880,10 @@
 	    bind = xmlSchemaIDCAcquireBinding(vctxt, matcher);
 #endif
 	    targets = xmlSchemaIDCAcquireTargetList(vctxt, matcher);
-	    if ((idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) && 
+	    if ((idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) &&
 		(targets->nbItems != 0)) {
 		xmlSchemaPSVIIDCKeyPtr ckey, bkey, *bkeySeq;
-		
+
 		i = 0;
 		res = 0;
 		/*
@@ -22894,7 +22894,7 @@
 			((xmlSchemaPSVIIDCNodePtr) targets->items[i])->keys;
 		    for (j = 0; j < nbKeys; j++) {
 			ckey = (*keySeq)[j];
-			bkey = bkeySeq[j];							
+			bkey = bkeySeq[j];
 			res = xmlSchemaAreValuesEqual(ckey->val, bkey->val);
 			if (res == -1) {
 			    return (-1);
@@ -22916,10 +22916,10 @@
 		} while (i < targets->nbItems);
 		if (i != targets->nbItems) {
 		    xmlChar *str = NULL, *strB = NULL;
-		    /*   
+		    /*
 		    * TODO: Try to report the key-sequence.
 		    */
-		    xmlSchemaCustomErr(ACTXT_CAST vctxt, 
+		    xmlSchemaCustomErr(ACTXT_CAST vctxt,
 			XML_SCHEMAV_CVC_IDC, NULL,
 			WXS_BASIC_CAST idc,
 			"Duplicate key-sequence %s in %s",
@@ -22937,15 +22937,15 @@
 	    ntItem = (xmlSchemaPSVIIDCNodePtr) xmlMalloc(
 		sizeof(xmlSchemaPSVIIDCNode));
 	    if (ntItem == NULL) {
-		xmlSchemaVErrMemory(NULL, 
+		xmlSchemaVErrMemory(NULL,
 		    "allocating an IDC node-table item", NULL);
 		xmlFree(*keySeq);
 		*keySeq = NULL;
 		return(-1);
-	    }	
+	    }
 	    memset(ntItem, 0, sizeof(xmlSchemaPSVIIDCNode));
-	    
-	    /* 
+
+	    /*
 	    * Store the node-table item in a global list.
 	    */
 	    if (idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) {
@@ -22967,7 +22967,7 @@
 		    xmlFree(ntItem);
 		    xmlFree(*keySeq);
 		    *keySeq = NULL;
-		    return (-1);		    
+		    return (-1);
 		}
 	    }
 	    /*
@@ -22979,11 +22979,11 @@
 	    ntItem->keys = *keySeq;
 	    *keySeq = NULL;
 #if 0
-	    if (xmlSchemaIDCAppendNodeTableItem(bind, ntItem) == -1) {
+	    if (xmlSchemaIDCAppendNodeTableItem(bind, ntItem) == -1)
 #endif
 	    if (xmlSchemaItemListAdd(targets, ntItem) == -1) {
 		if (idc->type == XML_SCHEMA_TYPE_IDC_KEYREF) {
-		    /* 
+		    /*
 		    * Free the item, since keyref items won't be
 		    * put on a global list.
 		    */
@@ -22992,18 +22992,18 @@
 		}
 		return (-1);
 	    }
-	    
+
 	    goto selector_leave;
 selector_key_error:
 	    {
 		xmlChar *str = NULL;
 		/*
-		* 4.2.1 (KEY) The ·target node set· and the 
-		* ·qualified node set· are equal, that is, every 
+		* 4.2.1 (KEY) The ·target node set· and the
+		* ·qualified node set· are equal, that is, every
 		* member of the ·target node set· is also a member
 		* of the ·qualified node set· and vice versa.
 		*/
-		xmlSchemaCustomErr(ACTXT_CAST vctxt, 
+		xmlSchemaCustomErr(ACTXT_CAST vctxt,
 		    XML_SCHEMAV_CVC_IDC, NULL,
 		    WXS_BASIC_CAST idc,
 		    "Not all fields of %s evaluate to a node",
@@ -23019,7 +23019,7 @@
 		*keySeq = NULL;
 	    }
 	} /* if selector */
-	
+
 	sto->nbHistory--;
 
 deregister_check:
@@ -23070,15 +23070,15 @@
     xmlSchemaIDCMatcherPtr matcher, last = NULL;
     xmlSchemaIDCPtr idc, refIdc;
     xmlSchemaIDCAugPtr aidc;
-        
+
     idc = (xmlSchemaIDCPtr) elemDecl->idcs;
     if (idc == NULL)
 	return (0);
-    
+
 #ifdef DEBUG_IDC
     {
 	xmlChar *str = NULL;
-	xmlGenericError(xmlGenericErrorContext, 
+	xmlGenericError(xmlGenericErrorContext,
 	    "IDC: REGISTER on %s, depth %d\n",
 	    (char *) xmlSchemaFormatQName(&str, vctxt->inode->nsName,
 		vctxt->inode->localName), vctxt->depth);
@@ -23119,7 +23119,7 @@
 			"Could not find an augmented IDC item for an IDC "
 			"definition");
 		    return (-1);
-		}		
+		}
 		if ((aidc->keyrefDepth == -1) ||
 		    (vctxt->depth < aidc->keyrefDepth))
 		    aidc->keyrefDepth = vctxt->depth;
@@ -23150,10 +23150,10 @@
 	    vctxt->idcMatcherCache = matcher->nextCached;
 	    matcher->nextCached = NULL;
 	} else {
-	    matcher = (xmlSchemaIDCMatcherPtr) 
+	    matcher = (xmlSchemaIDCMatcherPtr)
 		xmlMalloc(sizeof(xmlSchemaIDCMatcher));
 	    if (matcher == NULL) {
-		xmlSchemaVErrMemory(vctxt, 
+		xmlSchemaVErrMemory(vctxt,
 		    "allocating an IDC matcher", NULL);
 		return (-1);
 	    }
@@ -23166,16 +23166,16 @@
 	last = matcher;
 
 	matcher->type = IDC_MATCHER;
-	matcher->depth = vctxt->depth;	
+	matcher->depth = vctxt->depth;
 	matcher->aidc = aidc;
 	matcher->idcType = aidc->def->type;
-#ifdef DEBUG_IDC	
+#ifdef DEBUG_IDC
 	xmlGenericError(xmlGenericErrorContext, "IDC:   register matcher\n");
-#endif 
+#endif
 	/*
-	* Init the automaton state object. 
+	* Init the automaton state object.
 	*/
-	if (xmlSchemaIDCAddStateObject(vctxt, matcher, 
+	if (xmlSchemaIDCAddStateObject(vctxt, matcher,
 	    idc->selector, XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) == -1)
 	    return (-1);
 
@@ -23192,7 +23192,7 @@
     int res, i, j, k, nbTargets, nbFields, nbDupls, nbNodeTable;
     xmlSchemaPSVIIDCKeyPtr *keys, *ntkeys;
     xmlSchemaPSVIIDCNodePtr *targets, *dupls;
-    
+
     xmlSchemaIDCMatcherPtr matcher = ielem->idcMatchers;
     /* vctxt->createIDCNodeTables */
     while (matcher != NULL) {
@@ -23226,7 +23226,7 @@
 	    nbDupls = bind->dupls->nbItems;
 	} else {
 	    dupls = NULL;
-	    nbDupls = 0;	    
+	    nbDupls = 0;
 	}
 	if (bind->nodeTable != NULL) {
 	    nbNodeTable = bind->nbNodes;
@@ -23239,29 +23239,29 @@
 	    * Transfer all IDC target-nodes to the IDC node-table.
 	    */
 	    bind->nodeTable =
-		(xmlSchemaPSVIIDCNodePtr *) matcher->targets->items;		
+		(xmlSchemaPSVIIDCNodePtr *) matcher->targets->items;
 	    bind->sizeNodes = matcher->targets->sizeItems;
 	    bind->nbNodes = matcher->targets->nbItems;
 
 	    matcher->targets->items = NULL;
 	    matcher->targets->sizeItems = 0;
-	    matcher->targets->nbItems = 0;	    
+	    matcher->targets->nbItems = 0;
 	} else {
 	    /*
 	    * Compare the key-sequences and add to the IDC node-table.
 	    */
 	    nbTargets = matcher->targets->nbItems;
-	    targets = (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items;	
+	    targets = (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items;
 	    nbFields = matcher->aidc->def->nbFields;
 	    i = 0;
 	    do {
 		keys = targets[i]->keys;
-		if (nbDupls) {			
+		if (nbDupls) {
 		    /*
 		    * Search in already found duplicates first.
 		    */
 		    j = 0;
-		    do {						
+		    do {
 			if (nbFields == 1) {
 			    res = xmlSchemaAreValuesEqual(keys[0]->val,
 				dupls[j]->keys[0]->val);
@@ -23296,11 +23296,11 @@
 			    }
 			}
 			j++;
-		    } while (j < nbDupls);		    
+		    } while (j < nbDupls);
 		}
 		if (nbNodeTable) {
 		    j = 0;
-		    do {						
+		    do {
 			if (nbFields == 1) {
 			    res = xmlSchemaAreValuesEqual(keys[0]->val,
 				bind->nodeTable[j]->keys[0]->val);
@@ -23327,7 +23327,7 @@
 				    goto next_node_table_entry;
 				}
 			    }
-			}			
+			}
 			/*
 			* Add the duplicate to the list of duplicates.
 			*/
@@ -23335,7 +23335,7 @@
 			    bind->dupls = xmlSchemaItemListCreate();
 			    if (bind->dupls == NULL)
 				goto internal_error;
-			}		    
+			}
 			if (xmlSchemaItemListAdd(bind->dupls, bind->nodeTable[j]) == -1)
 			    goto internal_error;
 			/*
@@ -23370,12 +23370,12 @@
 }
 
 /**
- * xmlSchemaBubbleIDCNodeTables: 
+ * xmlSchemaBubbleIDCNodeTables:
  * @depth: the current tree depth
  *
- * Merges IDC bindings of an element at @depth into the corresponding IDC 
- * bindings of its parent element. If a duplicate note-table entry is found, 
- * both, the parent node-table entry and child entry are discarded from the 
+ * Merges IDC bindings of an element at @depth into the corresponding IDC
+ * bindings of its parent element. If a duplicate note-table entry is found,
+ * both, the parent node-table entry and child entry are discarded from the
  * node-table of the parent.
  *
  * Returns 0 if OK and -1 on internal errors.
@@ -23389,19 +23389,19 @@
     xmlSchemaIDCAugPtr aidc;
     int i, j, k, ret = 0, nbFields, oldNum, oldDupls;
 
-    bind = vctxt->inode->idcTable;        
+    bind = vctxt->inode->idcTable;
     if (bind == NULL) {
 	/* Fine, no table, no bubbles. */
 	return (0);
     }
-    
+
     parTable = &(vctxt->elemInfos[vctxt->depth -1]->idcTable);
     /*
     * Walk all bindings; create new or add to existing bindings.
     * Remove duplicate key-sequences.
     */
     while (bind != NULL) {
-	
+
 	if ((bind->nbNodes == 0) && WXS_ILIST_IS_EMPTY(bind->dupls))
 	    goto next_binding;
 	/*
@@ -23411,7 +23411,7 @@
 	    aidc = vctxt->aidcs;
 	    do {
 		if (aidc->def == bind->definition) {
-		    if ((aidc->keyrefDepth == -1) || 
+		    if ((aidc->keyrefDepth == -1) ||
 			(aidc->keyrefDepth >= vctxt->depth)) {
 			goto next_binding;
 		    }
@@ -23427,7 +23427,7 @@
 	* Search a matching parent binding for the
 	* IDC definition.
 	*/
-	while (parBind != NULL) {	    
+	while (parBind != NULL) {
 	    if (parBind->definition == bind->definition)
 		break;
 	    parBind = parBind->next;
@@ -23435,7 +23435,7 @@
 
 	if (parBind != NULL) {
 	    /*
-	    * Compare every node-table entry of the child node, 
+	    * Compare every node-table entry of the child node,
 	    * i.e. the key-sequence within, ...
 	    */
 	    oldNum = parBind->nbNodes; /* Skip newly added items. */
@@ -23445,12 +23445,12 @@
 		dupls = (xmlSchemaPSVIIDCNodePtr *) parBind->dupls->items;
 	    } else {
 		dupls = NULL;
-		oldDupls = 0;		
+		oldDupls = 0;
 	    }
-	    
+
 	    parNodes = parBind->nodeTable;
 	    nbFields = bind->definition->nbFields;
-	    
+
 	    for (i = 0; i < bind->nbNodes; i++) {
 		node = bind->nodeTable[i];
 		if (node == NULL)
@@ -23460,7 +23460,7 @@
 		* evaluated to be a duplicate key-sequence.
 		*/
 		if (oldDupls) {
-		    j = 0; 
+		    j = 0;
 		    while (j < oldDupls) {
 			if (nbFields == 1) {
 			    ret = xmlSchemaAreValuesEqual(
@@ -23493,12 +23493,12 @@
 			/* Duplicate found. Skip this entry. */
 			continue;
 		    }
-		}		    
+		}
 		/*
 		* ... and with every key-sequence of the parent node.
 		*/
 		if (oldNum) {
-		    j = 0; 
+		    j = 0;
 		    while (j < oldNum) {
 			parNode = parNodes[j];
 			if (nbFields == 1) {
@@ -23511,7 +23511,7 @@
 				j++;
 				continue;
 			    }
-			} else {			    
+			} else {
 			    for (k = 0; k < nbFields; k++) {
 				ret = xmlSchemaAreValuesEqual(
 				    node->keys[k]->val,
@@ -23532,20 +23532,20 @@
 			* Handle duplicates. Move the duplicate in
 			* the parent's node-table to the list of
 			* duplicates.
-			*/			
+			*/
 			oldNum--;
 			parBind->nbNodes--;
 			/*
 			* Move last old item to pos of duplicate.
 			*/
 			parNodes[j] = parNodes[oldNum];
-			
+
 			if (parBind->nbNodes != oldNum) {
 			    /*
-			    * If new items exist, move last new item to 
+			    * If new items exist, move last new item to
 			    * last of old items.
 			    */
-			    parNodes[oldNum] = 
+			    parNodes[oldNum] =
 				parNodes[parBind->nbNodes];
 			}
 			if (parBind->dupls == NULL) {
@@ -23553,31 +23553,31 @@
 			    if (parBind->dupls == NULL)
 				goto internal_error;
 			}
-			xmlSchemaItemListAdd(parBind->dupls, parNode);			
+			xmlSchemaItemListAdd(parBind->dupls, parNode);
 		    } else {
 			/*
-			* Add the node-table entry (node and key-sequence) of 
+			* Add the node-table entry (node and key-sequence) of
 			* the child node to the node table of the parent node.
 			*/
-			if (parBind->nodeTable == NULL) {			
-			    parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *) 
+			if (parBind->nodeTable == NULL) {
+			    parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
 				xmlMalloc(10 * sizeof(xmlSchemaPSVIIDCNodePtr));
 			    if (parBind->nodeTable == NULL) {
-				xmlSchemaVErrMemory(NULL, 
+				xmlSchemaVErrMemory(NULL,
 				    "allocating IDC list of node-table items", NULL);
 				goto internal_error;
 			    }
 			    parBind->sizeNodes = 1;
 			} else if (parBind->nbNodes >= parBind->sizeNodes) {
 			    parBind->sizeNodes *= 2;
-			    parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *) 
-				xmlRealloc(parBind->nodeTable, parBind->sizeNodes * 
+			    parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
+				xmlRealloc(parBind->nodeTable, parBind->sizeNodes *
 				sizeof(xmlSchemaPSVIIDCNodePtr));
 			    if (parBind->nodeTable == NULL) {
-				xmlSchemaVErrMemory(NULL, 
+				xmlSchemaVErrMemory(NULL,
 				    "re-allocating IDC list of node-table items", NULL);
 				goto internal_error;
-			    }			    
+			    }
 			}
 			parNodes = parBind->nodeTable;
 			/*
@@ -23587,9 +23587,9 @@
 			parNodes[parBind->nbNodes++] = node;
 		    }
 
-		}	
-		
-	    }	
+		}
+
+	    }
 	} else {
 	    /*
 	    * No binding for the IDC was found: create a new one and
@@ -23598,7 +23598,7 @@
 	    parBind = xmlSchemaIDCNewBinding(bind->definition);
 	    if (parBind == NULL)
 		goto internal_error;
-	    
+
 	    /*
 	    * TODO: Hmm, how to optimize the initial number of
 	    * allocated entries?
@@ -23624,11 +23624,11 @@
 		    /*
 		    * Copy the entries.
 		    */
-		    parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *) 
+		    parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
 			xmlMalloc(bind->nbNodes *
 			sizeof(xmlSchemaPSVIIDCNodePtr));
 		    if (parBind->nodeTable == NULL) {
-			xmlSchemaVErrMemory(NULL, 
+			xmlSchemaVErrMemory(NULL,
 			    "allocating an array of IDC node-table "
 			    "items", NULL);
 			xmlSchemaIDCFreeBinding(parBind);
@@ -23647,15 +23647,15 @@
 		if (parBind->dupls != NULL)
 		    xmlSchemaItemListFree(parBind->dupls);
 		parBind->dupls = bind->dupls;
-		bind->dupls = NULL;		
+		bind->dupls = NULL;
 	    }
 	    if (*parTable == NULL)
 		*parTable = parBind;
 	    else {
 		parBind->next = *parTable;
 		*parTable = parBind;
-	    }	   
-	}	
+	    }
+	}
 
 next_binding:
 	bind = bind->next;
@@ -23678,7 +23678,7 @@
 {
     xmlSchemaIDCMatcherPtr matcher;
     xmlSchemaPSVIIDCBindingPtr bind;
-    
+
     matcher = vctxt->inode->idcMatchers;
     /*
     * Find a keyref.
@@ -23699,7 +23699,7 @@
 	    */
 	    bind = vctxt->inode->idcTable;
 	    while (bind != NULL) {
-		if ((xmlSchemaIDCPtr) matcher->aidc->def->ref->item == 
+		if ((xmlSchemaIDCPtr) matcher->aidc->def->ref->item ==
 		    bind->definition)
 		    break;
 		bind = bind->next;
@@ -23768,7 +23768,7 @@
 			}
 		    }
 		}
-		
+
 		if (res == 0) {
 		    xmlChar *str = NULL, *strB = NULL;
 		    xmlSchemaKeyrefErr(vctxt,
@@ -23852,7 +23852,7 @@
 			xmlNodePtr attrNode,
 			int nodeLine,
 			const xmlChar *localName,
-			const xmlChar *nsName,			
+			const xmlChar *nsName,
 			int ownedNames,
 			xmlChar *value,
 			int ownedValue)
@@ -23878,7 +23878,7 @@
     if (nsName != NULL) {
 	if (xmlStrEqual(localName, BAD_CAST "nil")) {
 	    if (xmlStrEqual(attr->nsName, xmlSchemaInstanceNs)) {
-		attr->metaType = XML_SCHEMA_ATTR_INFO_META_XSI_NIL;		
+		attr->metaType = XML_SCHEMA_ATTR_INFO_META_XSI_NIL;
 	    }
 	} else if (xmlStrEqual(localName, BAD_CAST "type")) {
 	    if (xmlStrEqual(attr->nsName, xmlSchemaInstanceNs)) {
@@ -24099,7 +24099,7 @@
 	valType = valType;
     else
 	valType = xmlSchemaGetValType(val);
-    
+
     ret = 0;
     for (facetLink = type->facetSet; facetLink != NULL;
 	facetLink = facetLink->next) {
@@ -24148,11 +24148,11 @@
     ret = 0;
     for (facetLink = type->facetSet; facetLink != NULL;
 	facetLink = facetLink->next) {
-	
+
 	switch (facetLink->facet->type) {
 	    case XML_SCHEMA_FACET_LENGTH:
 	    case XML_SCHEMA_FACET_MINLENGTH:
-	    case XML_SCHEMA_FACET_MAXLENGTH:		    
+	    case XML_SCHEMA_FACET_MAXLENGTH:
 		ret = xmlSchemaValidateListSimpleTypeFacet(facetLink->facet,
 		    value, length, NULL);
 		break;
@@ -24164,7 +24164,7 @@
 		"validating against a list type facet");
 	    return (-1);
 	} else if (ret > 0) {
-	    if (fireErrors)		
+	    if (fireErrors)
 		xmlSchemaFacetErr(actxt, ret, node,
 		value, length, type, facetLink->facet, NULL, NULL, NULL);
 	    else
@@ -24241,7 +24241,7 @@
 		if (facetLink->facet->type != XML_SCHEMA_FACET_PATTERN)
 		    continue;
 		found = 1;
-		/* 
+		/*
 		* NOTE that for patterns, @value needs to be the
 		* normalized vaule.
 		*/
@@ -24253,7 +24253,7 @@
 			"validating against a pattern facet");
 		    return (-1);
 		} else {
-		    /* 
+		    /*
 		    * Save the last non-validating facet.
 		    */
 		    facet = facetLink->facet;
@@ -24276,12 +24276,12 @@
 
     return (error);
 }
- 
+
 static xmlChar *
 xmlSchemaNormalizeValue(xmlSchemaTypePtr type,
 			const xmlChar *value)
 {
-    switch (xmlSchemaGetWhiteSpaceFacetValue(type)) {	
+    switch (xmlSchemaGetWhiteSpaceFacetValue(type)) {
 	case XML_SCHEMA_WHITESPACE_COLLAPSE:
 	    return (xmlSchemaCollapseString(value));
 	case XML_SCHEMA_WHITESPACE_REPLACE:
@@ -24300,7 +24300,7 @@
     int ret;
     const xmlChar *nsName;
     xmlChar *local, *prefix = NULL;
-    
+
     ret = xmlValidateQName(value, 1);
     if (ret != 0) {
 	if (ret == -1) {
@@ -24323,7 +24323,7 @@
     *  - is there a default namespace?
     */
     nsName = xmlSchemaLookupNamespace(vctxt, prefix);
-    
+
     if (prefix != NULL) {
 	xmlFree(prefix);
 	/*
@@ -24380,7 +24380,7 @@
 	    value = normValue; \
 	isNormalized = 1; \
     }
-    
+
     if ((retVal != NULL) && (*retVal != NULL)) {
 	xmlSchemaFreeValue(*retVal);
 	*retVal = NULL;
@@ -24441,9 +24441,9 @@
 	* NOTATIONs need to be processed here, since they need
 	* to lookup in the hashtable of NOTATION declarations of the schema.
 	*/
-	if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) {	    
-	    switch (biType->builtInType) {		
-		case XML_SCHEMAS_NOTATION:		    
+	if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) {
+	    switch (biType->builtInType) {
+		case XML_SCHEMAS_NOTATION:
 		    ret = xmlSchemaValidateNotation(
 			(xmlSchemaValidCtxtPtr) actxt,
 			((xmlSchemaValidCtxtPtr) actxt)->schema,
@@ -24463,8 +24463,8 @@
 			    value, NULL, NULL);
 		    break;
 	    }
-	} else if (actxt->type == XML_SCHEMA_CTXT_PARSER) {	    
-	    switch (biType->builtInType) {		    
+	} else if (actxt->type == XML_SCHEMA_CTXT_PARSER) {
+	    switch (biType->builtInType) {
 		case XML_SCHEMAS_NOTATION:
 		    ret = xmlSchemaValidateNotation(NULL,
 			((xmlSchemaParserCtxtPtr) actxt)->schema, node,
@@ -24479,7 +24479,7 @@
 			ret = xmlSchemaValPredefTypeNodeNoNorm(biType,
 			    value, NULL, node);
 		    break;
-	    }	   
+	    }
 	} else {
 	    /*
 	    * Validation via a public API is not implemented yet.
@@ -24496,7 +24496,7 @@
 	    if (WXS_IS_LIST(type))
 		ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
 	    else
-		ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;	    
+		ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
 	}
 	if ((ret == 0) && (type->flags & XML_SCHEMAS_TYPE_HAS_FACETS)) {
 	    /*
@@ -24511,10 +24511,10 @@
 			"validating facets of atomic simple type");
 		    goto internal_error;
 		}
-		if (WXS_IS_LIST(type)) 
+		if (WXS_IS_LIST(type))
 		    ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
 		else
-		    ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;		
+		    ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
 	    }
 	}
 	if (fireErrors && (ret > 0))
@@ -24539,7 +24539,7 @@
 	* VAL TODO: Optimize validation of empty values.
 	* VAL TODO: We do not have computed values for lists.
 	*/
-	itemType = WXS_LIST_ITEMTYPE(type);	
+	itemType = WXS_LIST_ITEMTYPE(type);
 	cur = value;
 	do {
 	    while (IS_BLANK_CH(*cur))
@@ -24578,7 +24578,7 @@
 		}
 		ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
 		break;
-	    }	    
+	    }
 	    cur = end;
 	} while (*cur != 0);
 	FREE_AND_NULL(tmpValue);
@@ -24599,7 +24599,7 @@
 	    }
 	}
 	if (fireErrors && (ret > 0)) {
-	    /* 
+	    /*
 	    * Report the normalized value.
 	    */
 	    normalize = 1;
@@ -24629,7 +24629,7 @@
 	    AERROR_INT("xmlSchemaVCheckCVCSimpleType",
 		"union simple type has no member types");
 	    goto internal_error;
-	}	
+	}
 	/*
 	* Always normalize union type values, since we currently
 	* cannot store the whitespace information with the value
@@ -24637,7 +24637,7 @@
 	* not possible.
 	*/
 	while (memberLink != NULL) {
-	    if (valNeeded) 
+	    if (valNeeded)
 		ret = xmlSchemaVCheckCVCSimpleType(actxt, node,
 		    memberLink->type, value, &val, 0, 1, 0);
 	    else
@@ -24674,7 +24674,7 @@
 			"validating facets of union simple type");
 		    goto internal_error;
 		}
-		ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3;		
+		ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3;
 	    }
 	}
 	if (fireErrors && (ret > 0))
@@ -25089,11 +25089,11 @@
 static int
 xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
 {
-    xmlSchemaTypePtr type = vctxt->inode->typeDef;    
+    xmlSchemaTypePtr type = vctxt->inode->typeDef;
     xmlSchemaItemListPtr attrUseList;
     xmlSchemaAttributeUsePtr attrUse = NULL;
     xmlSchemaAttributePtr attrDecl = NULL;
-    xmlSchemaAttrInfoPtr iattr, tmpiattr;    
+    xmlSchemaAttrInfoPtr iattr, tmpiattr;
     int i, j, found, nbAttrs, nbUses;
     int xpathRes = 0, res, wildIDs = 0, fixed;
     xmlNodePtr defAttrOwnerElem = NULL;
@@ -25193,7 +25193,7 @@
 	    }
 	    tmpiattr->state = XML_SCHEMAS_ATTR_ERR_MISSING;
 	    tmpiattr->use = attrUse;
-	    tmpiattr->decl = attrDecl;	    
+	    tmpiattr->decl = attrDecl;
 	} else if ((attrUse->occurs == XML_SCHEMAS_ATTR_USE_OPTIONAL) &&
 	    ((attrUse->defValue != NULL) ||
 	     (attrDecl->defValue != NULL))) {
@@ -25421,7 +25421,7 @@
 	    * VAL TODO: Should we use the *normalized* value? This currently
 	    *   uses the *initial* value.
 	    */
-	    
+
 	    if (defAttrOwnerElem) {
 		xmlChar *normValue;
 		const xmlChar *value;
@@ -25513,7 +25513,7 @@
 	/*
 	* SPEC (cvc-attribute)
 	* (3) "The item's ·normalized value· must be locally ·valid·
-	* with respect to that {type definition} as per 
+	* with respect to that {type definition} as per
 	* String Valid (§3.14.4)."
 	*
 	* VAL TODO: Do we already have the
@@ -25534,7 +25534,7 @@
 		iattr->node, iattr->typeDef, iattr->value, NULL,
 		1, 0, 0);
 	}
-	    
+
 	if (res != 0) {
 	    if (res == -1) {
 		VERROR_INT("xmlSchemaVAttributesComplex",
@@ -25549,7 +25549,7 @@
 	    goto eval_idcs;
 	}
 
-	if (fixed) {	    
+	if (fixed) {
 	    /*
 	    * SPEC Attribute Locally Valid (Use) (cvc-au)
 	    * "For an attribute information item to be·valid·
@@ -25655,8 +25655,8 @@
 		xmlSchemaCustomErr(ACTXT_CAST vctxt,
 		    XML_SCHEMAV_CVC_AU, NULL, NULL,
 		    "The value '%s' does not match the fixed "
-		    "value constraint '%s'", 
-		    iattr->value, iattr->vcValue);		
+		    "value constraint '%s'",
+		    iattr->value, iattr->vcValue);
 		break;
 	    case XML_SCHEMAS_ATTR_ERR_WILD_STRICT_NO_DECL:
 		VERROR(XML_SCHEMAV_CVC_WILDCARD, NULL,
@@ -25718,7 +25718,7 @@
 	xmlSchemaElementPtr decl = NULL;
 
 	decl = xmlSchemaGetElem(vctxt->schema,
-	    vctxt->inode->localName, vctxt->inode->nsName);	    
+	    vctxt->inode->localName, vctxt->inode->nsName);
 	if (decl != NULL) {
 	    vctxt->inode->decl = decl;
 	    return (0);
@@ -25776,16 +25776,16 @@
 xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt,
 			      const xmlChar *value,
 			      xmlSchemaValPtr *val)
-{   
+{
     int ret = 0;
     xmlSchemaNodeInfoPtr inode = vctxt->inode;
 
     /*
     * cos-valid-default:
     * Schema Component Constraint: Element Default Valid (Immediate)
-    * For a string to be a valid default with respect to a type 
+    * For a string to be a valid default with respect to a type
     * definition the appropriate case among the following must be true:
-    */    
+    */
     if WXS_IS_COMPLEX(inode->typeDef) {
 	/*
 	* Complex type.
@@ -25793,7 +25793,7 @@
 	* SPEC (2.1) "its {content type} must be a simple type definition
 	* or mixed."
 	* SPEC (2.2.2) "If the {content type} is mixed, then the {content
-	* type}'s particle must be ·emptiable· as defined by 
+	* type}'s particle must be ·emptiable· as defined by
 	* Particle Emptiable (§3.9.6)."
 	*/
 	if ((! WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) &&
@@ -25807,18 +25807,18 @@
 		"or mixed content and a particle emptiable");
 	    return(ret);
 	}
-    }	
+    }
     /*
-    * 1 If the type definition is a simple type definition, then the string 
-    * must be ·valid· with respect to that definition as defined by String 
+    * 1 If the type definition is a simple type definition, then the string
+    * must be ·valid· with respect to that definition as defined by String
     * Valid (§3.14.4).
     *
     * AND
     *
-    * 2.2.1 If the {content type} is a simple type definition, then the 
-    * string must be ·valid· with respect to that simple type definition 
+    * 2.2.1 If the {content type} is a simple type definition, then the
+    * string must be ·valid· with respect to that simple type definition
     * as defined by String Valid (§3.14.4).
-    */  
+    */
     if (WXS_IS_SIMPLE(inode->typeDef)) {
 
 	ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST vctxt,
@@ -25832,7 +25832,7 @@
     if (ret < 0) {
 	VERROR_INT("xmlSchemaCheckCOSValidDefault",
 	    "calling xmlSchemaVCheckCVCSimpleType()");
-    }    
+    }
     return (ret);
 }
 
@@ -25866,13 +25866,13 @@
 
 static int
 xmlSchemaValidatorPushElem(xmlSchemaValidCtxtPtr vctxt)
-{    
+{
     vctxt->inode = xmlSchemaGetFreshElemInfo(vctxt);
     if (vctxt->inode == NULL) {
 	VERROR_INT("xmlSchemaValidatorPushElem",
 	    "calling xmlSchemaGetFreshElemInfo()");
 	return (-1);
-    }   
+    }
     vctxt->nbAttrInfos = 0;
     return (0);
 }
@@ -25895,7 +25895,7 @@
 
 
 
-/* 
+/*
 * Process END of element.
 */
 static int
@@ -25914,7 +25914,7 @@
 	*/
 	vctxt->skipDepth = vctxt->depth -1;
 	goto end_elem;
-    }    
+    }
     if ((inode->typeDef == NULL) ||
 	(inode->flags & XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE)) {
 	/*
@@ -25934,8 +25934,8 @@
 	* Workaround for "anyType".
 	*/
 	if (inode->typeDef->builtInType == XML_SCHEMAS_ANYTYPE)
-	    goto character_content;			
-	
+	    goto character_content;
+
 	if ((inode->flags & XML_SCHEMA_ELEM_INFO_ERR_BAD_CONTENT) == 0) {
 	    xmlChar *values[10];
 	    int terminal, nbval = 10, nbneg;
@@ -25956,12 +25956,12 @@
 #ifdef DEBUG_AUTOMATA
 		xmlGenericError(xmlGenericErrorContext,
 		    "AUTOMATON create on '%s'\n", inode->localName);
-#endif	    
+#endif
 	    }
 	    /*
 	    * Get hold of the still expected content, since a further
 	    * call to xmlRegExecPushString() will loose this information.
-	    */ 
+	    */
 	    xmlRegExecNextValues(inode->regexCtxt,
 		&nbval, &nbneg, &values[0], &terminal);
 	    ret = xmlRegExecPushString(inode->regexCtxt, NULL, NULL);
@@ -26011,14 +26011,14 @@
 	/*
 	* Speedup if no declaration exists.
 	*/
-	if (WXS_IS_SIMPLE(inode->typeDef)) {	    
+	if (WXS_IS_SIMPLE(inode->typeDef)) {
 	    ret = xmlSchemaVCheckINodeDataType(vctxt,
 		inode, inode->typeDef, inode->value);
 	} else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
 	    ret = xmlSchemaVCheckINodeDataType(vctxt,
 		inode, inode->typeDef->contentTypeDef,
 		inode->value);
-	}		
+	}
 	if (ret < 0) {
 	    VERROR_INT("xmlSchemaValidatorPopElem",
 		"calling xmlSchemaVCheckCVCSimpleType()");
@@ -26027,26 +26027,26 @@
 	goto end_elem;
     }
     /*
-    * cvc-elt (3.3.4) : 5 
+    * cvc-elt (3.3.4) : 5
     * The appropriate case among the following must be true:
     */
     /*
-    * cvc-elt (3.3.4) : 5.1 
-    * If the declaration has a {value constraint}, 
-    * the item has neither element nor character [children] and 
+    * cvc-elt (3.3.4) : 5.1
+    * If the declaration has a {value constraint},
+    * the item has neither element nor character [children] and
     * clause 3.2 has not applied, then all of the following must be true:
     */
     if ((inode->decl->value != NULL) &&
-	(inode->flags & XML_SCHEMA_ELEM_INFO_EMPTY) && 
+	(inode->flags & XML_SCHEMA_ELEM_INFO_EMPTY) &&
 	(! INODE_NILLED(inode))) {
 	/*
-	* cvc-elt (3.3.4) : 5.1.1 
+	* cvc-elt (3.3.4) : 5.1.1
 	* If the ·actual type definition· is a ·local type definition·
 	* then the canonical lexical representation of the {value constraint}
-	* value must be a valid default for the ·actual type definition· as 
-	* defined in Element Default Valid (Immediate) (§3.3.6). 
+	* value must be a valid default for the ·actual type definition· as
+	* defined in Element Default Valid (Immediate) (§3.3.6).
 	*/
-	/* 
+	/*
 	* NOTE: 'local' above means types acquired by xsi:type.
 	* NOTE: Although the *canonical* value is stated, it is not
 	* relevant if canonical or not. Additionally XML Schema 1.1
@@ -26069,22 +26069,22 @@
 	    * (see following).
 	    */
 	    goto default_psvi;
-	}	
+	}
 	/*
-	* cvc-elt (3.3.4) : 5.1.2 
-	* The element information item with the canonical lexical 
-	* representation of the {value constraint} value used as its 
-	* ·normalized value· must be ·valid· with respect to the 
+	* cvc-elt (3.3.4) : 5.1.2
+	* The element information item with the canonical lexical
+	* representation of the {value constraint} value used as its
+	* ·normalized value· must be ·valid· with respect to the
 	* ·actual type definition· as defined by Element Locally Valid (Type)
 	* (§3.3.4).
-	*/	    
+	*/
 	if (WXS_IS_SIMPLE(inode->typeDef)) {
 	    ret = xmlSchemaVCheckINodeDataType(vctxt,
 		inode, inode->typeDef, inode->decl->value);
 	} else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
 	    ret = xmlSchemaVCheckINodeDataType(vctxt,
 		inode, inode->typeDef->contentTypeDef,
-		inode->decl->value);	    
+		inode->decl->value);
 	}
 	if (ret != 0) {
 	    if (ret < 0) {
@@ -26105,7 +26105,7 @@
 	    xmlChar *normValue;
 	    /*
 	    * VAL TODO: Normalize the value.
-	    */	    
+	    */
 	    normValue = xmlSchemaNormalizeValue(inode->typeDef,
 		inode->decl->value);
 	    if (normValue != NULL) {
@@ -26118,15 +26118,15 @@
 		    "calling xmlNewText()");
 		goto internal_error;
 	    } else
-		xmlAddChild(inode->node, textChild);	    
+		xmlAddChild(inode->node, textChild);
 	}
-	
-    } else if (! INODE_NILLED(inode)) {	
+
+    } else if (! INODE_NILLED(inode)) {
 	/*
-	* 5.2.1 The element information item must be ·valid· with respect 
-	* to the ·actual type definition· as defined by Element Locally 
+	* 5.2.1 The element information item must be ·valid· with respect
+	* to the ·actual type definition· as defined by Element Locally
 	* Valid (Type) (§3.3.4).
-	*/	
+	*/
 	if (WXS_IS_SIMPLE(inode->typeDef)) {
 	     /*
 	    * SPEC (cvc-type) (3.1)
@@ -26135,7 +26135,7 @@
 	    * (Element) (§3.3.4) did not apply, then the ·normalized value·
 	    * must be ·valid· with respect to the type definition as defined
 	    * by String Valid (§3.14.4).
-	    */	    
+	    */
 	    ret = xmlSchemaVCheckINodeDataType(vctxt,
 		    inode, inode->typeDef, inode->value);
 	} else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
@@ -26146,14 +26146,14 @@
 	    * Element Locally Valid (Complex Type) (§3.4.4);"
 	    *
 	    * SPEC (cvc-complex-type) (2.2)
-	    * "If the {content type} is a simple type definition, ... 
+	    * "If the {content type} is a simple type definition, ...
 	    * the ·normalized value· of the element information item is
 	    * ·valid· with respect to that simple type definition as
 	    * defined by String Valid (§3.14.4)."
 	    */
 	    ret = xmlSchemaVCheckINodeDataType(vctxt,
 		inode, inode->typeDef->contentTypeDef, inode->value);
-	}	
+	}
 	if (ret != 0) {
 	    if (ret < 0) {
 		VERROR_INT("xmlSchemaValidatorPopElem",
@@ -26163,7 +26163,7 @@
 	    goto end_elem;
 	}
 	/*
-	* 5.2.2 If there is a fixed {value constraint} and clause 3.2 has 
+	* 5.2.2 If there is a fixed {value constraint} and clause 3.2 has
 	* not applied, all of the following must be true:
 	*/
 	if ((inode->decl->value != NULL) &&
@@ -26174,7 +26174,7 @@
 	    * done on computed values.
 	    */
 	    /*
-	    * 5.2.2.1 The element information item must have no element 
+	    * 5.2.2.1 The element information item must have no element
 	    * information item [children].
 	    */
 	    if (inode->flags &
@@ -26186,28 +26186,28 @@
 		goto end_elem;
 	    } else {
 		/*
-		* 5.2.2.2 The appropriate case among the following must 
+		* 5.2.2.2 The appropriate case among the following must
 		* be true:
-		*/		
+		*/
 		if (WXS_HAS_MIXED_CONTENT(inode->typeDef)) {
 		    /*
-		    * 5.2.2.2.1 If the {content type} of the ·actual type 
-		    * definition· is mixed, then the *initial value* of the 
-		    * item must match the canonical lexical representation 
+		    * 5.2.2.2.1 If the {content type} of the ·actual type
+		    * definition· is mixed, then the *initial value* of the
+		    * item must match the canonical lexical representation
 		    * of the {value constraint} value.
 		    *
-		    * ... the *initial value* of an element information 
-		    * item is the string composed of, in order, the 
-		    * [character code] of each character information item in 
+		    * ... the *initial value* of an element information
+		    * item is the string composed of, in order, the
+		    * [character code] of each character information item in
 		    * the [children] of that element information item.
-		    */		   
+		    */
 		    if (! xmlStrEqual(inode->value, inode->decl->value)){
-			/* 
+			/*
 			* VAL TODO: Report invalid & expected values as well.
 			* VAL TODO: Implement the canonical stuff.
 			*/
 			ret = XML_SCHEMAV_CVC_ELT_5_2_2_2_1;
-			xmlSchemaCustomErr(ACTXT_CAST vctxt, 
+			xmlSchemaCustomErr(ACTXT_CAST vctxt,
 			    ret, NULL, NULL,
 			    "The initial value '%s' does not match the fixed "
 			    "value constraint '%s'",
@@ -26216,9 +26216,9 @@
 		    }
 		} else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
 		    /*
-		    * 5.2.2.2.2 If the {content type} of the ·actual type 
-		    * definition· is a simple type definition, then the 
-		    * *actual value* of the item must match the canonical 
+		    * 5.2.2.2.2 If the {content type} of the ·actual type
+		    * definition· is a simple type definition, then the
+		    * *actual value* of the item must match the canonical
 		    * lexical representation of the {value constraint} value.
 		    */
 		    /*
@@ -26233,16 +26233,16 @@
 			xmlSchemaCustomErr(ACTXT_CAST vctxt,
 			    ret, NULL, NULL,
 			    "The actual value '%s' does not match the fixed "
-			    "value constraint '%s'", 
+			    "value constraint '%s'",
 			    inode->value,
 			    inode->decl->value);
 			goto end_elem;
-		    }		    
+		    }
 		}
-	    }	    
+	    }
 	}
     }
-    
+
 end_elem:
     if (vctxt->depth < 0) {
 	/* TODO: raise error? */
@@ -26252,7 +26252,7 @@
 	vctxt->skipDepth = -1;
     /*
     * Evaluate the history of XPath state objects.
-    */    
+    */
     if (inode->appliedXPath &&
 	(xmlSchemaXPathProcessHistory(vctxt, vctxt->depth) == -1))
 	goto internal_error;
@@ -26268,7 +26268,7 @@
     *   We will currently build IDC node-tables and bubble them only if
     *   keyrefs do exist.
     */
-    
+
     /*
     * Add the current IDC target-nodes to the IDC node-tables.
     */
@@ -26302,7 +26302,7 @@
 	    */
 	    if (xmlSchemaBubbleIDCNodeTables(vctxt) == -1)
 		goto internal_error;
-	}	
+	}
     }
     /*
     * Clear the current ielem.
@@ -26335,10 +26335,10 @@
 	    aidc = aidc->next;
 	} while (aidc != NULL);
     }
-    vctxt->depth--;        
+    vctxt->depth--;
     vctxt->inode = vctxt->elemInfos[vctxt->depth];
     /*
-    * VAL TODO: 7 If the element information item is the ·validation root·, it must be 
+    * VAL TODO: 7 If the element information item is the ·validation root·, it must be
     * ·valid· per Validation Root Valid (ID/IDREF) (§3.3.4).
     */
     return (ret);
@@ -26595,7 +26595,7 @@
     if (consumed != NULL)
 	*consumed = 0;
     if (INODE_NILLED(vctxt->inode)) {
-	/* 
+	/*
 	* SPEC cvc-elt (3.3.4 - 3.2.1)
 	* "The element information item must have no character or
 	* element information item [children]."
@@ -26611,7 +26611,7 @@
     * information item [children]."
     */
     if (vctxt->inode->typeDef->contentType ==
-	    XML_SCHEMA_CONTENT_EMPTY) {    
+	    XML_SCHEMA_CONTENT_EMPTY) {
 	VERROR(XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, NULL,
 	    "Character content is not allowed, "
 	    "because the content type is empty");
@@ -26622,12 +26622,12 @@
 	    XML_SCHEMA_CONTENT_ELEMENTS) {
 	if ((nodeType != XML_TEXT_NODE) ||
 	    (! xmlSchemaIsBlank((xmlChar *) value, len))) {
-	    /* 
-	    * SPEC cvc-complex-type (2.3) 
-	    * "If the {content type} is element-only, then the 
-	    * element information item has no character information 
-	    * item [children] other than those whose [character 
-	    * code] is defined as a white space in [XML 1.0 (Second 
+	    /*
+	    * SPEC cvc-complex-type (2.3)
+	    * "If the {content type} is element-only, then the
+	    * element information item has no character information
+	    * item [children] other than those whose [character
+	    * code] is defined as a white space in [XML 1.0 (Second
 	    * Edition)]."
 	    */
 	    VERROR(XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, NULL,
@@ -26637,7 +26637,7 @@
 	}
 	return (0);
     }
-    
+
     if ((value == NULL) || (value[0] == 0))
 	return (0);
     /*
@@ -26649,7 +26649,7 @@
 	((vctxt->inode->decl == NULL) ||
 	(vctxt->inode->decl->value == NULL)))
 	return (0);
-    
+
     if (vctxt->inode->value == NULL) {
 	/*
 	* Set the value.
@@ -26692,7 +26692,7 @@
 	    len = xmlStrlen(value);
 	/*
 	* Concat the value.
-	*/	
+	*/
 	if (vctxt->inode->flags & XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES) {
 	    vctxt->inode->value = BAD_CAST xmlStrncat(
 		(xmlChar *) vctxt->inode->value, value, len);
@@ -26701,7 +26701,7 @@
 		BAD_CAST xmlStrncatNew(vctxt->inode->value, value, len);
 	    vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES;
 	}
-    }	
+    }
 
     return (0);
 }
@@ -26718,7 +26718,7 @@
 	goto internal_error;
     }
     if (vctxt->xsiAssemble) {
-	/* 
+	/*
 	* We will stop validation if there was an error during
 	* dynamic schema construction.
 	* Note that we simply set @skipDepth to 0, this could
@@ -26831,12 +26831,12 @@
     	VERROR(ret, NULL,
     	    "The type definition is absent");
 	goto exit;
-    }    
+    }
     if (vctxt->inode->typeDef->flags & XML_SCHEMAS_TYPE_ABSTRACT) {
 	vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE;
 	ret = XML_SCHEMAV_CVC_TYPE_2;
     	    VERROR(ret, NULL,
-    	    "The type definition is abstract");	
+    	    "The type definition is abstract");
 	goto exit;
     }
     /*
@@ -26917,7 +26917,7 @@
 	nodeType = xmlTextReaderNodeType(vctxt->reader);
 
 	if (nodeType == XML_ELEMENT_NODE) {
-	    
+
 	    vctxt->depth++;
 	    if (xmlSchemaValidatorPushElem(vctxt) == -1) {
 		VERROR_INT("xmlSchemaVReaderWalk",
@@ -27092,8 +27092,8 @@
 * Process text content.
 */
 static void
-xmlSchemaSAXHandleText(void *ctx, 
-		       const xmlChar * ch, 
+xmlSchemaSAXHandleText(void *ctx,
+		       const xmlChar * ch,
 		       int len)
 {
     xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx;
@@ -27117,10 +27117,10 @@
 * Process CDATA content.
 */
 static void
-xmlSchemaSAXHandleCDataSection(void *ctx, 
-			     const xmlChar * ch, 
+xmlSchemaSAXHandleCDataSection(void *ctx,
+			     const xmlChar * ch,
 			     int len)
-{   
+{
     xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx;
 
     if (vctxt->depth < 0)
@@ -27154,20 +27154,20 @@
 
 static void
 xmlSchemaSAXHandleStartElementNs(void *ctx,
-				 const xmlChar * localname, 
-				 const xmlChar * prefix ATTRIBUTE_UNUSED, 
-				 const xmlChar * URI, 
-				 int nb_namespaces, 
-				 const xmlChar ** namespaces, 
-				 int nb_attributes, 
-				 int nb_defaulted ATTRIBUTE_UNUSED, 
+				 const xmlChar * localname,
+				 const xmlChar * prefix ATTRIBUTE_UNUSED,
+				 const xmlChar * URI,
+				 int nb_namespaces,
+				 const xmlChar ** namespaces,
+				 int nb_attributes,
+				 int nb_defaulted ATTRIBUTE_UNUSED,
 				 const xmlChar ** attributes)
-{  
+{
     xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx;
     int ret;
     xmlSchemaNodeInfoPtr ielem;
     int i, j;
-    
+
     /*
     * SAX VAL TODO: What to do with nb_defaulted?
     */
@@ -27195,16 +27195,16 @@
     ielem->flags |= XML_SCHEMA_ELEM_INFO_EMPTY;
     /*
     * Register namespaces on the elem info.
-    */    
+    */
     if (nb_namespaces != 0) {
 	/*
 	* Although the parser builds its own namespace list,
 	* we have no access to it, so we'll use an own one.
 	*/
-        for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) {	    
+        for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) {
 	    /*
 	    * Store prefix and namespace name.
-	    */	   
+	    */
 	    if (ielem->nsBindings == NULL) {
 		ielem->nsBindings =
 		    (const xmlChar **) xmlMalloc(10 *
@@ -27240,7 +27240,7 @@
 	    } else
 		ielem->nsBindings[ielem->nbNsBindings * 2 + 1] =
 		    namespaces[j+1];
-	    ielem->nbNsBindings++;	    	    
+	    ielem->nbNsBindings++;
 	}
     }
     /*
@@ -27254,7 +27254,7 @@
         for (j = 0, i = 0; i < nb_attributes; i++, j += 5) {
 	    /*
 	    * Duplicate the value.
-	    */	 
+	    */
 	    value = xmlStrndup(attributes[j+3],
 		attributes[j+4] - attributes[j+3]);
 	    /*
@@ -27281,7 +27281,7 @@
 	    goto internal_error;
 	}
 	goto exit;
-    }    
+    }
 
 exit:
     return;
@@ -27391,7 +27391,7 @@
 #ifdef LIBXML_READER_ENABLED
     vctxt->reader = NULL;
 #endif
-    vctxt->hasKeyrefs = 0;    
+    vctxt->hasKeyrefs = 0;
 
     if (vctxt->value != NULL) {
         xmlSchemaFreeValue(vctxt->value);
@@ -27461,7 +27461,7 @@
 		break;
 	    xmlSchemaClearElemInfo(vctxt, ei);
 	}
-    }    
+    }
     xmlSchemaItemListClear(vctxt->nodeQNames);
     /* Recreate the dict. */
     xmlDictFree(vctxt->dict);
@@ -27563,7 +27563,7 @@
  * @ctxt: the schema validation context
  *
  * Check if any error was detected during validation.
- * 
+ *
  * Returns 1 if valid so far, 0 if errors were detected, and -1 in case
  *         of internal error.
  */
@@ -27622,7 +27622,7 @@
 
 /**
  * xmlSchemaGetValidErrors:
- * @ctxt:	a XML-Schema validation context
+ * @ctxt: a XML-Schema validation context
  * @err: the error function result
  * @warn: the warning function result
  * @ctx: the functions context result
@@ -27683,7 +27683,7 @@
 
 /**
  * xmlSchemaValidCtxtGetOptions:
- * @ctxt:	a schema validation context
+ * @ctxt: a schema validation context
  *
  * Get the validation context options.
  *
@@ -27751,7 +27751,7 @@
 			nsName = NULL;
 		    ret = xmlSchemaValidatorPushAttribute(vctxt,
 			(xmlNodePtr) attr,
-			/* 
+			/*
 			* Note that we give it the line number of the
 			* parent element.
 			*/
@@ -27807,7 +27807,7 @@
 	    (node->type == XML_ENTITY_REF_NODE)) {
 	    /*
 	    * DOC VAL TODO: What to do with entities?
-	    */	    
+	    */
 	    VERROR_INT("xmlSchemaVDocWalk",
 		"there is at least one entity reference in the node-tree "
 		"currently being validated. Processing of entities with "
@@ -27867,7 +27867,7 @@
 xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) {
     /*
     * Some initialization.
-    */    
+    */
     vctxt->err = 0;
     vctxt->nberrors = 0;
     vctxt->depth = -1;
@@ -27884,9 +27884,9 @@
     */
     if (vctxt->schema == NULL) {
 	xmlSchemaParserCtxtPtr pctxt;
-	
+
 	vctxt->xsiAssemble = 1;
-	/* 
+	/*
 	* If not schema was given then we will create a schema
 	* dynamically using XSI schema locations.
 	*
@@ -27902,8 +27902,8 @@
 	*/
 	vctxt->schema = xmlSchemaNewSchema(pctxt);
 	if (vctxt->schema == NULL)
-	    return (-1);		
-	/* 
+	    return (-1);
+	/*
 	* Create the schema construction context.
 	*/
 	pctxt->constructor = xmlSchemaConstructionCtxtCreate(pctxt->dict);
@@ -27914,13 +27914,13 @@
 	* Take ownership of the constructor to be able to free it.
 	*/
 	pctxt->ownsConstructor = 1;
-    }	
-    /* 
-    * Augment the IDC definitions for the main schema and all imported ones 
+    }
+    /*
+    * Augment the IDC definitions for the main schema and all imported ones
     * NOTE: main schema if the first in the imported list
     */
     xmlHashScan(vctxt->schema->schemasImports,(xmlHashScanner)xmlSchemaAugmentImportedIDC, vctxt);
-    
+
     return(0);
 }
 
@@ -28335,10 +28335,10 @@
 }
 
 static void
-startElementNsSplit(void *ctx, const xmlChar * localname, 
-		    const xmlChar * prefix, const xmlChar * URI, 
-		    int nb_namespaces, const xmlChar ** namespaces, 
-		    int nb_attributes, int nb_defaulted, 
+startElementNsSplit(void *ctx, const xmlChar * localname,
+		    const xmlChar * prefix, const xmlChar * URI,
+		    int nb_namespaces, const xmlChar ** namespaces,
+		    int nb_attributes, int nb_defaulted,
 		    const xmlChar ** attributes) {
     xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx;
     if (ctxt == NULL)
@@ -28357,7 +28357,7 @@
 }
 
 static void
-endElementNsSplit(void *ctx, const xmlChar * localname, 
+endElementNsSplit(void *ctx, const xmlChar * localname,
 		    const xmlChar * prefix, const xmlChar * URI) {
     xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx;
     if (ctxt == NULL)
@@ -28398,7 +28398,7 @@
     old_sax = *sax;
     if ((old_sax != NULL) && (old_sax->initialized != XML_SAX2_MAGIC))
         return(NULL);
-    if ((old_sax != NULL) && 
+    if ((old_sax != NULL) &&
         (old_sax->startElementNs == NULL) && (old_sax->endElementNs == NULL) &&
         ((old_sax->startElement != NULL) || (old_sax->endElement != NULL)))
         return(NULL);
@@ -28416,7 +28416,7 @@
     ret->ctxt = ctxt;
     ret->user_sax_ptr = sax;
     ret->user_sax = old_sax;
-    if (old_sax == NULL) {	
+    if (old_sax == NULL) {
         /*
 	 * go direct, no need for the split block and functions.
 	 */
@@ -28437,7 +28437,7 @@
     } else {
        /*
         * for each callback unused by Schemas initialize it to the Split
-	* routine only if non NULL in the user block, this can speed up 
+	* routine only if non NULL in the user block, this can speed up
 	* things at the SAX level.
 	*/
         if (old_sax->internalSubset != NULL)
@@ -28590,7 +28590,7 @@
     if (options)
         xmlCtxtUseOptions(pctxt, options);
 #endif
-    pctxt->linenumbers = 1;    
+    pctxt->linenumbers = 1;
 
     inputStream = xmlNewIOInputStream(pctxt, input, enc);;
     if (inputStream == NULL) {
@@ -28658,16 +28658,33 @@
 
     if ((ctxt == NULL) || (filename == NULL))
         return (-1);
-    
+
     input = xmlParserInputBufferCreateFilename(filename,
 	XML_CHAR_ENCODING_NONE);
     if (input == NULL)
 	return (-1);
     ret = xmlSchemaValidateStream(ctxt, input, XML_CHAR_ENCODING_NONE,
-	NULL, NULL);    
+	NULL, NULL);
     return (ret);
 }
 
+/**
+ * xmlSchemaValidCtxtGetParserCtxt:
+ * @ctxt: a schema validation context
+ *
+ * allow access to the parser context of the schema validation context
+ *
+ * Returns the parser context of the schema validation context or NULL
+ *         in case of error.
+ */
+xmlParserCtxtPtr
+xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt)
+{
+    if (ctxt == NULL)
+        return(NULL);
+    return (ctxt->parserCtxt);
+}
+
 #define bottom_xmlschemas
 #include "elfgcchack.h"
 #endif /* LIBXML_SCHEMAS_ENABLED */