fixing #130453 XInclude element with no href attribute fully integrating

* xinclude.c: fixing #130453 XInclude element with no href attribute
* relaxng.c rngparser.c include/libxml2/relaxng.h: fully integrating
  the compact syntax will require more work, postponed for the
  2.6.5 release.
Daniel
diff --git a/ChangeLog b/ChangeLog
index d7b818a..cc46bf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sun Jan 25 20:52:09 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+	* xinclude.c: fixing #130453 XInclude element with no href attribute
+	* relaxng.c rngparser.c include/libxml2/relaxng.h: fully integrating 
+	  the compact syntax will require more work, postponed for the
+	  2.6.5 release.
+
 Sat Jan 24 09:30:22 CET 2004 Daniel Veillard <daniel@veillard.com>
 
 	* include/libxml/schemasInternals.h xmlschemas.c: applied patch from
diff --git a/include/libxml/relaxng.h b/include/libxml/relaxng.h
index 3743f3e..e970289 100644
--- a/include/libxml/relaxng.h
+++ b/include/libxml/relaxng.h
@@ -83,6 +83,16 @@
 } xmlRelaxNGValidErr;
 
 /*
+ * xmlRelaxNGParserFlags:
+ *
+ * List of possible Relax NG Parser flags
+ */
+typedef enum {
+    XML_RELAXNGP_NONE = 0,
+    XML_RELAXNGP_FREE_DOC = 1,
+    XML_RELAXNGP_CRNG = 2
+} xmlRelaxNGParserFlag;
+/*
  * Interfaces for parsing.
  */
 XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL 
@@ -93,6 +103,10 @@
 XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL   
 		    xmlRelaxNGNewDocParserCtxt	(xmlDocPtr doc);
 
+XMLPUBFUN int XMLCALL
+		    xmlRelaxParserSetFlag	(xmlRelaxNGParserCtxtPtr ctxt,
+		    				 int flag);
+
 XMLPUBFUN void XMLCALL		
 		    xmlRelaxNGFreeParserCtxt	(xmlRelaxNGParserCtxtPtr ctxt);
 XMLPUBFUN void XMLCALL			
diff --git a/relaxng.c b/relaxng.c
index 985eff2..dcaf880 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -246,6 +246,8 @@
     /* used to compile content models */
     xmlAutomataPtr am;          /* the automata */
     xmlAutomataStatePtr state;  /* used to build the automata */
+
+    int crng;			/* compact syntax and other flags */
 };
 
 #define FLAGS_IGNORABLE		1
@@ -1382,7 +1384,39 @@
 
 /************************************************************************
  * 									*
- * 			Document functions					*
+ * 			Semi internal functions				*
+ * 									*
+ ************************************************************************/
+
+/**
+ * xmlRelaxParserSetFlag:
+ * @ctxt: a RelaxNG parser context
+ * @flags: a set of flags values
+ *
+ * Semi private function used to pass informations to a parser context
+ * which are a combination of xmlRelaxNGParserFlag .
+ *
+ * Returns 0 if success and -1 in case of error
+ */
+int
+xmlRelaxParserSetFlag(xmlRelaxNGParserCtxtPtr ctxt, int flags)
+{
+    if (ctxt == NULL) return(-1);
+    if (flags & XML_RELAXNGP_FREE_DOC) {
+        ctxt->crng |= XML_RELAXNGP_FREE_DOC;
+	flags -= XML_RELAXNGP_FREE_DOC;
+    }
+    if (flags & XML_RELAXNGP_CRNG) {
+        ctxt->crng |= XML_RELAXNGP_CRNG;
+	flags -= XML_RELAXNGP_CRNG;
+    }
+    if (flags != 0) return(-1);
+    return(0);
+}
+
+/************************************************************************
+ * 									*
+ * 			Document functions				*
  * 									*
  ************************************************************************/
 static xmlDocPtr xmlRelaxNGCleanupDoc(xmlRelaxNGParserCtxtPtr ctxt,
diff --git a/rngparser.c b/rngparser.c
index 67a25b7..bc72f6b 100644
--- a/rngparser.c
+++ b/rngparser.c
@@ -1,6 +1,11 @@
 /**
  * rngparser.c: parser for the Relax-NG compact syntax.
  *
+ * Based on:
+ *   RELAX NG Compact Syntax
+ *   Committee Specification 21 November 2002
+ *   http://www.oasis-open.org/committees/relax-ng/compact-20021121.html
+ *
  * See Copyright for the status of this software.
  *
  * Daniel Veillard <veillard@redhat.com>
@@ -1417,17 +1422,18 @@
 }
 
 /**
- * xmlParseCRNG:
+ * xmlConvertCRNG:
  * @schemas:  pointer to the text of the compact schemas
  * @len:  length of the schemas in bytes (or 0)
+ * @encoding:  encoding indicated by the context or NULL
  *
  * Compiles the schemas into the equivalent Relax-NG XML structure
  *
  * Returns the xmlDocPtr resulting from the compilation or
  *         NULL in case of error
  */
-static xmlDocPtr
-xmlParseCRNG(const xmlChar *schemas, int len) {
+xmlDocPtr
+xmlConvertCRNG(const char *schemas, int len, const char *encoding) {
     struct _xmlCRelaxNGParserCtxt ctxt;
     xmlDocPtr ret = NULL;
 
@@ -1484,8 +1490,8 @@
     ctxt.key_ref = xmlDictLookup(ctxt.dict, BAD_CAST "ref", 3);
     ctxt.key_define = xmlDictLookup(ctxt.dict, BAD_CAST "define", 6);
 
-    /* xmlParseCRNGTokenize(&ctxt); */
-    xmlParseCRNG_topLevel(&ctxt);
+    /* xmlConvertCRNGTokenize(&ctxt); */
+    xmlConvertCRNG_topLevel(&ctxt);
 
     xmlDictFree(ctxt.dict);
 
@@ -1493,6 +1499,21 @@
     return(ret);
 }
 
+/**
+ * xmlConvertCRNGFile:
+ * @URL: URL or filename for the resource
+ * @encoding:  encoding indicated by the context or NULL
+ *
+ * Compiles the schemas into the equivalent Relax-NG XML structure
+ *
+ * Returns the xmlDocPtr resulting from the compilation or
+ *         NULL in case of error
+ */
+xmlDocPtr
+xmlConvertCRNG(const char *URL, const char *encoding) {
+}
+
+#ifdef STANDALONE
 const xmlChar *schemas = 
 "# RELAX NG XML syntax specified in compact syntax.\n\
 \n\
@@ -1562,10 +1583,11 @@
 int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
     xmlDocPtr res;
 
-    res = xmlParseCRNG(schemas, -1);
+    res = xmlConvertCRNG(schemas, -1);
     if (res != NULL) {
         xmlDocFormatDump(stdout, res, 1);
 	xmlFreeDoc(res);
     }
     return(0);
 }
+#endif
diff --git a/xinclude.c b/xinclude.c
index e4f9821..56f7350 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -1841,10 +1841,9 @@
      */
     href = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_HREF);
     if (href == NULL) {
-        /* @@@@ */
-	xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, 
-		       XML_XINCLUDE_NO_HREF, "no href\n", NULL);
-	return(-1);
+	href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */
+	if (href == NULL) 
+	    return(-1);
     }
     parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE);
     if (parse != NULL) {